diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/game.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/game.c b/examples/game.c index 065ff99..4517519 100644 --- a/examples/game.c +++ b/examples/game.c @@ -186,10 +186,11 @@ static enum yasl_app_result on_event(void *ud, const struct yasl_event *ev) case YASL_KEY_E: game->key_e = down; break; case YASL_KEY_SPACE: if (ev->key.action == YASL_KEY_PRESS) { - /* Toggle relative pointer mode */ - game->relative_mouse = !game->relative_mouse; - yasl_surface_set_pointer_mode(game->surface, - game->relative_mouse ? YASL_POINTER_RELATIVE : YASL_POINTER_NORMAL); + /* Toggle relative pointer mode; unsupported backends stay normal. */ + game->relative_mouse = !game->relative_mouse && + yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_RELATIVE); + if (!game->relative_mouse) + yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_NORMAL); } break; case YASL_KEY_ESCAPE: @@ -221,8 +222,8 @@ static enum yasl_app_result on_event(void *ud, const struct yasl_event *ev) case YASL_EVENT_POINTER_DOWN: if (!game->relative_mouse) { /* Click window to capture cursor */ - game->relative_mouse = true; - yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_RELATIVE); + game->relative_mouse = + yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_RELATIVE); } break; |
