diff --git a/SDL/files/SDL_dcevents.c b/SDL/files/SDL_dcevents.c index 4710be5..bc9080a 100644 --- a/SDL/files/SDL_dcevents.c +++ b/SDL/files/SDL_dcevents.c @@ -25,6 +25,7 @@ slouken@libsdl.org Modified by Lawrence Sebald + Modified by Falco Girgis */ #include "SDL.h" @@ -33,9 +34,7 @@ #include "SDL_dcvideo.h" #include "SDL_dcevents_c.h" -#include -#include -#include +#include const static unsigned short sdl_key[]= { /*0*/ 0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', @@ -101,7 +100,11 @@ static void mouse_update(void) { } static void keyboard_update(void) { +#if KOS_VERSION_BELOW(2, 2, 0) static kbd_state_t old_state; +#else + static kbd_mods_t old_mods; +#endif kbd_state_t *state; maple_device_t *dev; int shiftkeys; @@ -116,6 +119,7 @@ static void keyboard_update(void) { if(!state) return; +#if KOS_VERSION_BELOW(2, 2, 0) shiftkeys = state->shift_keys ^ old_state.shift_keys; for(i = 0; i < sizeof(sdl_shift); ++i) { if((shiftkeys >> i) & 1) { @@ -137,6 +141,28 @@ static void keyboard_update(void) { } old_state = *state; + +#else /* KOS 2.2.0+ */ + shiftkeys = state->modifiers.raw ^ old_mods.raw; + for(i = 0; i < sizeof(sdl_shift)/sizeof(sdl_shift[0]); ++i) { + if((shiftkeys >> i) & 1) { + keysym.sym = sdl_shift[i]; + SDL_PrivateKeyboard(((state->modifiers.raw >> i) & 1) ? + SDL_PRESSED : SDL_RELEASED, &keysym); + } + } + + for(i = 0; i < sizeof(sdl_key)/sizeof(sdl_key[0]); ++i) { + int key = sdl_key[i]; + keysym.sym = key; + + if(state->key_states[i].value == KEY_STATE_CHANGED_DOWN) { + SDL_PrivateKeyboard(SDL_PRESSED, &keysym); + } else if(state->key_states[i].value == KEY_STATE_CHANGED_UP) { + SDL_PrivateKeyboard(SDL_RELEASED, &keysym); + } + } +#endif } void DC_PumpEvents(_THIS) { @@ -145,4 +171,4 @@ void DC_PumpEvents(_THIS) { } void DC_InitOSKeymap(_THIS) { -} +} \ No newline at end of file