diff --git a/common/wwkeyboard.cpp b/common/wwkeyboard.cpp index b7f2d683..8020d1f2 100644 --- a/common/wwkeyboard.cpp +++ b/common/wwkeyboard.cpp @@ -88,7 +88,10 @@ WWKeyboardClass::WWKeyboardClass(void) , Tail(0) , DownSkip(0) { +#if defined(_WIN32) memset(KeyState, '\0', sizeof(KeyState)); +#endif + memset(DownState, '\0', sizeof(DownState)); } @@ -297,19 +300,6 @@ KeyASCIIType WWKeyboardClass::To_ASCII(unsigned short key) return KA_NONE; } - /* - ** Set the KeyState buffer to reflect the shift bits stored in the key value. - */ - if (key & WWKEY_SHIFT_BIT) { - KeyState[VK_SHIFT] = 0x80; - } - if (key & WWKEY_CTRL_BIT) { - KeyState[VK_CONTROL] = 0x80; - } - if (key & WWKEY_ALT_BIT) { - KeyState[VK_MENU] = 0x80; - } - /* ** Ask windows to translate the key into an ASCII equivalent. */ @@ -330,9 +320,21 @@ KeyASCIIType WWKeyboardClass::To_ASCII(unsigned short key) return sdl_keymap[key]; } #elif defined(_WIN32) + /* + ** Set the KeyState buffer to reflect the shift bits stored in the key value. + */ + if (key & WWKEY_SHIFT_BIT) { + KeyState[VK_SHIFT] = 0x80; + } + if (key & WWKEY_CTRL_BIT) { + KeyState[VK_CONTROL] = 0x80; + } + if (key & WWKEY_ALT_BIT) { + KeyState[VK_MENU] = 0x80; + } + scancode = MapVirtualKeyA(key & 0xFF, 0); result = ToAscii((UINT)(key & 0xFF), (UINT)scancode, (PBYTE)KeyState, (LPWORD)buffer, (UINT)0); -#endif /* ** Restore the KeyState buffer back to pristine condition. @@ -346,6 +348,7 @@ KeyASCIIType WWKeyboardClass::To_ASCII(unsigned short key) if (key & WWKEY_ALT_BIT) { KeyState[VK_MENU] = 0; } +#endif /* ** If Windows could not perform the translation as expected, then diff --git a/common/wwkeyboard.h b/common/wwkeyboard.h index e49f364a..a18c047a 100644 --- a/common/wwkeyboard.h +++ b/common/wwkeyboard.h @@ -900,7 +900,9 @@ class WWKeyboardClass ** This is a keyboard state array that is used to aid in translating ** KN_ keys into KA_ keys. */ +#if defined(_WIN32) unsigned char KeyState[256]; +#endif /* ** This is the circular keyboard holding buffer. It holds the VK key and