From b76504a64c8d4847fc64d82083e5607e621e3be7 Mon Sep 17 00:00:00 2001 From: hgn Date: Mon, 26 Dec 2022 17:29:54 +0000 Subject: [PATCH] mistake with keymods --- vg.h | 20 ++++++++++++++++++-- vg_console.h | 22 ++++++++++++---------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/vg.h b/vg.h index ada5469..17bc6ee 100644 --- 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 ) diff --git a/vg_console.h b/vg_console.h index 8d35aa2..e18515d 100644 --- a/vg_console.h +++ b/vg_console.h @@ -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; ikey == 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; } } -- 2.25.1