X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=69efaf508189e9631cb3b7f3b08f608f364922f5;hp=b5f83725334d41688b92f9531853d3a78a1be113;hb=bbbd254d0e097f479e20a06ddf97eb84782c2e82;hpb=4cd59cef0737229da365e385a8762e681a5e471f diff --git a/src/events.c b/src/events.c index b5f83725..69efaf50 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); @@ -442,6 +443,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(); } @@ -698,6 +703,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 +830,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 +842,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); } } } @@ -1386,6 +1401,10 @@ static boolean checkTextInputKey(Key key) if (game_status == GAME_MODE_PLAYING) return FALSE; + // if Shift or right Alt key is pressed, handle key as text input + if ((GetKeyModState() & KMOD_TextInput) != KMOD_None) + return TRUE; + // ignore raw keys as text input when not in text input mode if (KSYM_RAW(key) && !textinput_status) return FALSE; @@ -1808,7 +1827,7 @@ static void HandleKeysSpecial(Key key) cheat_input[cheat_input_len] = '\0'; #if DEBUG_EVENTS_KEY - Debug("event:key:special", "'%s' [%d]\n", cheat_input, cheat_input_len); + Debug("event:key:special", "'%s' [%d]", cheat_input, cheat_input_len); #endif if (game_status == GAME_MODE_MAIN)