mistake with keymods
authorhgn <hgodden00@gmail.com>
Mon, 26 Dec 2022 17:29:54 +0000 (17:29 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 26 Dec 2022 17:29:54 +0000 (17:29 +0000)
vg.h
vg_console.h

diff --git a/vg.h b/vg.h
index ada54695aee189dc37a0583dceabc5cd6c17786d..17bc6eee93b817f032ce128a0e1893f9c71161ec 100644 (file)
--- a/vg.h
+++ b/vg.h
@@ -688,13 +688,19 @@ VG_STATIC void _vg_init_window( const char *window_name )
 
    vg.refresh_rate = mode.refresh_rate;
 
-   vg_info( "CreateWindow\n" );
+   if( !vg.window_x )
+      vg.window_x = mode.w;
+
+   if( !vg.window_y )
+      vg.window_y = mode.h;
+
+   vg_info( "CreateWindow( %d %d )\n", vg.window_x, vg.window_y );
 
    /* TODO: Allow selecting closest video mode from launch opts */
    if((vg.window = SDL_CreateWindow( window_name,
                                      SDL_WINDOWPOS_UNDEFINED,
                                      SDL_WINDOWPOS_UNDEFINED,
-                                     mode.w, mode.h,
+                                     vg.window_x, vg.window_y,
 
                                      SDL_WINDOW_FULLSCREEN_DESKTOP | 
                                      SDL_WINDOW_OPENGL |
@@ -751,6 +757,16 @@ VG_STATIC void _vg_init_window( const char *window_name )
    }
    else
       vg_success( "Using adaptive Vsync\n" );
+
+   SDL_DisplayMode dispmode;
+   if( !SDL_GetWindowDisplayMode( vg.window, &dispmode ) )
+   {
+      if( dispmode.refresh_rate )
+      {
+         vg.refresh_rate = dispmode.refresh_rate;
+         vg_info( "Refresh rate: %d\n", dispmode.refresh_rate );
+      }
+   }
 }
 
 VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name )
index 8d35aa286fdce8933e35b39720cd5dfd6534d850..e18515d45cd029e3d422da5c09881994193a7fc0 100644 (file)
@@ -655,7 +655,7 @@ VG_STATIC void console_proc_key( SDL_Keysym ev )
    }
    
    if( !vg_console.enabled ) return;
-   
+
    struct console_mapping
    {
       u16 mod;
@@ -663,7 +663,7 @@ VG_STATIC void console_proc_key( SDL_Keysym ev )
       
       void (*handler)(void);
    }
-   mapping[] =
+   mappings[] =
    {
       { 0,              SDLK_LEFT,       _console_left              },
       { KMOD_SHIFT,     SDLK_LEFT,       _console_left_select       },
@@ -684,23 +684,25 @@ VG_STATIC void console_proc_key( SDL_Keysym ev )
       { 0,              SDLK_RETURN,     _console_enter             }
    };
 
-   for( int i=0; i<vg_list_size( mapping ); i++ )
+   SDL_Keymod mod = ev.mod & (KMOD_SHIFT|KMOD_CTRL|KMOD_ALT);
+
+   for( int i=0; i<vg_list_size( mappings ); i++ )
    {
-      struct console_mapping *mk = &mapping[i];
+      struct console_mapping *mapping = &mappings[i];
 
-      if( mk->key == ev.sym )
+      if( mapping->key == ev.sym )
       {
-         if( mk->mod == 0 )
+         if( mapping->mod == 0 )
          {
-            if( ev.mod == 0 )
+            if( mod == 0 )
             {
-               mk->handler();
+               mapping->handler();
                return;
             }
          }
-         else if( (ev.mod & mk->mod) == mk->mod )
+         else if( (mod & mapping->mod) == mapping->mod )
          {
-            mk->handler();
+            mapping->handler();
             return;
          }
       }