Skip to content

Commit

Permalink
Merge pull request #2245 from cdwfs/add-numpad-key-support
Browse files Browse the repository at this point in the history
Add numpad keys to keycodes
  • Loading branch information
nesbox authored Jul 31, 2023
2 parents d1012ea + 0e09562 commit 91b8d24
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 33 deletions.
4 changes: 3 additions & 1 deletion src/studio/screens/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ static void initGamepadButtons(StudioMainMenu* menu)
"TAB", "RET", "BACKS","DEL", "INS", "PGUP", "PGDN", "HOME",
"END", "UP", "DOWN", "LEFT", "RIGHT","CAPS", "CTRL", "SHIFT",
"ALT", "ESC", "F1", "F2", "F3", "F4", "F5", "F6",
"F7", "F8", "F9", "F10", "F11", "F12",
"F7", "F8", "F9", "F10", "F11", "F12", "NP0", "NP1",
"NP2", "NP3", "NP4", "NP5", "NP6", "NP7", "NP8", "NP9",
"NP+", "NP-", "NP*", "NP/", "NPENT", "NP.",
};

for(s32 i = 0, index = menu->gamepads.index * TIC_BUTTONS; i != TIC_BUTTONS; ++i)
Expand Down
32 changes: 16 additions & 16 deletions src/system/baremetalpi/keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ tic_key_left, // KeyLeft, 0x50
tic_key_down, // KeyDown, 0x51
tic_key_up, // KeyUp, 0x52
tic_key_unknown, // KeyNumLock, 0x53
tic_key_unknown, // KeyKP_Divide, 0x54
tic_key_unknown, // KeyKP_Multiply, 0x55
tic_key_unknown, // KeyKP_Subtract, 0x56
tic_key_unknown, // KeyKP_Add, 0x57
tic_key_unknown, // KeyKP_Enter, 0x58
tic_key_unknown, // KeyEnd, 0x59
tic_key_unknown, // KeyDown, 0x5A
tic_key_unknown, // KeyPageDown, 0x5B
tic_key_unknown, // KeyLeft, 0x5C
tic_key_unknown, // KeyKP_Center, 0x5D
tic_key_unknown, // KeyRight, 0x5E
tic_key_unknown, // KeyHome, 0x5F
tic_key_unknown, // KeyUp, 0x60
tic_key_unknown, // KeyPageUp, 0x61
tic_key_unknown, // KeyInsert, 0x62
tic_key_unknown, // KeyDelete, 0x63
tic_key_numpaddivide, // KeyKP_Divide, 0x54
tic_key_numpadmultiply, // KeyKP_Multiply, 0x55
tic_key_numpadminus, // KeyKP_Subtract, 0x56
tic_key_numpadplus, // KeyKP_Add, 0x57
tic_key_numpadenter, // KeyKP_Enter, 0x58
tic_key_numpad1, // KeyEnd, 0x59
tic_key_numpad2, // KeyDown, 0x5A
tic_key_numpad3, // KeyPageDown, 0x5B
tic_key_numpad4, // KeyLeft, 0x5C
tic_key_numpad5, // KeyKP_Center, 0x5D
tic_key_numpad6, // KeyRight, 0x5E
tic_key_numpad7, // KeyHome, 0x5F
tic_key_numpad8, // KeyUp, 0x60
tic_key_numpad9, // KeyPageUp, 0x61
tic_key_numpad0, // KeyInsert, 0x62
tic_key_numpadperiod, // KeyDelete, 0x63
tic_key_unknown, // '<', 0x64
tic_key_unknown, // KeyApplication, 0x65
tic_key_unknown, // KeyNone, 0x66
Expand Down
16 changes: 16 additions & 0 deletions src/system/libretro/tic80_libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ RETRO_API void retro_init(void)
state->keymap[RETROK_F11] = tic_key_f11;
state->keymap[RETROK_F12] = tic_key_f12;
state->keymap[RETROK_F12] = tic_key_f12;
state->keymap[RETROK_KP0] = tic_key_numpad0;
state->keymap[RETROK_KP1] = tic_key_numpad1;
state->keymap[RETROK_KP2] = tic_key_numpad2;
state->keymap[RETROK_KP3] = tic_key_numpad3;
state->keymap[RETROK_KP4] = tic_key_numpad4;
state->keymap[RETROK_KP5] = tic_key_numpad5;
state->keymap[RETROK_KP6] = tic_key_numpad6;
state->keymap[RETROK_KP7] = tic_key_numpad7;
state->keymap[RETROK_KP8] = tic_key_numpad8;
state->keymap[RETROK_KP9] = tic_key_numpad9;
state->keymap[RETROK_KP_PERIOD] = tic_key_numpadperiod;
state->keymap[RETROK_KP_DIVIDE] = tic_key_numpaddivide;
state->keymap[RETROK_KP_MULTIPLY] = tic_key_numpadmultiply;
state->keymap[RETROK_KP_MINUS] = tic_key_numpadminus;
state->keymap[RETROK_KP_PLUS] = tic_key_numpadplus;
state->keymap[RETROK_KP_ENTER] = tic_key_numpadenter;
}

/**
Expand Down
17 changes: 17 additions & 0 deletions src/system/sdl/keycodes.inl
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,20 @@
[tic_key_f10] = SDLK_F10,
[tic_key_f11] = SDLK_F11,
[tic_key_f12] = SDLK_F12,

[tic_key_numpad0] = SDLK_KP_0,
[tic_key_numpad1] = SDLK_KP_1,
[tic_key_numpad2] = SDLK_KP_2,
[tic_key_numpad3] = SDLK_KP_3,
[tic_key_numpad4] = SDLK_KP_4,
[tic_key_numpad5] = SDLK_KP_5,
[tic_key_numpad6] = SDLK_KP_6,
[tic_key_numpad7] = SDLK_KP_7,
[tic_key_numpad8] = SDLK_KP_8,
[tic_key_numpad9] = SDLK_KP_9,
[tic_key_numpadplus] = SDLK_KP_PLUS,
[tic_key_numpadminus] = SDLK_KP_MINUS,
[tic_key_numpadmultiply] = SDLK_KP_MULTIPLY,
[tic_key_numpaddivide] = SDLK_KP_DIVIDE,
[tic_key_numpadenter] = SDLK_KP_ENTER,
[tic_key_numpadperiod] = SDLK_KP_PERIOD,
32 changes: 16 additions & 16 deletions src/system/sokol/sokol.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,22 +291,22 @@ static void handleKeydown(sapp_keycode keycode, bool down)
[SAPP_KEYCODE_F23] = tic_key_unknown,
[SAPP_KEYCODE_F24] = tic_key_unknown,
[SAPP_KEYCODE_F25] = tic_key_unknown,
[SAPP_KEYCODE_KP_0] = tic_key_0,
[SAPP_KEYCODE_KP_1] = tic_key_1,
[SAPP_KEYCODE_KP_2] = tic_key_2,
[SAPP_KEYCODE_KP_3] = tic_key_3,
[SAPP_KEYCODE_KP_4] = tic_key_4,
[SAPP_KEYCODE_KP_5] = tic_key_5,
[SAPP_KEYCODE_KP_6] = tic_key_6,
[SAPP_KEYCODE_KP_7] = tic_key_7,
[SAPP_KEYCODE_KP_8] = tic_key_8,
[SAPP_KEYCODE_KP_9] = tic_key_9,
[SAPP_KEYCODE_KP_DECIMAL] = tic_key_unknown,
[SAPP_KEYCODE_KP_DIVIDE] = tic_key_unknown,
[SAPP_KEYCODE_KP_MULTIPLY] = tic_key_unknown,
[SAPP_KEYCODE_KP_SUBTRACT] = tic_key_unknown,
[SAPP_KEYCODE_KP_ADD] = tic_key_unknown,
[SAPP_KEYCODE_KP_ENTER] = tic_key_return,
[SAPP_KEYCODE_KP_0] = tic_key_numpad0,
[SAPP_KEYCODE_KP_1] = tic_key_numpad1,
[SAPP_KEYCODE_KP_2] = tic_key_numpad2,
[SAPP_KEYCODE_KP_3] = tic_key_numpad3,
[SAPP_KEYCODE_KP_4] = tic_key_numpad4,
[SAPP_KEYCODE_KP_5] = tic_key_numpad5,
[SAPP_KEYCODE_KP_6] = tic_key_numpad6,
[SAPP_KEYCODE_KP_7] = tic_key_numpad7,
[SAPP_KEYCODE_KP_8] = tic_key_numpad8,
[SAPP_KEYCODE_KP_9] = tic_key_numpad9,
[SAPP_KEYCODE_KP_DECIMAL] = tic_key_numpadperiod,
[SAPP_KEYCODE_KP_DIVIDE] = tic_key_numpaddivide,
[SAPP_KEYCODE_KP_MULTIPLY] = tic_key_numpadmultiply,
[SAPP_KEYCODE_KP_SUBTRACT] = tic_key_numpadminus,
[SAPP_KEYCODE_KP_ADD] = tic_key_numpadplus,
[SAPP_KEYCODE_KP_ENTER] = tic_key_numpadenter,
[SAPP_KEYCODE_KP_EQUAL] = tic_key_equals,
[SAPP_KEYCODE_LEFT_SHIFT] = tic_key_shift,
[SAPP_KEYCODE_LEFT_CONTROL] = tic_key_ctrl,
Expand Down
17 changes: 17 additions & 0 deletions src/tic.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,23 @@ typedef enum
tic_key_f11,
tic_key_f12,

tic_key_numpad0,
tic_key_numpad1,
tic_key_numpad2,
tic_key_numpad3,
tic_key_numpad4,
tic_key_numpad5,
tic_key_numpad6,
tic_key_numpad7,
tic_key_numpad8,
tic_key_numpad9,
tic_key_numpadplus,
tic_key_numpadminus,
tic_key_numpadmultiply,
tic_key_numpaddivide,
tic_key_numpadenter,
tic_key_numpadperiod,

////////////////

tic_keys_count
Expand Down

0 comments on commit 91b8d24

Please sign in to comment.