rnd-20000721-1-src
[rocksndiamonds.git] / src / system.c
index 71b248e805e6d5c4deea6805460420bf08fb6c79..5fbf9efec2a83b7bc555823d81994a4e23e84340 100644 (file)
@@ -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