X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=9aad2bca87dfa837891244e5099d004c97a7d629;hp=4755d51ff57dc975ba1a27f91d45f02f7847fe2f;hb=6dd55346a5d7a35592294313893c14e0641e15ae;hpb=9c4b703ca8d2d27df28d74f40e5f2c7515b1ca51 diff --git a/src/events.c b/src/events.c index 4755d51f..9aad2bca 100644 --- a/src/events.c +++ b/src/events.c @@ -304,7 +304,8 @@ void HandleMouseCursor() cursor_inside_playfield && DelayReached(&special_cursor_delay, special_cursor_delay_value)) { - if (level.game_engine_type != GAME_ENGINE_TYPE_MM) + if (level.game_engine_type != GAME_ENGINE_TYPE_MM || + tile_cursor.enabled) SetMouseCursor(CURSOR_PLAYFIELD); } } @@ -400,6 +401,10 @@ void SetPlayerMouseAction(int mx, int my, int button) { int lx = getLevelFromScreenX(mx); 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(); @@ -412,10 +417,12 @@ void SetPlayerMouseAction(int mx, int my, int button) if (tape.recording && tape.pausing && tape.use_mouse) { - /* prevent button release or motion events from un-pausing a paused game */ - if (button && !motion_status) - TapeTogglePause(TAPE_TOGGLE_MANUAL); + /* un-pause a paused game only if mouse button was newly pressed down */ + if (new_button) + TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); } + + SetTileCursorXY(lx, ly); } void SleepWhileUnmapped() @@ -629,10 +636,30 @@ void HandleWindowEvent(WindowEvent *event) if (new_display_width != video.display_width || new_display_height != video.display_height) { + int nr = GRID_ACTIVE_NR(); // previous screen orientation + video.display_width = new_display_width; video.display_height = new_display_height; SDLSetScreenProperties(); + + // 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]; + } } } #endif @@ -651,6 +678,18 @@ static struct void HandleFingerEvent_VirtualButtons(FingerEvent *event) { +#if 1 + int x = event->x * overlay.grid_xsize; + int y = event->y * overlay.grid_ysize; + int grid_button = overlay.grid_button[x][y]; + Key key = (grid_button == CHAR_GRID_BUTTON_LEFT ? setup.input[0].key.left : + grid_button == CHAR_GRID_BUTTON_RIGHT ? setup.input[0].key.right : + grid_button == CHAR_GRID_BUTTON_UP ? setup.input[0].key.up : + grid_button == CHAR_GRID_BUTTON_DOWN ? setup.input[0].key.down : + grid_button == CHAR_GRID_BUTTON_SNAP ? setup.input[0].key.snap : + grid_button == CHAR_GRID_BUTTON_DROP ? setup.input[0].key.drop : + KSYM_UNDEFINED); +#else float ypos = 1.0 - 1.0 / 3.0 * video.display_width / video.display_height; float event_x = (event->x); float event_y = (event->y - ypos) / (1 - ypos); @@ -673,6 +712,7 @@ void HandleFingerEvent_VirtualButtons(FingerEvent *event) event_y > 2.0 / 3.0 && event_y < 1 ? setup.input[0].key.down : KSYM_UNDEFINED); +#endif int key_status = (event->type == EVENT_FINGERRELEASE ? KEY_RELEASED : KEY_PRESSED); char *key_status_name = (key_status == KEY_RELEASED ? "KEY_RELEASED" : @@ -956,7 +996,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); @@ -2339,7 +2388,12 @@ void HandleJoystick() return; } - if (tape.recording && tape.pausing && !tape.use_mouse) + if (tape.single_step && tape.recording && tape.pausing && !tape.use_mouse) + { + if (joystick & JOY_ACTION) + TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); + } + else if (tape.recording && tape.pausing && !tape.use_mouse) { if (joystick & JOY_ACTION) TapeTogglePause(TAPE_TOGGLE_MANUAL);