X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=036f8a0772191fc69f61b36f5abc6cedcd01db8d;hp=22cfdcd12ebadba2d7084591f3d6ec9bac91ab12;hb=115ce6f2da1914d68b0fe0e5f9082973190dacdd;hpb=d0a7080670f9a2fa96138cf1c06708016a42d615 diff --git a/src/events.c b/src/events.c index 22cfdcd1..036f8a07 100644 --- a/src/events.c +++ b/src/events.c @@ -164,7 +164,7 @@ boolean NextValidEvent(Event *event) return FALSE; } -void HandleEvents() +void HandleEvents(void) { Event event; unsigned int event_frame_delay = 0; @@ -283,7 +283,7 @@ void HandleOtherEvents(Event *event) } } -void HandleMouseCursor() +void HandleMouseCursor(void) { if (game_status == GAME_MODE_TITLE) { @@ -347,7 +347,24 @@ void EventLoop(void) } } -void ClearEventQueue() +void ClearAutoRepeatKeyEvents(void) +{ + 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; + } +} + +void ClearEventQueue(void) { Event event; @@ -377,14 +394,14 @@ void ClearEventQueue() } } -void ClearPlayerMouseAction() +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; @@ -425,7 +442,7 @@ void SetPlayerMouseAction(int mx, int my, int button) SetTileCursorXY(lx, ly); } -void SleepWhileUnmapped() +void SleepWhileUnmapped(void) { boolean window_unmapped = TRUE; @@ -1370,6 +1387,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 +1399,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) @@ -1554,16 +1573,16 @@ void HandleButton(int mx, int my, int button, int button_nr) strEqual(setup.touch.control_type, TOUCH_CONTROL_FOLLOW_FINGER)); #endif - if (handle_gadgets && HandleGadgets(mx, my, button)) + if (HandleGlobalAnimClicks(mx, my, button)) { /* do not handle this button event anymore */ - mx = my = -32; /* force mouse event to be outside screen tiles */ + return; /* force mouse event not to be handled at all */ } - if (HandleGlobalAnimClicks(mx, my, button)) + if (handle_gadgets && HandleGadgets(mx, my, button)) { /* do not handle this button event anymore */ - return; /* force mouse event not to be handled at all */ + mx = my = -32; /* force mouse event to be outside screen tiles */ } if (button_hold && game_status == GAME_MODE_PLAYING && tape.pausing) @@ -1762,11 +1781,12 @@ static void HandleKeysSpecial(Key key) } /* special key shortcuts for all game modes */ - if (is_string_suffix(cheat_input, ":dump-gadget-ids") || - is_string_suffix(cheat_input, ":dgi") || - is_string_suffix(cheat_input, ":DGI")) + if (is_string_suffix(cheat_input, ":dump-event-actions") || + is_string_suffix(cheat_input, ":dea") || + is_string_suffix(cheat_input, ":DEA")) { DumpGadgetIdentifiers(); + DumpScreenIdentifiers(); } } @@ -2030,7 +2050,7 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_MAIN && (key == setup.shortcut.toggle_pause || key == KSYM_space)) { - StartGameActions(options.network, setup.autorecord, level.random_seed); + StartGameActions(network.enabled, setup.autorecord, level.random_seed); return; } @@ -2195,7 +2215,7 @@ void HandleKey(Key key, int key_status) HandleKeysDebug(key); } -void HandleNoEvent() +void HandleNoEvent(void) { HandleMouseCursor(); @@ -2207,7 +2227,7 @@ void HandleNoEvent() } } -void HandleEventActions() +void HandleEventActions(void) { // if (button_status && game_status != GAME_MODE_PLAYING) if (button_status && (game_status != GAME_MODE_PLAYING || @@ -2221,10 +2241,8 @@ void HandleEventActions() HandleJoystick(); } -#if defined(NETWORK_AVALIABLE) - if (options.network) + if (network.enabled) HandleNetworking(); -#endif switch (game_status) { @@ -2272,7 +2290,7 @@ static void HandleTileCursor(int dx, int dy, int button) } } -static int HandleJoystickForAllPlayers() +static int HandleJoystickForAllPlayers(void) { int i; int result = 0; @@ -2305,7 +2323,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; @@ -2495,3 +2513,18 @@ void HandleSpecialGameControllerKeys(Key key, int key_status) #endif #endif } + +boolean DoKeysymAction(int keysym) +{ + if (keysym < 0) + { + Key key = (Key)(-keysym); + + HandleKey(key, KEY_PRESSED); + HandleKey(key, KEY_RELEASED); + + return TRUE; + } + + return FALSE; +}