Simplify code a bit

This commit is contained in:
M374LX 2024-01-16 00:05:10 -03:00
parent 9e93915107
commit 44c18cb683

View File

@ -80,8 +80,8 @@ static PlatformData platform = { 0 }; // Platform specific data
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Local Variables Definition // Local Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define SCANCODE_MAPPED_NUM 162 #define KEYCODE_MAPPED_NUM 162
static const KeyboardKey ScancodeToKey[SCANCODE_MAPPED_NUM] = { static const KeyboardKey KeycodeMap[KEYCODE_MAPPED_NUM] = {
KEY_NULL, // AKEYCODE_UNKNOWN KEY_NULL, // AKEYCODE_UNKNOWN
0, // AKEYCODE_SOFT_LEFT 0, // AKEYCODE_SOFT_LEFT
0, // AKEYCODE_SOFT_RIGHT 0, // AKEYCODE_SOFT_RIGHT
@ -1185,12 +1185,8 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
return 1; // Handled gamepad button return 1; // Handled gamepad button
} }
KeyboardKey key = KEY_NULL; KeyboardKey key = (keycode > 0 && keycode < KEYCODE_MAPPED_NUM) ? KeycodeMap[keycode] : KEY_NULL;
if (keycode > 0 && keycode < SCANCODE_MAPPED_NUM) if (key != KEY_NULL)
{
key = ScancodeToKey[keycode];
if (key > 0)
{ {
// Save current key and its state // Save current key and its state
// NOTE: Android key action is 0 for down and 1 for up // NOTE: Android key action is 0 for down and 1 for up
@ -1204,7 +1200,6 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
else if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_MULTIPLE) CORE.Input.Keyboard.keyRepeatInFrame[key] = 1; else if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_MULTIPLE) CORE.Input.Keyboard.keyRepeatInFrame[key] = 1;
else CORE.Input.Keyboard.currentKeyState[key] = 0; // Key up else CORE.Input.Keyboard.currentKeyState[key] = 0; // Key up
} }
}
if (keycode == AKEYCODE_POWER) if (keycode == AKEYCODE_POWER)
{ {