Skip to content

Commit

Permalink
[ion/simulator/sdl] Fix Android 11 touch events
Browse files Browse the repository at this point in the history
Based on SDL commit :
libsdl-org/SDL@2e38c94
  • Loading branch information
HugoNumworks authored and EmilieNumworks committed Nov 26, 2021
1 parent a80d620 commit e385767
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1866,14 +1866,24 @@ else if (event.getAction() == KeyEvent.ACTION_UP) {
@Override
public boolean onTouch(View v, MotionEvent event) {
/* Ref: http://developer.android.com/training/gestures/multi.html */
final int touchDevId = event.getDeviceId();
int touchDevId = event.getDeviceId();
final int pointerCount = event.getPointerCount();
int action = event.getActionMasked();
int pointerFingerId;
int mouseButton;
int i = -1;
float x,y,p;

/**
* Prevent id to be -1, since it's used in SDL internal for synthetic events
* Appears when using Android emulator, eg:
* adb shell input mouse tap 100 100
* adb shell input touchscreen tap 100 100
*/
if (touchDevId < 0) {
touchDevId -= 1;
}

// 12290 = Samsung DeX mode desktop mouse
// 12290 = 0x3002 = 0x2002 | 0x1002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN
// 0x2 = SOURCE_CLASS_POINTER
Expand Down

0 comments on commit e385767

Please sign in to comment.