diff options
| author | Franklin Wei <franklin@rockbox.org> | 2020-07-06 22:06:30 -0400 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2020-12-07 19:40:06 +0000 |
| commit | 78bc9ea7f79f379634f822d5f95242900f5716b9 (patch) | |
| tree | 20dd3aa4e3ea4025fb72953c9d9950792ada7023 /galaxies.c | |
| parent | 9aa7b7cdfb2bcd200f45941a58d6ae698882a2d4 (diff) | |
| download | puzzles-78bc9ea7f79f379634f822d5f95242900f5716b9.zip puzzles-78bc9ea7f79f379634f822d5f95242900f5716b9.tar.gz puzzles-78bc9ea7f79f379634f822d5f95242900f5716b9.tar.bz2 puzzles-78bc9ea7f79f379634f822d5f95242900f5716b9.tar.xz | |
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.
Diffstat (limited to 'galaxies.c')
| -rw-r--r-- | galaxies.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -3469,6 +3469,37 @@ 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) { + space *sp = &SPACE(state, ui->cur_x, ui->cur_y); + + if(sp->flags & F_DOT) { + *x = SCOORD(ui->cur_x) - DOT_SIZE; + *y = SCOORD(ui->cur_y) - DOT_SIZE; + *w = *h = 2 * DOT_SIZE + 1; + } else if(sp->type != s_tile) { + int dx = (ui->cur_x % 2) ? CURSOR_SIZE : CURSOR_SIZE/3; + int dy = (ui->cur_y % 2) ? CURSOR_SIZE : CURSOR_SIZE/3; + int x1 = SCOORD(ui->cur_x)-dx, y1 = SCOORD(ui->cur_y)-dy; + int xs = dx*2+1, ys = dy*2+1; + + *x = x1; + *y = y1; + *w = xs; + *h = ys; + } else { + *x = SCOORD(ui->cur_x) - CURSOR_SIZE; + *y = SCOORD(ui->cur_y) - CURSOR_SIZE; + *w = *h = 2 * CURSOR_SIZE + 1; + } + } +} + static int game_status(const game_state *state) { return state->completed ? +1 : 0; @@ -3695,6 +3726,7 @@ const struct game thegame = { game_redraw, game_anim_length, game_flash_length, + game_get_cursor_location, game_status, #ifdef EDITOR false, false, NULL, NULL, |