Compare commits

...

2 Commits

Author SHA1 Message Date
Alexander Batalov 3cca4a81e9 Check back button to RMB emulation 2022-10-02 13:56:49 +03:00
Alexander Batalov 3924b6bba3 Fix back button on Android 2022-09-28 09:19:02 +03:00
2 changed files with 9 additions and 0 deletions

View File

@ -2036,6 +2036,14 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
switch (event.getAction()) { switch (event.getAction()) {
case KeyEvent.ACTION_DOWN: case KeyEvent.ACTION_DOWN:
case KeyEvent.ACTION_UP: case KeyEvent.ACTION_UP:
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
SDLActivity.onNativeMouse(MotionEvent.BUTTON_SECONDARY, MotionEvent.ACTION_DOWN, 0, 0, true);
} else if (event.getAction() == KeyEvent.ACTION_UP) {
SDLActivity.onNativeMouse(MotionEvent.BUTTON_SECONDARY, MotionEvent.ACTION_UP, 0, 0, true);
}
}
// mark the event as handled or it will be handled by system // mark the event as handled or it will be handled by system
// handling KEYCODE_BACK by system will call onBackPressed() // handling KEYCODE_BACK by system will call onBackPressed()
return true; return true;

View File

@ -43,6 +43,7 @@ int main(int argc, char* argv[])
#endif #endif
#if __ANDROID__ #if __ANDROID__
SDL_SetHint(SDL_HINT_ANDROID_TRAP_BACK_BUTTON, "1");
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"); SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
chdir(SDL_AndroidGetExternalStoragePath()); chdir(SDL_AndroidGetExternalStoragePath());