From 78bc9ea7f79f379634f822d5f95242900f5716b9 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Mon, 6 Jul 2020 22:06:30 -0400 Subject: Add method for frontends to query the backend's cursor location. The Rockbox frontend allows games to be displayed in a "zoomed-in" state targets with small displays. Currently we use a modal interface -- a "viewing" mode in which the cursor keys are used to pan around the rendered bitmap; and an "interaction" mode that actually sends keys to the game. This commit adds a midend_get_cursor_location() function to allow the frontend to retrieve the backend's cursor location or other "region of interest" -- such as the player location in Cube or Inertia. With this information, the Rockbox frontend can now intelligently follow the cursor around in the zoomed-in state, eliminating the need for a modal interface. --- net.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'net.c') diff --git a/net.c b/net.c index 1a0c6cd..5796e95 100644 --- a/net.c +++ b/net.c @@ -3087,6 +3087,20 @@ static float game_flash_length(const game_state *oldstate, return 0.0F; } +static void game_get_cursor_location(const game_ui *ui, + const game_drawstate *ds, + const game_state *state, + const game_params *params, + int *x, int *y, int *w, int *h) +{ + if(ui->cur_visible) { + *x = WINDOW_OFFSET + TILE_SIZE * ui->cur_x; + *y = WINDOW_OFFSET + TILE_SIZE * ui->cur_y; + + *w = *h = TILE_SIZE; + } +} + static int game_status(const game_state *state) { return state->completed ? +1 : 0; @@ -3268,6 +3282,7 @@ const struct game thegame = { game_redraw, game_anim_length, game_flash_length, + game_get_cursor_location, game_status, true, false, game_print_size, game_print, true, /* wants_statusbar */ -- cgit v1.1