Implemented SDL_GetKeyState().
authorRyan C. Gordon <icculus@icculus.org>
Fri, 08 Mar 2019 21:31:21 -0500
changeset 11176364b4bafbb
parent 110 967a0716df06
child 112 be327fd46284
Implemented SDL_GetKeyState().

Now Psychonauts works. :)
src/SDL12_compat.c
     1.1 --- a/src/SDL12_compat.c	Fri Mar 08 21:30:59 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Fri Mar 08 21:31:21 2019 -0500
     1.3 @@ -740,6 +740,7 @@
     1.4  static Uint8 EventStates[SDL12_NUMEVENTS];
     1.5  static int SwapInterval = 0;
     1.6  static JoystickOpenedItem JoystickOpenList[16];
     1.7 +static Uint8 KeyState[SDLK12_LAST];
     1.8  
     1.9  // !!! FIXME: need a mutex for the event queue.
    1.10  #define SDL12_MAXEVENTS 128
    1.11 @@ -1838,6 +1839,16 @@
    1.12      return SDLK12_UNKNOWN;
    1.13  }
    1.14  
    1.15 +DECLSPEC Uint8 * SDLCALL
    1.16 +SDL_GetKeyState(int *numkeys)
    1.17 +{
    1.18 +    if (numkeys) {
    1.19 +        *numkeys = (int) SDL_arraysize(KeyState);
    1.20 +    }
    1.21 +    return KeyState;
    1.22 +}
    1.23 +
    1.24 +
    1.25  static int
    1.26  EventFilter20to12(void *data, SDL_Event *event20)
    1.27  {
    1.28 @@ -1925,6 +1936,9 @@
    1.29              if (event12.key.keysym.sym == SDLK12_UNKNOWN) {
    1.30                  return 0;  /* drop it if we can't map it */
    1.31              }
    1.32 +
    1.33 +            KeyState[event12.key.keysym.sym] = event20->key.state;
    1.34 +
    1.35              event12.type = (event20->type == SDL_KEYDOWN) ? SDL12_KEYDOWN : SDL12_KEYUP;
    1.36              event12.key.which = 0;
    1.37              event12.key.state = event20->key.state;