From 6d7f6c64502398d8eee350924730d07c56982e4c Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Thu, 21 Jul 2022 06:42:07 +0200 Subject: [PATCH] params: Add an option to not hide system cursor; toggle cursor with fullscreen --- src/libsuperderpy.c | 2 +- src/libsuperderpy.h | 1 + src/utils.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libsuperderpy.c b/src/libsuperderpy.c index c3fe67c..11118d3 100644 --- a/src/libsuperderpy.c +++ b/src/libsuperderpy.c @@ -358,7 +358,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* al_destroy_bitmap(icon); } - if (game->config.fullscreen || IS_POCKETCHIP) { + if (!game->_priv.params.show_cursor && (game->config.fullscreen || IS_POCKETCHIP)) { al_hide_mouse_cursor(game->display); } al_inhibit_screensaver(true); diff --git a/src/libsuperderpy.h b/src/libsuperderpy.h index ae6994b..2e89422 100644 --- a/src/libsuperderpy.h +++ b/src/libsuperderpy.h @@ -149,6 +149,7 @@ struct Params { bool disable_bg_clear; /*!< If set to true, the gamestate framebuffer won't be cleared to background color before calling Gamestate_Draw. */ bool fixed_size; /*!< If set to true, the game's window will not be resizable. */ bool no_autopause; /*!< If set to true, engine autopause is forced to be disabled. */ + bool show_cursor; /*!< If set to true, system cursor won't be hidden in fullscreen. */ int samples; /*!< How many samples should be used for multisampling; 0 to disable. */ int sample_rate; /*!< Default sample rate of audio output; 0 to use engine default. */ char* window_title; /*!< A title of the game's window. When NULL, al_get_app_name() is used. */ diff --git a/src/utils.c b/src/utils.c index 7cf77da..3004f0b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -759,6 +759,13 @@ SYMBOL_EXPORT bool ToggleFullscreen(struct Game* game) { al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, game->config.fullscreen); SetupViewport(game); PrintConsole(game, "Fullscreen toggled: %s", game->config.fullscreen ? "on" : "off"); + if (!game->_priv.params.show_cursor) { + if (game->config.fullscreen) { + al_hide_mouse_cursor(game->display); + } else { + al_show_mouse_cursor(game->display); + } + } return game->config.fullscreen; }