@@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
3939#define DEBUGMATRIX (...)
4040
4141
42- int in_the_matrix = 0 ;
42+ bool in_the_matrix = false ;
4343
4444
4545// TODO: many inventions here eventlually should be moved into some common place as
@@ -89,7 +89,6 @@ static int chrscreen_xsize, chrscreen_ysize;
8989static Uint8 * vmem = NULL , * vmem_prev = NULL , * vmem_backup = NULL ;
9090static int current_x = 0 , current_y = 0 ;
9191static int need_update = 0 ;
92- static int init_done = 0 ;
9392static Uint8 queued_input ;
9493static unsigned int matrix_counter = 0 ;
9594static int live_update_enabled = 1 ;
@@ -297,7 +296,7 @@ static void dump_map ( void )
297296
298297static void cmd_off ( char * p )
299298{
300- matrix_mode_toggle (0 );
299+ matrix_mode_toggle (false );
301300}
302301
303302
@@ -785,7 +784,7 @@ static int kbd_cb_keyevent ( SDL_KeyboardEvent *ev )
785784 // Monitor ctrl-tab, as the main handler is defunct at this point, we "hijacked" it!
786785 // So we must give up the matrix mode themselves here
787786 if (sym == SDLK_TAB && (ev -> keysym .mod & (KMOD_LCTRL | KMOD_RCTRL )))
788- matrix_mode_toggle (0 );
787+ matrix_mode_toggle (false );
789788 else
790789 queued_input = sym ;
791790 }
@@ -803,22 +802,22 @@ static int kbd_cb_textevent ( SDL_TextInputEvent *ev )
803802}
804803
805804
806- void matrix_mode_toggle ( int status )
805+ void matrix_mode_toggle ( const bool status )
807806{
808807 if (!is_osd_enabled ()) {
809808 ERROR_WINDOW ("OSD is not enabled to be able to use Matrix mode." );
810809 return ;
811810 }
812- status = !!status ;
813- if (status == !!in_the_matrix )
811+ if (status == in_the_matrix )
814812 return ;
815813 in_the_matrix = status ;
816814 static int saved_allow_mouse_grab ;
817815 if (in_the_matrix ) {
816+ static bool init_done = false;
818817 D6XX_registers [0x72 ] |= 0x40 ; // be sure we're sync with the matrix bit!
819818 osd_hijack (matrix_updater_callback , & backend_xsize , & backend_ysize , & backend_pixels );
820819 if (!init_done ) {
821- init_done = 1 ;
820+ init_done = true ;
822821 init_colour_mappings ();
823822 chrscreen_xsize = backend_xsize / 8 ;
824823 chrscreen_ysize = backend_ysize / 8 ;
@@ -869,5 +868,10 @@ void matrix_mode_toggle ( int status )
869868 hid_register_sdl_textinput_event_callback (HID_CB_LEVEL_CONSOLE , NULL );
870869 allow_mouse_grab = saved_allow_mouse_grab ;
871870 }
872- clear_emu_events (); // cure problems, that triggering/switching-on/off matrix screen cause that ALT key remains latched etc ...
871+ // Original intent: cure problems, that triggering/switching-on/off matrix screen cause that ALT key remains latched etc ...
872+ // However it breaks the "rapid CTRL-TAB cycling" between matrix/normal mode (without releasing CTRL).
873+ // Now it seems, removing this call does not have any notable side-effect besides the original intent, so I try to remove it now.
874+ #if 0
875+ clear_emu_events ();
876+ #endif
873877}
0 commit comments