Skip to content
Permalink
Browse files

Implemented SDL_GetKeyState().

Now Psychonauts works.  :)
  • Loading branch information
icculus committed Mar 9, 2019
1 parent d69092b commit 9c9f59a8583a6c811dddc310aae5ce80439bc32b
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/SDL12_compat.c
@@ -740,6 +740,7 @@ static SDL12_Cursor *CurrentCursor12 = NULL;
static Uint8 EventStates[SDL12_NUMEVENTS];
static int SwapInterval = 0;
static JoystickOpenedItem JoystickOpenList[16];
static Uint8 KeyState[SDLK12_LAST];

// !!! FIXME: need a mutex for the event queue.
#define SDL12_MAXEVENTS 128
@@ -1838,6 +1839,16 @@ Keysym20to12(const SDL_Keycode keysym20)
return SDLK12_UNKNOWN;
}

DECLSPEC Uint8 * SDLCALL
SDL_GetKeyState(int *numkeys)
{
if (numkeys) {
*numkeys = (int) SDL_arraysize(KeyState);
}
return KeyState;
}


static int
EventFilter20to12(void *data, SDL_Event *event20)
{
@@ -1925,6 +1936,9 @@ EventFilter20to12(void *data, SDL_Event *event20)
if (event12.key.keysym.sym == SDLK12_UNKNOWN) {
return 0; /* drop it if we can't map it */
}

KeyState[event12.key.keysym.sym] = event20->key.state;

event12.type = (event20->type == SDL_KEYDOWN) ? SDL12_KEYDOWN : SDL12_KEYUP;
event12.key.which = 0;
event12.key.state = event20->key.state;

0 comments on commit 9c9f59a

Please sign in to comment.