Skip to content

Commit e385767

Browse files
HugoNumworksEmilieNumworks
authored andcommitted
[ion/simulator/sdl] Fix Android 11 touch events
Based on SDL commit : libsdl-org/SDL@2e38c94
1 parent a80d620 commit e385767

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ion/src/simulator/android/src/java/org/libsdl/app/SDLActivity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,14 +1866,24 @@ else if (event.getAction() == KeyEvent.ACTION_UP) {
18661866
@Override
18671867
public boolean onTouch(View v, MotionEvent event) {
18681868
/* Ref: http://developer.android.com/training/gestures/multi.html */
1869-
final int touchDevId = event.getDeviceId();
1869+
int touchDevId = event.getDeviceId();
18701870
final int pointerCount = event.getPointerCount();
18711871
int action = event.getActionMasked();
18721872
int pointerFingerId;
18731873
int mouseButton;
18741874
int i = -1;
18751875
float x,y,p;
18761876

1877+
/**
1878+
* Prevent id to be -1, since it's used in SDL internal for synthetic events
1879+
* Appears when using Android emulator, eg:
1880+
* adb shell input mouse tap 100 100
1881+
* adb shell input touchscreen tap 100 100
1882+
*/
1883+
if (touchDevId < 0) {
1884+
touchDevId -= 1;
1885+
}
1886+
18771887
// 12290 = Samsung DeX mode desktop mouse
18781888
// 12290 = 0x3002 = 0x2002 | 0x1002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN
18791889
// 0x2 = SOURCE_CLASS_POINTER

0 commit comments

Comments
 (0)