X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=e3632df02a71a2c3081f1fb634d0b128d6c7e1dc;hb=0ede483d20ce26c84087e9fe476debe277f4973a;hp=f4311bfdee435c6701cc11f3feb8d2342d501cd6;hpb=fc2258f533dd7578e76f89a0fe1ad093022284dd;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index f4311bfd..e3632df0 100644 --- a/src/events.c +++ b/src/events.c @@ -43,6 +43,7 @@ static boolean stop_processing_events = FALSE; // forward declarations for internal use +static void ClearTouchInfo(void); static void HandleNoEvent(void); static void HandleEventActions(void); @@ -407,6 +408,7 @@ void ClearEventQueue(void) button_status = MB_RELEASED; break; + case EVENT_FINGERRELEASE: case EVENT_KEYRELEASE: ClearPlayerAction(); break; @@ -442,6 +444,10 @@ void ClearPlayerAction(void) stored_player[i].snap_action = 0; } + // simulate finger release events for still pressed virtual buttons + overlay.grid_button_action = JOY_NO_ACTION; + + ClearTouchInfo(); ClearJoystickState(); ClearPlayerMouseAction(); } @@ -667,19 +673,10 @@ void HandleWindowEvent(WindowEvent *event) // check if screen orientation has changed (should always be true here) if (nr != GRID_ACTIVE_NR()) { - int x, y; - if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterScreenRotation(nr); - nr = GRID_ACTIVE_NR(); - - overlay.grid_xsize = setup.touch.grid_xsize[nr]; - overlay.grid_ysize = setup.touch.grid_ysize[nr]; - - for (x = 0; x < MAX_GRID_XSIZE; x++) - for (y = 0; y < MAX_GRID_YSIZE; y++) - overlay.grid_button[x][y] = setup.touch.grid_button[nr][x][y]; + SetOverlayGridSizeAndButtons(); } } } @@ -698,6 +695,24 @@ static struct byte action; } touch_info[NUM_TOUCH_FINGERS]; +static void SetTouchInfo(int pos, SDL_FingerID finger_id, int counter, + Key key, byte action) +{ + touch_info[pos].touched = (action != JOY_NO_ACTION); + touch_info[pos].finger_id = finger_id; + touch_info[pos].counter = counter; + touch_info[pos].key = key; + touch_info[pos].action = action; +} + +static void ClearTouchInfo(void) +{ + int i; + + for (i = 0; i < NUM_TOUCH_FINGERS; i++) + SetTouchInfo(i, 0, 0, 0, JOY_NO_ACTION); +} + static void HandleFingerEvent_VirtualButtons(FingerEvent *event) { int x = event->x * overlay.grid_xsize; @@ -807,11 +822,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) } } - touch_info[i].touched = TRUE; - touch_info[i].finger_id = event->fingerId; - touch_info[i].counter = Counter(); - touch_info[i].key = key; - touch_info[i].action = grid_button_action; + SetTouchInfo(i, event->fingerId, Counter(), key, grid_button_action); } else { @@ -823,11 +834,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) getKeyNameFromKey(touch_info[i].key), "KEY_RELEASED", i); } - touch_info[i].touched = FALSE; - touch_info[i].finger_id = 0; - touch_info[i].counter = 0; - touch_info[i].key = 0; - touch_info[i].action = JOY_NO_ACTION; + SetTouchInfo(i, 0, 0, 0, JOY_NO_ACTION); } } }