Correct touch position

parent 078572bb
......@@ -39,16 +39,19 @@ Variable buttonmask
dup sf@ sfloat+ sf@ ;
: 2sf! ( r1 r2 addr -- )
dup sfloat+ sf! sf! ;
: getXY ( index -- rx ry )
dup getX screen-xy cell+ @ s>f f-
getY screen-xy @ s>f f- ;
: samepos? ( rx ry -- flag )
lastpos 2sf@ frot f- f**2 f-rot f- f**2 f+ samepos f< ;
: ?samepos ( -- )
0 getX 0 getY fover fover samepos? 0= IF 0 to clicks THEN lastpos 2sf! ;
0 getXY fover fover samepos? 0= IF 0 to clicks THEN lastpos 2sf! ;
Variable xy$
: >xy$ ( -- xy$ )
getPointerCount 2* sfloats xy$ $!len
0 xy$ $@ bounds ?DO
dup getX I sf! dup getY I sfloat+ sf! 1+
dup getXY I 2sf! 1+
2 sfloats +LOOP drop xy$
getDownTime downtime 2!
getEventTime lasttime 2! ;
......@@ -71,7 +74,7 @@ Variable xy$
getButtonState buttonmask !
top-act IF xy$ buttonmask @ top-act .touchup THEN ;
: action-move ( -- )
flags #pending bit@ 0 getX 0 getY samepos? 0= and IF
flags #pending bit@ 0 getXY samepos? 0= and IF
send-clicks 0 to clicks
THEN
top-act IF xy$ buttonmask @ top-act .touchmove THEN ;
......
......@@ -415,7 +415,11 @@ previous
Defer scale-me ' terminal-scale-me is scale-me
2Variable screen-xy
2Variable screen-wh
: config-changer ( -- )
screen-xywh@ screen-wh 2! screen-xy 2!
getwh >screen-orientation scale-me need-sync on
form-chooser ;
: ?config-changer ( -- )
......
......@@ -190,6 +190,8 @@ JValue psize
newPoint to psize
JValue dmetrics
newDisplayMetrics to dmetrics
JValue screenrect
newRect to screenrect
: screen-orientation@ ( -- 0..3 )
clazz >o getWindowManager >o getDefaultDisplay >o
......@@ -200,6 +202,10 @@ newDisplayMetrics to dmetrics
: screen-size@ ( -- w h )
screen-metric@
dmetrics >o widthPixels heightPixels o> ;
: screen-xywh@ ( -- x y w h )
clazz >o getWindow >o getDecorView >o
screenrect getWindowVisibleDisplayFrame ref> ref> o>
screenrect >o left top right bottom o> ;
$80 Constant FLAG_KEEP_SCREEN_ON
......
......@@ -59,6 +59,7 @@ jni-class: android/view/Display
jni-method: getRotation getRotation ()I
SDK_INT 13 >= [IF]
jni-method: getSizeD getSize (Landroid/graphics/Point;)V
jni-method: getRectSize getRectSize (Landroid/graphics/Rect;)V
[ELSE]
jni-method: getWidth getWidth ()I
jni-method: getHeight getHeight ()I
......@@ -70,6 +71,13 @@ jni-new: newPoint ()V
jni-field: x x I
jni-field: y y I
jni-class: android/graphics/Rect
jni-new: newRect ()V
jni-field: top top I
jni-field: left left I
jni-field: right right I
jni-field: bottom bottom I
jni-class: android/util/DisplayMetrics
jni-new: newDisplayMetrics ()V
jni-field: heightPixels heightPixels I
......@@ -84,6 +92,9 @@ jni-class: android/view/inputmethod/InputMethodManager
jni-method: toggleSoftInput toggleSoftInput (II)V
jni-class: android/view/View
jni-method: getWindowVisibleDisplayFrame getWindowVisibleDisplayFrame (Landroid/graphics/Rect;)V
jni-class: android/view/Window
jni-method: getDecorView getDecorView ()Landroid/view/View;
jni-method: addFlags addFlags (I)V
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment