rnd-20000806-1-src
[rocksndiamonds.git] / src / system.c
index 71b248e805e6d5c4deea6805460420bf08fb6c79..6b85ccb38c219d7fe790031bdbf817a355c179d6 100644 (file)
 
 #include "main.h"
 
-#ifdef USE_SDL_LIBRARY
-#include "sdl.h"
-#endif
-
 inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
 {
 #ifdef USE_SDL_LIBRARY
@@ -105,32 +101,39 @@ 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
 }
 
-inline boolean QueryPointer(DrawWindow window, int *win_x, int *win_y)
+inline boolean PointerInWindow(DrawWindow window)
 {
 #ifdef USE_SDL_LIBRARY
-  SDL_GetMouseState(win_x, win_y);
   return TRUE;
 #else
   DrawWindow root, child;
   int root_x, root_y;
   unsigned int mask;
+  int win_x, win_y;
 
   /* if XQueryPointer() returns False, the pointer
      is not on the same screen as the specified window */
   return XQueryPointer(display, window, &root, &child, &root_x, &root_y,
-                      win_x, win_y, &mask);
+                      &win_x, &win_y, &mask);
 #endif
 }
 
@@ -152,6 +155,21 @@ inline void NextEvent(Event *event)
 #endif
 }
 
+inline Key GetEventKey(KeyEvent *event, boolean with_modifiers)
+{
+#ifdef USE_SDL_LIBRARY
+  if (with_modifiers && event->keysym.unicode != 0)
+    return event->keysym.unicode;
+  else
+    return event->keysym.sym;
+#else
+  if (with_modifiers)
+    return XLookupKeysym(event, event->state);
+  else
+    return XLookupKeysym(event, 0);
+#endif
+}
+
 inline void dummy()
 {
 #ifdef USE_SDL_LIBRARY