mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-30 05:18:13 +08:00
win32: minor fixup in WIN_UpdateKeymap()
Remove unused defines in SDL_windowsevents.c
This commit is contained in:
committed by
Sam Lantinga
parent
2c4360ce8f
commit
3152b98e87
@@ -51,15 +51,6 @@
|
|||||||
|
|
||||||
/* #define HIGHDPI_DEBUG */
|
/* #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... */
|
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
|
||||||
#ifndef WM_XBUTTONDOWN
|
#ifndef WM_XBUTTONDOWN
|
||||||
#define WM_XBUTTONDOWN 0x020B
|
#define WM_XBUTTONDOWN 0x020B
|
||||||
|
|||||||
@@ -120,7 +120,9 @@ void WIN_UpdateKeymap(SDL_bool send_event)
|
|||||||
WIN_ResetDeadKeys();
|
WIN_ResetDeadKeys();
|
||||||
|
|
||||||
for (i = 0; i < SDL_arraysize(windows_scancode_table); i++) {
|
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 */
|
/* Make sure this scancode is a valid character scancode */
|
||||||
scancode = windows_scancode_table[i];
|
scancode = windows_scancode_table[i];
|
||||||
if (scancode == SDL_SCANCODE_UNKNOWN) {
|
if (scancode == SDL_SCANCODE_UNKNOWN) {
|
||||||
@@ -133,7 +135,9 @@ void WIN_UpdateKeymap(SDL_bool send_event)
|
|||||||
continue;
|
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) {
|
if (!vk) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -147,8 +151,8 @@ void WIN_UpdateKeymap(SDL_bool send_event)
|
|||||||
BYTE keyboardState[256] = { 0 };
|
BYTE keyboardState[256] = { 0 };
|
||||||
WCHAR buffer[16] = { 0 };
|
WCHAR buffer[16] = { 0 };
|
||||||
Uint32 *ch = 0;
|
Uint32 *ch = 0;
|
||||||
int result = ToUnicode(vk, i, keyboardState, buffer, 16, 0);
|
int result = ToUnicode(vk, sc, keyboardState, buffer, 16, 0);
|
||||||
buffer[SDL_abs(result) + 1] = 0;
|
buffer[SDL_abs(result)] = 0;
|
||||||
|
|
||||||
/* Convert UTF-16 to UTF-32 code points */
|
/* 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));
|
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];
|
BYTE keyboardState[256];
|
||||||
WCHAR buffer[16];
|
WCHAR buffer[16];
|
||||||
int keycode, scancode, result, i;
|
int vk, sc, result, i;
|
||||||
|
|
||||||
if (!GetKeyboardState(keyboardState)) {
|
if (!GetKeyboardState(keyboardState)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
keycode = VK_SPACE;
|
vk = VK_SPACE;
|
||||||
scancode = MapVirtualKey(keycode, MAPVK_VK_TO_VSC);
|
sc = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
|
||||||
if (scancode == 0) {
|
if (sc == 0) {
|
||||||
/* the keyboard doesn't have this key */
|
/* the keyboard doesn't have this key */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 5; i++) {
|
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) {
|
if (result > 0) {
|
||||||
/* success */
|
/* success */
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user