X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fsystem.c;h=5fbf9efec2a83b7bc555823d81994a4e23e84340;hp=71b248e805e6d5c4deea6805460420bf08fb6c79;hb=b9c7e4a42762c8526702726f1404d3e75dbc29f5;hpb=36357e8399d0a42ac45a1cd096aee24a9008b5f5 diff --git a/src/system.c b/src/system.c index 71b248e8..5fbf9efe 100644 --- a/src/system.c +++ b/src/system.c @@ -105,14 +105,21 @@ inline void SyncDisplay() inline void KeyboardAutoRepeatOn() { -#ifndef USE_SDL_LIBRARY +#ifdef USE_SDL_LIBRARY + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2, + SDL_DEFAULT_REPEAT_INTERVAL / 2); + SDL_EnableUNICODE(1); +#else XAutoRepeatOn(display); #endif } inline void KeyboardAutoRepeatOff() { -#ifndef USE_SDL_LIBRARY +#ifdef USE_SDL_LIBRARY + SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); + SDL_EnableUNICODE(0); +#else XAutoRepeatOff(display); #endif } @@ -152,6 +159,30 @@ inline void NextEvent(Event *event) #endif } +inline Key GetEventKey(KeyEvent *event, boolean with_modifiers) +{ +#ifdef USE_SDL_LIBRARY +#if 0 + printf("0x%x, 0x%x\n", + event->keysym.sym, event->keysym.unicode); +#endif + if (with_modifiers && event->keysym.unicode != 0) + return event->keysym.unicode; + else + return event->keysym.sym; +#else +#if 0 + printf("0x%x, 0x%x\n", + (unsigned int)XLookupKeysym(event, 0), + (unsigned int)XLookupKeysym(event, event->state)); +#endif + if (with_modifiers) + return XLookupKeysym(event, event->state); + else + return XLookupKeysym(event, 0); +#endif +} + inline void dummy() { #ifdef USE_SDL_LIBRARY