removed some remaining unused X11 stuff
[rocksndiamonds.git] / src / events.c
index 14e7df862d68b129d81effc376322c081cf9aad4..f89e5236071b7d30c8e66499a539808a868f5d53 100644 (file)
 
 #define        DEBUG_EVENTS            0
 
+#define DEBUG_EVENTS_BUTTON    (DEBUG_EVENTS   * 0)
+#define DEBUG_EVENTS_MOTION    (DEBUG_EVENTS   * 0)
+#define DEBUG_EVENTS_WINDOW    (DEBUG_EVENTS   * 0)
+#define DEBUG_EVENTS_FINGER    (DEBUG_EVENTS   * 0)
+#define DEBUG_EVENTS_TEXT      (DEBUG_EVENTS   * 1)
+#define DEBUG_EVENTS_KEY       (DEBUG_EVENTS   * 1)
+
 
 static boolean cursor_inside_playfield = FALSE;
 static boolean playfield_cursor_set = FALSE;
@@ -224,8 +231,6 @@ void EventLoop(void)
     }
     else
     {
-      SyncDisplay();
-
       if (!PendingEvent())     /* delay only if no pending events */
        Delay(10);
     }
@@ -364,7 +369,7 @@ void HandleExposeEvent(ExposeEvent *event)
 
 void HandleButtonEvent(ButtonEvent *event)
 {
-#if DEBUG_EVENTS
+#if DEBUG_EVENTS_BUTTON
   Error(ERR_DEBUG, "BUTTON EVENT: button %d %s, x/y %d/%d\n",
        event->button,
        event->type == EVENT_BUTTONPRESS ? "pressed" : "released",
@@ -391,7 +396,7 @@ void HandleMotionEvent(MotionEvent *event)
 
   motion_status = TRUE;
 
-#if DEBUG_EVENTS
+#if DEBUG_EVENTS_MOTION
   Error(ERR_DEBUG, "MOTION EVENT: button %d moved, x/y %d/%d\n",
        button_status, event->x, event->y);
 #endif
@@ -403,7 +408,7 @@ void HandleMotionEvent(MotionEvent *event)
 
 void HandleWindowEvent(WindowEvent *event)
 {
-#if DEBUG_EVENTS
+#if DEBUG_EVENTS_WINDOW
   int subtype = event->event;
 
   char *event_name =
@@ -485,7 +490,7 @@ void HandleFingerEvent(FingerEvent *event)
   float event_x = event->x;
   float event_y = event->y;
 
-#if DEBUG_EVENTS
+#if DEBUG_EVENTS_FINGER
   Error(ERR_DEBUG, "FINGER EVENT: finger was %s, touch ID %lld, finger ID %lld, x/y %f/%f, dx/dy %f/%f, pressure %f",
        event->type == EVENT_FINGERPRESS ? "pressed" :
        event->type == EVENT_FINGERRELEASE ? "released" : "moved",
@@ -775,7 +780,7 @@ void HandleTextEvent(TextEvent *event)
   char *text = event->text;
   Key key = getKeyFromKeyName(text);
 
-#if DEBUG_EVENTS
+#if DEBUG_EVENTS_TEXT
   Error(ERR_DEBUG, "TEXT EVENT: text == '%s' [%d byte(s), '%c'/%d], resulting key == %d (%s) [%04x]",
        text,
        strlen(text),
@@ -785,11 +790,16 @@ void HandleTextEvent(TextEvent *event)
        GetKeyModState());
 #endif
 
-  // if (game_status != GAME_MODE_PLAYING && GetKeyModState() != KMOD_None)
-  /*
-  if (game_status != GAME_MODE_PLAYING &&
-      (GetKeyModState() & KMOD_TextInput) != KMOD_None)
-  */
+#if defined(PLATFORM_ANDROID)
+  if (game_status == GAME_MODE_PSEUDO_TYPENAME)
+  {
+    HandleTypeName(0, key);
+
+    return;
+  }
+#endif
+
+  // only handle key input with text modifier keys pressed
   if (checkTextInputKeyModState())
   {
     HandleKey(key, KEY_PRESSED);
@@ -818,7 +828,7 @@ void HandleKeyEvent(KeyEvent *event)
   Key key = GetEventKey(event, with_modifiers);
   Key keymod = (with_modifiers ? GetEventKey(event, FALSE) : key);
 
-#if DEBUG_EVENTS
+#if DEBUG_EVENTS_KEY
   Error(ERR_DEBUG, "KEY EVENT: key was %s, keysym.scancode == %d, keysym.sym == %d, keymod = %d, GetKeyModState() = 0x%04x, resulting key == %d (%s)",
        event->type == EVENT_KEYPRESS ? "pressed" : "released",
        event->keysym.scancode,
@@ -838,6 +848,7 @@ void HandleKeyEvent(KeyEvent *event)
   HandleKeyModState(keymod, key_status);
 
 #if defined(TARGET_SDL2)
+  // only handle raw key input without text modifier keys pressed
   if (!checkTextInputKeyModState())
     HandleKey(key, key_status);
 #else
@@ -1020,7 +1031,7 @@ static void HandleKeysSpecial(Key key)
   cheat_input[cheat_input_len++] = letter;
   cheat_input[cheat_input_len] = '\0';
 
-#if DEBUG_EVENTS
+#if DEBUG_EVENTS_KEY
   Error(ERR_DEBUG, "SPECIAL KEY '%s' [%d]\n", cheat_input, cheat_input_len);
 #endif