From: Holger Schemel Date: Mon, 2 Apr 2018 10:33:11 +0000 (+0200) Subject: added support for non-button touch pads for MM game engine X-Git-Tag: 4.1.0.0~4 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fd045bdb92ad7e3523ba850c13a7ef6533d0e726;p=rocksndiamonds.git added support for non-button touch pads for MM game engine 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. --- diff --git a/src/events.c b/src/events.c index 7a3f9987..3d116363 100644 --- a/src/events.c +++ b/src/events.c @@ -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); diff --git a/src/game.c b/src/game.c index 6e64d55c..2f57bf51 100644 --- a/src/game.c +++ b/src/game.c @@ -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; diff --git a/src/libgame/system.h b/src/libgame/system.h index 578d060e..7f8d2341 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1451,6 +1451,7 @@ struct MouseActionInfo { int lx, ly; int button; + int button_hint; }; struct LevelStats