added support for non-button touch pads for MM game engine
authorHolger Schemel <info@artsoft.org>
Mon, 2 Apr 2018 10:33:11 +0000 (12:33 +0200)
committerHolger Schemel <info@artsoft.org>
Mon, 2 Apr 2018 10:33:11 +0000 (12:33 +0200)
There are some systems with touch pads (like Mac notebooks) which do not
have separate left/right buttons, which are required for controlling the
Mirror Magic game engine (which usually works best with left/right mouse
buttons).

This change adds support for recognizing touch clicks on the left and
right half of the touch pad as left and right button clicks to rotate
mirrors and other rotatable game elements in the MM game engine to the
left or to the right.

src/events.c
src/game.c
src/libgame/system.h

index 7a3f9987d4b09a80ebdc48c970c8eb118f3b4727..3d1163638a24738f20af985e658300d3e8eedd10 100644 (file)
@@ -403,6 +403,9 @@ void SetPlayerMouseAction(int mx, int my, int button)
   int ly = getLevelFromScreenY(my);
   int new_button = (!local_player->mouse_action.button && button);
 
+  if (local_player->mouse_action.button_hint)
+    button = local_player->mouse_action.button_hint;
+
   ClearPlayerMouseAction();
 
   if (!IN_GFX_FIELD_PLAY(mx, my) || !IN_LEV_FIELD(lx, ly))
@@ -960,7 +963,16 @@ void HandleFingerEvent(FingerEvent *event)
     return;
 
   if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
+  {
+    if (strEqual(setup.touch.control_type, TOUCH_CONTROL_OFF))
+      local_player->mouse_action.button_hint =
+       (event->type == EVENT_FINGERRELEASE ? MB_NOT_PRESSED :
+        event->x < 0.5                     ? MB_LEFTBUTTON  :
+        event->x > 0.5                     ? MB_RIGHTBUTTON :
+        MB_NOT_PRESSED);
+
     return;
+  }
 
   if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS))
     HandleFingerEvent_VirtualButtons(event);
index 6e64d55c532278896e9ada1b2a4b39c4765a30bc..2f57bf51cc7f32a6aee74dc3e04f5c3c5dd10fb3 100644 (file)
@@ -3345,10 +3345,12 @@ void InitGame()
     player->mouse_action.lx = 0;
     player->mouse_action.ly = 0;
     player->mouse_action.button = 0;
+    player->mouse_action.button_hint = 0;
 
     player->effective_mouse_action.lx = 0;
     player->effective_mouse_action.ly = 0;
     player->effective_mouse_action.button = 0;
+    player->effective_mouse_action.button_hint = 0;
 
     player->score = 0;
     player->score_final = 0;
index 578d060ee9402591ec8fdeba37f1a972e97d54dd..7f8d23416dafce3e8407ada7911844ae5787b2fc 100644 (file)
@@ -1451,6 +1451,7 @@ struct MouseActionInfo
 {
   int lx, ly;
   int button;
+  int button_hint;
 };
 
 struct LevelStats