@@ -49,7 +49,7 @@ static const char* settings_key = "Emu.x65";
4949extern ui_settings_t * settings_load (const char * imgui_ini_key );
5050int window_width = 0 ;
5151int window_height = 0 ;
52- static bool disable_gui = false;
52+ bool disable_gui = false;
5353
5454typedef struct {
5555 uint32_t version ;
@@ -124,6 +124,21 @@ static gfx_border_t gui_border(bool no_gui) {
124124 };
125125}
126126
127+ #ifdef CHIPS_USE_UI
128+ // gfx draw_extra dispatch: gated on disable_gui at call time so the menu can
129+ // toggle UI visibility at runtime (init-time gating would lock the choice in)
130+ static void ui_draw_extra (const gfx_draw_info_t * draw_info ) {
131+ if (!disable_gui ) {
132+ ui_draw (draw_info );
133+ }
134+ }
135+
136+ void app_set_disable_gui (bool hidden ) {
137+ disable_gui = hidden ;
138+ gfx_set_border (gui_border (hidden ));
139+ }
140+ #endif
141+
127142// audio-streaming callback
128143static void push_audio (const float * samples , int num_samples , void * user_data ) {
129144 (void )user_data ;
@@ -239,7 +254,7 @@ void app_init(void) {
239254 .disable_speaker_icon = sargs_exists ("disable-speaker-icon" ),
240255#ifdef CHIPS_USE_UI
241256 .init_extra_cb = ui_preinit ,
242- .draw_extra_cb = disable_gui ? NULL : ui_draw ,
257+ .draw_extra_cb = ui_draw_extra ,
243258#endif
244259 .border = gui_border (disable_gui ),
245260 .display_info = x65_display_info (& state .x65 ),
@@ -422,6 +437,19 @@ void app_input(const sapp_event* event) {
422437 }
423438#endif
424439#ifdef CHIPS_USE_UI
440+ // Hide/show debug UI hotkey. Multi-modifier so it can't collide with X65
441+ // input, intercepted (and swallowed) before HID forwarding.
442+ if (event -> type == SAPP_EVENTTYPE_KEY_DOWN || event -> type == SAPP_EVENTTYPE_KEY_UP ) {
443+ const uint32_t hide_ui_mods = SAPP_MODIFIER_CTRL | SAPP_MODIFIER_SHIFT ;
444+ const bool is_hide_ui = event -> key_code == SAPP_KEYCODE_H
445+ && ((event -> modifiers & hide_ui_mods ) == hide_ui_mods );
446+ if (is_hide_ui ) {
447+ if (event -> type == SAPP_EVENTTYPE_KEY_DOWN ) {
448+ app_set_disable_gui (!disable_gui );
449+ }
450+ return ;
451+ }
452+ }
425453 if (!disable_gui && ui_input (event )) {
426454 // input was handled by UI
427455 return ;
0 commit comments