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:
@@ -1,4 +1,6 @@
|
|||||||
Changes towards version 0.2:
|
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
|
- OpenGL mode now fully supports partial screen updates -Mika
|
||||||
- Fixed melee ship selection-box bugs -fOSSiL
|
- Fixed melee ship selection-box bugs -fOSSiL
|
||||||
- Added a 4th button to starcon.key 'Esc' now emergency-escapes -PBlue
|
- Added a 4th button to starcon.key 'Esc' now emergency-escapes -PBlue
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ static SWORD **JoyaxisValues = 0;
|
|||||||
|
|
||||||
static BOOLEAN (* PauseFunc) (void) = 0;
|
static BOOLEAN (* PauseFunc) (void) = 0;
|
||||||
static BOOLEAN InputInitialized = FALSE;
|
static BOOLEAN InputInitialized = FALSE;
|
||||||
|
UWORD UNICODEToKBD (UNICODE which_key);
|
||||||
|
|
||||||
UNICODE PauseKey = 0;
|
UNICODE PauseKey = 0;
|
||||||
UNICODE ExitKey = 0;
|
UNICODE ExitKey = 0;
|
||||||
@@ -111,25 +112,27 @@ void
|
|||||||
ProcessKeyboardEvent(const SDL_Event *Event)
|
ProcessKeyboardEvent(const SDL_Event *Event)
|
||||||
{
|
{
|
||||||
SDLKey k = Event->key.keysym.sym;
|
SDLKey k = Event->key.keysym.sym;
|
||||||
|
UNICODE map_key;
|
||||||
if (!InputInitialized)
|
if (!InputInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Event->type == SDL_KEYDOWN)
|
if (Event->type == SDL_KEYDOWN)
|
||||||
{
|
{
|
||||||
if (Event->key.keysym.unicode != 0)
|
if (Event->key.keysym.unicode != 0)
|
||||||
kbdbuf[kbdtail] = (UNICODE) Event->key.keysym.unicode;
|
map_key = (UNICODE) Event->key.keysym.unicode;
|
||||||
else
|
else
|
||||||
kbdbuf[kbdtail] = KBDToUNICODE(k);
|
map_key = KBDToUNICODE(k);
|
||||||
|
kbdbuf[kbdtail] = map_key;
|
||||||
kbdtail = (kbdtail + 1) & (KBDBUFSIZE - 1);
|
kbdtail = (kbdtail + 1) & (KBDBUFSIZE - 1);
|
||||||
if (kbdtail == kbdhead)
|
if (kbdtail == kbdhead)
|
||||||
kbdhead = (kbdhead + 1) & (KBDBUFSIZE - 1);
|
kbdhead = (kbdhead + 1) & (KBDBUFSIZE - 1);
|
||||||
if (KBDToUNICODE(k) == AbortKey)
|
if (map_key == AbortKey)
|
||||||
exit(0);
|
exit(0);
|
||||||
KeyboardDown[k] |= 0x3;
|
KeyboardDown[UNICODEToKBD (map_key)] |= 0x3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
KeyboardDown[k] &= (~0x1);
|
KeyboardDown[UNICODEToKBD (KBDToUNICODE (k))] &= (~0x1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user