diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 69a7c7efd..4e1f64bf0 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.2: +- Correctly deal with multiply-mapped keys. This may fix some keys + not being detected correctly on the Mac as well - PBlue - OpenGL mode now fully supports partial screen updates -Mika - Fixed melee ship selection-box bugs -fOSSiL - Added a 4th button to starcon.key 'Esc' now emergency-escapes -PBlue diff --git a/sc2/src/sc2code/libs/input/sdl/input.c b/sc2/src/sc2code/libs/input/sdl/input.c index 22a9a68c2..89923bc06 100644 --- a/sc2/src/sc2code/libs/input/sdl/input.c +++ b/sc2/src/sc2code/libs/input/sdl/input.c @@ -34,6 +34,7 @@ static SWORD **JoyaxisValues = 0; static BOOLEAN (* PauseFunc) (void) = 0; static BOOLEAN InputInitialized = FALSE; +UWORD UNICODEToKBD (UNICODE which_key); UNICODE PauseKey = 0; UNICODE ExitKey = 0; @@ -111,25 +112,27 @@ void ProcessKeyboardEvent(const SDL_Event *Event) { SDLKey k = Event->key.keysym.sym; + UNICODE map_key; if (!InputInitialized) return; if (Event->type == SDL_KEYDOWN) { if (Event->key.keysym.unicode != 0) - kbdbuf[kbdtail] = (UNICODE) Event->key.keysym.unicode; + map_key = (UNICODE) Event->key.keysym.unicode; else - kbdbuf[kbdtail] = KBDToUNICODE(k); + map_key = KBDToUNICODE(k); + kbdbuf[kbdtail] = map_key; kbdtail = (kbdtail + 1) & (KBDBUFSIZE - 1); if (kbdtail == kbdhead) kbdhead = (kbdhead + 1) & (KBDBUFSIZE - 1); - if (KBDToUNICODE(k) == AbortKey) + if (map_key == AbortKey) exit(0); - KeyboardDown[k] |= 0x3; + KeyboardDown[UNICODEToKBD (map_key)] |= 0x3; } else { - KeyboardDown[k] &= (~0x1); + KeyboardDown[UNICODEToKBD (KBDToUNICODE (k))] &= (~0x1); } }