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.
This commit is contained in:
Franklin Wei
2020-07-06 22:06:30 -04:00
committed by Simon Tatham
parent 9aa7b7cdfb
commit 78bc9ea7f7
47 changed files with 740 additions and 0 deletions

View File

@ -347,6 +347,8 @@ const char *identify_game(char **name,
bool (*read)(void *ctx, void *buf, int len),
void *rctx);
void midend_request_id_changes(midend *me, void (*notify)(void *), void *ctx);
bool midend_get_cursor_location(midend *me, int *x, int *y, int *w, int *h);
/* Printing functions supplied by the mid-end */
const char *midend_print_puzzle(midend *me, document *doc, bool with_soln);
int midend_tilesize(midend *me);
@ -680,6 +682,11 @@ struct game {
const game_state *newstate, int dir, game_ui *ui);
float (*flash_length)(const game_state *oldstate,
const game_state *newstate, int dir, game_ui *ui);
void (*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);
int (*status)(const game_state *state);
bool can_print, can_print_in_colour;
void (*print_size)(const game_params *params, float *x, float *y);