win32: minor fixup in WIN_UpdateKeymap()

Remove unused defines in SDL_windowsevents.c
This commit is contained in:
Dimitriy Ryazantcev 2023-12-20 13:54:29 +02:00 committed by Sam Lantinga
parent 2c4360ce8f
commit 3152b98e87
2 changed files with 13 additions and 18 deletions

View File

@ -51,15 +51,6 @@
/* #define HIGHDPI_DEBUG */
/* Masks for processing the windows KEYDOWN and KEYUP messages */
#define REPEATED_KEYMASK (1 << 30)
#define EXTENDED_KEYMASK (1 << 24)
#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
#ifndef VK_OEM_NEC_EQUAL
#define VK_OEM_NEC_EQUAL 0x92
#endif
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
#ifndef WM_XBUTTONDOWN
#define WM_XBUTTONDOWN 0x020B

View File

@ -120,7 +120,9 @@ void WIN_UpdateKeymap(SDL_bool send_event)
WIN_ResetDeadKeys();
for (i = 0; i < SDL_arraysize(windows_scancode_table); i++) {
int vk;
Uint8 vk;
Uint16 sc;
/* Make sure this scancode is a valid character scancode */
scancode = windows_scancode_table[i];
if (scancode == SDL_SCANCODE_UNKNOWN) {
@ -133,7 +135,9 @@ void WIN_UpdateKeymap(SDL_bool send_event)
continue;
}
vk = MapVirtualKey(i, MAPVK_VSC_TO_VK);
/* Unpack the single byte index to make the scan code. */
sc = MAKEWORD(i & 0x7f, (i & 0x80) ? 0xe0 : 0x00);
vk = LOBYTE(MapVirtualKey(sc, MAPVK_VSC_TO_VK));
if (!vk) {
continue;
}
@ -147,8 +151,8 @@ void WIN_UpdateKeymap(SDL_bool send_event)
BYTE keyboardState[256] = { 0 };
WCHAR buffer[16] = { 0 };
Uint32 *ch = 0;
int result = ToUnicode(vk, i, keyboardState, buffer, 16, 0);
buffer[SDL_abs(result) + 1] = 0;
int result = ToUnicode(vk, sc, keyboardState, buffer, 16, 0);
buffer[SDL_abs(result)] = 0;
/* Convert UTF-16 to UTF-32 code points */
ch = (Uint32 *)SDL_iconv_string("UTF-32LE", "UTF-16LE", (const char *)buffer, (SDL_abs(result) + 1) * sizeof(WCHAR));
@ -196,21 +200,21 @@ void WIN_ResetDeadKeys()
*/
BYTE keyboardState[256];
WCHAR buffer[16];
int keycode, scancode, result, i;
int vk, sc, result, i;
if (!GetKeyboardState(keyboardState)) {
return;
}
keycode = VK_SPACE;
scancode = MapVirtualKey(keycode, MAPVK_VK_TO_VSC);
if (scancode == 0) {
vk = VK_SPACE;
sc = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
if (sc == 0) {
/* the keyboard doesn't have this key */
return;
}
for (i = 0; i < 5; i++) {
result = ToUnicode(keycode, scancode, keyboardState, buffer, 16, 0);
result = ToUnicode(vk, sc, keyboardState, buffer, 16, 0);
if (result > 0) {
/* success */
return;