X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=37d7c0d72b05b7ef907324589db997b353d54312;hp=7972d1b53e0ddf37bd1973383675e25b414cd3ae;hb=e5035e129af2e6bc1540c050e48be541f1a7fe5a;hpb=5eb97ccbaffc671f05dd73bf0548c1666414017e diff --git a/src/events.c b/src/events.c index 7972d1b5..37d7c0d7 100644 --- a/src/events.c +++ b/src/events.c @@ -164,7 +164,7 @@ boolean NextValidEvent(Event *event) return FALSE; } -void HandleEvents() +static void HandleEvents(void) { Event event; unsigned int event_frame_delay = 0; @@ -283,7 +283,7 @@ void HandleOtherEvents(Event *event) } } -void HandleMouseCursor() +static void HandleMouseCursor(void) { if (game_status == GAME_MODE_TITLE) { @@ -347,7 +347,26 @@ void EventLoop(void) } } -void ClearEventQueue() +void ClearAutoRepeatKeyEvents(void) +{ +#if defined(TARGET_SDL2) + while (PendingEvent()) + { + Event next_event; + + PeekEvent(&next_event); + + /* if event is repeated key press event, remove it from event queue */ + if (next_event.type == EVENT_KEYPRESS && + next_event.key.repeat) + WaitEvent(&next_event); + else + break; + } +#endif +} + +void ClearEventQueue(void) { Event event; @@ -377,14 +396,14 @@ void ClearEventQueue() } } -void ClearPlayerMouseAction() +static void ClearPlayerMouseAction(void) { local_player->mouse_action.lx = 0; local_player->mouse_action.ly = 0; local_player->mouse_action.button = 0; } -void ClearPlayerAction() +void ClearPlayerAction(void) { int i; @@ -397,7 +416,7 @@ void ClearPlayerAction() ClearPlayerMouseAction(); } -void SetPlayerMouseAction(int mx, int my, int button) +static void SetPlayerMouseAction(int mx, int my, int button) { int lx = getLevelFromScreenX(mx); int ly = getLevelFromScreenY(my); @@ -425,7 +444,7 @@ void SetPlayerMouseAction(int mx, int my, int button) SetTileCursorXY(lx, ly); } -void SleepWhileUnmapped() +void SleepWhileUnmapped(void) { boolean window_unmapped = TRUE; @@ -676,7 +695,7 @@ static struct Key key; } touch_info[NUM_TOUCH_FINGERS]; -void HandleFingerEvent_VirtualButtons(FingerEvent *event) +static void HandleFingerEvent_VirtualButtons(FingerEvent *event) { #if 1 int x = event->x * overlay.grid_xsize; @@ -836,7 +855,7 @@ void HandleFingerEvent_VirtualButtons(FingerEvent *event) } } -void HandleFingerEvent_WipeGestures(FingerEvent *event) +static void HandleFingerEvent_WipeGestures(FingerEvent *event) { static Key motion_key_x = KSYM_UNDEFINED; static Key motion_key_y = KSYM_UNDEFINED; @@ -1370,6 +1389,8 @@ static void HandleButtonOrFinger(int mx, int my, int button) HandleButtonOrFinger_WipeGestures_MM(mx, my, button); else if (strEqual(setup.touch.control_type, TOUCH_CONTROL_FOLLOW_FINGER)) HandleButtonOrFinger_FollowFinger_MM(mx, my, button); + else if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS)) + SetPlayerMouseAction(mx, my, button); /* special case */ } else { @@ -1380,7 +1401,7 @@ static void HandleButtonOrFinger(int mx, int my, int button) #if defined(TARGET_SDL2) -static boolean checkTextInputKeyModState() +static boolean checkTextInputKeyModState(void) { // when playing, only handle raw key events and ignore text input if (game_status == GAME_MODE_PLAYING) @@ -2094,6 +2115,10 @@ void HandleKey(Key key, int key_status) case GAME_MODE_SETUP: case GAME_MODE_INFO: case GAME_MODE_SCORES: + + if (anyTextGadgetActiveOrJustFinished && key != KSYM_Escape) + break; + switch (key) { case KSYM_space: @@ -2196,7 +2221,7 @@ void HandleKey(Key key, int key_status) HandleKeysDebug(key); } -void HandleNoEvent() +void HandleNoEvent(void) { HandleMouseCursor(); @@ -2208,7 +2233,7 @@ void HandleNoEvent() } } -void HandleEventActions() +void HandleEventActions(void) { // if (button_status && game_status != GAME_MODE_PLAYING) if (button_status && (game_status != GAME_MODE_PLAYING || @@ -2222,10 +2247,8 @@ void HandleEventActions() HandleJoystick(); } -#if defined(NETWORK_AVALIABLE) if (network.enabled) HandleNetworking(); -#endif switch (game_status) { @@ -2273,7 +2296,7 @@ static void HandleTileCursor(int dx, int dy, int button) } } -static int HandleJoystickForAllPlayers() +static int HandleJoystickForAllPlayers(void) { int i; int result = 0; @@ -2306,7 +2329,7 @@ static int HandleJoystickForAllPlayers() return result; } -void HandleJoystick() +void HandleJoystick(void) { static unsigned int joytest_delay = 0; static unsigned int joytest_delay_value = GADGET_FRAME_DELAY; @@ -2376,6 +2399,9 @@ void HandleJoystick() case GAME_MODE_INFO: case GAME_MODE_SCORES: { + if (anyTextGadgetActive()) + break; + if (game_status == GAME_MODE_TITLE) HandleTitleScreen(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_MAIN)