Allow gamepad without mapped buttons to use scan code directly in android

This commit is contained in:
Benau
2020-04-21 18:07:43 +08:00
parent 5faa856b0e
commit abfb9e535c
3 changed files with 23 additions and 2 deletions

View File

@@ -223,6 +223,7 @@ public class SuperTuxKartActivity extends NativeActivity
int scan_code = event.getScanCode();
// KeyCharacterMap.COMBINING_ACCENT is not handled at the moment
int unichar = event.getUnicodeChar(meta_state);
int repeat_count = event.getRepeatCount();
// Dispatch the different events depending on where they come from
// Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
@@ -236,7 +237,7 @@ public class SuperTuxKartActivity extends NativeActivity
// Note that we process events with specific key codes here
if (action == KeyEvent.ACTION_DOWN)
{
if (SDLControllerManager.onNativePadDown(device_id, key_code, meta_state, scan_code, unichar) == 0)
if (SDLControllerManager.onNativePadDown(device_id, key_code, meta_state, scan_code, unichar, repeat_count) == 0)
return true;
}
else if (action == KeyEvent.ACTION_UP)
@@ -246,7 +247,6 @@ public class SuperTuxKartActivity extends NativeActivity
}
}
int repeat_count = event.getRepeatCount();
// User pressed back button
if (key_code == KeyEvent.KEYCODE_BACK &&
action == KeyEvent.ACTION_DOWN)