removed unused code
[rocksndiamonds.git] / src / events.c
index 1e39b67bc57a7489beb9c78376d3a11486e65564..6066335d64e1f2193d93acfcd5da54a8e29081c4 100644 (file)
@@ -103,6 +103,15 @@ static int FilterEvents(const Event *event)
   cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE &&
                             motion->y >= SY && motion->y < SY + SYSIZE);
 
+  // set correct mouse x/y position (for pointer class global animations)
+  // (this is required in rare cases where the mouse x/y position calculated
+  // from raw values (to apply logical screen size scaling corrections) does
+  // not match the final mouse event x/y position -- this may happen because
+  // the SDL renderer's viewport position is internally represented as float,
+  // but only accessible as integer, which may lead to rounding errors)
+  gfx.mouse_x = motion->x;
+  gfx.mouse_y = motion->y;
+
   // do no reset mouse cursor before all pending events have been processed
   if (gfx.cursor_mode == cursor_mode_last &&
       ((game_status == GAME_MODE_TITLE &&
@@ -656,7 +665,6 @@ static struct
 
 static void HandleFingerEvent_VirtualButtons(FingerEvent *event)
 {
-#if 1
   int x = event->x * overlay.grid_xsize;
   int y = event->y * overlay.grid_ysize;
   int grid_button = overlay.grid_button[x][y];
@@ -668,30 +676,6 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event)
             grid_button == CHAR_GRID_BUTTON_SNAP  ? setup.input[0].key.snap :
             grid_button == CHAR_GRID_BUTTON_DROP  ? setup.input[0].key.drop :
             KSYM_UNDEFINED);
-#else
-  float ypos = 1.0 - 1.0 / 3.0 * video.display_width / video.display_height;
-  float event_x = (event->x);
-  float event_y = (event->y - ypos) / (1 - ypos);
-  Key key = (event_x > 0         && event_x < 1.0 / 6.0 &&
-            event_y > 2.0 / 3.0 && event_y < 1 ?
-            setup.input[0].key.snap :
-            event_x > 1.0 / 6.0 && event_x < 1.0 / 3.0 &&
-            event_y > 2.0 / 3.0 && event_y < 1 ?
-            setup.input[0].key.drop :
-            event_x > 7.0 / 9.0 && event_x < 8.0 / 9.0 &&
-            event_y > 0         && event_y < 1.0 / 3.0 ?
-            setup.input[0].key.up :
-            event_x > 6.0 / 9.0 && event_x < 7.0 / 9.0 &&
-            event_y > 1.0 / 3.0 && event_y < 2.0 / 3.0 ?
-            setup.input[0].key.left :
-            event_x > 8.0 / 9.0 && event_x < 1 &&
-            event_y > 1.0 / 3.0 && event_y < 2.0 / 3.0 ?
-            setup.input[0].key.right :
-            event_x > 7.0 / 9.0 && event_x < 8.0 / 9.0 &&
-            event_y > 2.0 / 3.0 && event_y < 1 ?
-            setup.input[0].key.down :
-            KSYM_UNDEFINED);
-#endif
   int key_status = (event->type == EVENT_FINGERRELEASE ? KEY_RELEASED :
                    KEY_PRESSED);
   char *key_status_name = (key_status == KEY_RELEASED ? "KEY_RELEASED" :
@@ -1901,6 +1885,13 @@ static void HandleKeysSpecial(Key key)
       {
        CopyClipboardToBrush();
       }
+      else if (letter == 'z')  // undo or redo last operation
+      {
+       if (GetKeyModState() & KMOD_Shift)
+         RedoLevelEditorOperation();
+       else
+         UndoLevelEditorOperation();
+      }
     }
   }