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. --- midend.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'midend.c') diff --git a/midend.c b/midend.c index b3032e7..15636d4 100644 --- a/midend.c +++ b/midend.c @@ -1464,6 +1464,35 @@ void midend_request_id_changes(midend *me, void (*notify)(void *), void *ctx) me->game_id_change_notify_ctx = ctx; } +bool midend_get_cursor_location(midend *me, + int *x_out, int *y_out, + int *w_out, int *h_out) +{ + int x, y, w, h; + x = y = -1; + w = h = 1; + + if(me->ourgame->get_cursor_location) + me->ourgame->get_cursor_location(me->ui, + me->drawstate, + me->states[me->statepos-1].state, + me->params, + &x, &y, &w, &h); + + if(x == -1 && y == -1) + return false; + + if(x_out) + *x_out = x; + if(y_out) + *y_out = y; + if(w_out) + *w_out = w; + if(h_out) + *h_out = h; + return true; +} + void midend_supersede_game_desc(midend *me, const char *desc, const char *privdesc) { -- cgit v1.1