removed drag-and-drop support if compiled with SDL version older than 2.0.5
[rocksndiamonds.git] / src / events.c
index bc6e2eb083604889ca75802a0ab1c139df8bd418..b3e4c81f599fe00ab070f7353b040a7fa573ff58 100644 (file)
@@ -268,12 +268,14 @@ void HandleOtherEvents(Event *event)
       HandleJoystickEvent(event);
       break;
 
+#if defined(USE_DRAG_AND_DROP)
     case SDL_DROPBEGIN:
     case SDL_DROPCOMPLETE:
     case SDL_DROPFILE:
     case SDL_DROPTEXT:
       HandleDropEvent(event);
       break;
+#endif
 
     default:
       break;
@@ -1525,6 +1527,7 @@ void HandleClientMessageEvent(ClientMessageEvent *event)
     CloseAllAndExit(0);
 }
 
+#if defined(USE_DRAG_AND_DROP)
 static boolean HandleDropFileEvent(char *filename)
 {
   Error(ERR_DEBUG, "DROP FILE EVENT: '%s'", filename);
@@ -1643,6 +1646,7 @@ void HandleDropEvent(Event *event)
   if (event->drop.file != NULL)
     SDL_free(event->drop.file);
 }
+#endif
 
 void HandleButton(int mx, int my, int button, int button_nr)
 {
@@ -2015,6 +2019,7 @@ void HandleKey(Key key, int key_status)
     for (pnr = 0; pnr < MAX_PLAYERS; pnr++)
     {
       byte key_action = 0;
+      byte key_snap_action = 0;
 
       if (setup.input[pnr].use_joystick)
        continue;
@@ -2030,15 +2035,33 @@ void HandleKey(Key key, int key_status)
       {
        ssi = setup.shortcut;
 
+       // also remember normal snap key when handling snap+direction keys
+       key_snap_action |= key_action & JOY_BUTTON_SNAP;
+
        for (i = 0; i < NUM_DIRECTIONS; i++)
+       {
          if (key == *key_info[i].key_snap)
-           key_action |= key_info[i].action | JOY_BUTTON_SNAP;
+         {
+           key_action      |= key_info[i].action | JOY_BUTTON_SNAP;
+           key_snap_action |= key_info[i].action;
+         }
+       }
       }
 
       if (key_status == KEY_PRESSED)
-       stored_player[pnr].action |= key_action;
+      {
+       stored_player[pnr].action      |= key_action;
+       stored_player[pnr].snap_action |= key_snap_action;
+      }
       else
-       stored_player[pnr].action &= ~key_action;
+      {
+       stored_player[pnr].action      &= ~key_action;
+       stored_player[pnr].snap_action &= ~key_snap_action;
+      }
+
+      // restore snap action if one of several pressed snap keys was released
+      if (stored_player[pnr].snap_action)
+       stored_player[pnr].action |= JOY_BUTTON_SNAP;
 
       if (tape.single_step && tape.recording && tape.pausing && !tape.use_mouse)
       {