From dfce9bf3693adcaf616c9ce18e02a4aeef69d322 Mon Sep 17 00:00:00 2001 From: Simon Anciaux <14198779+mrmixer@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:09:01 +0200 Subject: [PATCH] Fix wrong initialization of keycode lookup table Up until now, several keys were assigned the same key value because the `keycode_lookup_table` array wasn't properly initialized. The values at the end of the array were all set to `KeyCode_Ex0 + 1` which is 112. This would cause several key to be treated as the same key. In my case the key next to the left shift key ( `<` and `>` on AZERTY) was getting the same value as the `Right Windows key`. But I suppose that the left and right windows key would get the same value too (I can't check this as I have only 1 windows key on my keyboard). This fix just properly initialize the array. I also fixed a typo in a function name: `keycode_physical_translaion_is_wrong` => `keycode_physical_translation_is_wrong`. --- code/platform_win32/win32_4ed.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/platform_win32/win32_4ed.cpp b/code/platform_win32/win32_4ed.cpp index 007e25f4..0f7ab82a 100644 --- a/code/platform_win32/win32_4ed.cpp +++ b/code/platform_win32/win32_4ed.cpp @@ -781,12 +781,12 @@ win32_keycode_init(void){ keycode_lookup_table[VK_NUMPAD9] = KeyCode_NumPad9; for (i32 i = 0xDF; i < 0xFF; i += 1){ - keycode_lookup_table[i] = KeyCode_Ex0 + 1; + keycode_lookup_table[i] = KeyCode_Ex0 + i - 0xDF; } } internal b32 -keycode_physical_translaion_is_wrong(u64 vk){ +keycode_physical_translation_is_wrong(u64 vk){ b32 result = false; switch (vk){ case VK_UP: case VK_DOWN: case VK_LEFT: case VK_RIGHT: @@ -1225,7 +1225,7 @@ win32_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ u64 vk = wParam; if (win32vars.key_mode == KeyMode_Physical && - !keycode_physical_translaion_is_wrong(vk)){ + !keycode_physical_translation_is_wrong(vk)){ UINT scan_code = ((lParam >> 16) & bitmask_8); vk = MapVirtualKeyEx(scan_code, MAPVK_VSC_TO_VK_EX, win32vars.kl_universal); }