From 9c9f59a8583a6c811dddc310aae5ce80439bc32b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 8 Mar 2019 21:31:21 -0500 Subject: [PATCH] Implemented SDL_GetKeyState(). Now Psychonauts works. :) --- src/SDL12_compat.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c index 5ff2b071c..a29a9c5fc 100644 --- a/src/SDL12_compat.c +++ b/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;