Correctly detect button presses on keyboards with alternate key mappings.

This may fix the key-mapping issues Mac users have reported


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@688 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
ghaushe
2003-02-05 20:19:07 +00:00
parent 71e99b18cf
commit 5ffa64991b
2 changed files with 10 additions and 5 deletions
+2
View File
@@ -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
+8 -5
View File
@@ -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);
}
}