diff --git a/CHANGELOG.txt b/CHANGELOG.txt index fe692f82e..e886f7d3a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D1X-Rebirth Changelog 20101228 -------- editor/info.c, editor/med.c, include/editor/editor.h, include/editor/info.h: Make the keypad info display into a window +arch/include/event.h, arch/include/joy.h, arch/include/mouse.h, arch/sdl/event.c, arch/sdl/joy.c, arch/sdl/mouse.c, d1x.ini, include/args.h, main/automap.c, main/config.c, main/config.h, main/game.c, main/gamecntl.c, main/inferno.c, main/kconfig.c, main/menu.c, main/newmenu.c, main/playsave.c, main/playsave.h, misc/args.c: Added Sensitivity/Deadzone menu with sliders for each movement based action seperated for joystick and mouse to support all kinds of configuration - regardless the amount of joystick axes and whatnot; SDL_WM_GrabInput does not only capture mouse but also focus keyboard input - changed code to respect this fact and made grabbing a menu option which is enabled by default 20101224 -------- diff --git a/arch/include/event.h b/arch/include/event.h index 095e04dce..ee6d337ed 100644 --- a/arch/include/event.h +++ b/arch/include/event.h @@ -43,4 +43,6 @@ int call_default_handler(d_event *event); // Sends input, idle and draw events to event handlers void event_process(); +void event_toggle_focus(int activate_focus); + #endif diff --git a/arch/include/joy.h b/arch/include/joy.h index dbc634cca..52d76bc62 100644 --- a/arch/include/joy.h +++ b/arch/include/joy.h @@ -25,6 +25,6 @@ extern int joy_get_button_down_cnt(int btn); extern void joystick_read_raw_axis(int *axis); extern void joy_flush(); extern int joy_get_button_state(int btn); -extern int joy_get_scaled_reading(int raw, int axn); +extern int joy_get_scaled_reading(int raw); #endif // _JOY_H diff --git a/arch/include/mouse.h b/arch/include/mouse.h index 9301fc33f..c26e8830a 100644 --- a/arch/include/mouse.h +++ b/arch/include/mouse.h @@ -46,6 +46,5 @@ extern void mouse_set_pos( int x, int y); extern fix64 mouse_button_down_time(int button); extern int mouse_button_down_count(int button); extern int mouse_button_state(int button); -extern void mouse_toggle_cursor(int activate); #endif diff --git a/arch/sdl/event.c b/arch/sdl/event.c index 87777960b..a095b3dc2 100644 --- a/arch/sdl/event.c +++ b/arch/sdl/event.c @@ -12,6 +12,7 @@ #include "key.h" #include "window.h" #include "timer.h" +#include "config.h" #include @@ -21,7 +22,8 @@ extern void mouse_motion_handler(SDL_MouseMotionEvent *mme); extern void joy_button_handler(SDL_JoyButtonEvent *jbe); extern void joy_hat_handler(SDL_JoyHatEvent *jhe); extern void joy_axis_handler(SDL_JoyAxisEvent *jae); -extern void mouse_update_cursor_and_grab(); +extern void mouse_cursor_autohide(); +extern void mouse_toggle_cursor(int activate); static int initialised=0; @@ -69,7 +71,7 @@ void event_poll() } } - mouse_update_cursor_and_grab(); + mouse_cursor_autohide(); } void event_flush() @@ -136,3 +138,13 @@ void event_process(void) gr_flip(); } + +void event_toggle_focus(int activate_focus) +{ + if (activate_focus && GameCfg.Grabinput) + SDL_WM_GrabInput(SDL_GRAB_ON); + else + SDL_WM_GrabInput(SDL_GRAB_OFF); + mouse_toggle_cursor(!activate_focus); +} + diff --git a/arch/sdl/joy.c b/arch/sdl/joy.c index 50fe20bd2..2f6a1d8d3 100644 --- a/arch/sdl/joy.c +++ b/arch/sdl/joy.c @@ -301,15 +301,7 @@ int joy_get_button_state( int btn ) return Joystick.buttons[btn].state; } -int joy_get_scaled_reading( int raw, int axis_num ) +int joy_get_scaled_reading( int raw ) { - int x, d; - - d = (PlayerCfg.JoystickDeadzone) * 6; - if (((raw/256) > (-1*d)) && ((raw/256) < d)) - x = 0; - else - x = raw/256; - - return x; + return raw/256; } diff --git a/arch/sdl/mouse.c b/arch/sdl/mouse.c index 166e46cbc..9ec1f2117 100644 --- a/arch/sdl/mouse.c +++ b/arch/sdl/mouse.c @@ -38,13 +38,11 @@ typedef struct d_event_mousebutton void mouse_init(void) { memset(&Mouse,0,sizeof(Mouse)); - mouse_toggle_cursor(1); } void mouse_close(void) { SDL_ShowCursor(SDL_ENABLE); - SDL_WM_GrabInput(SDL_GRAB_OFF); } void mouse_button_handler(SDL_MouseButtonEvent *mbe) @@ -241,27 +239,14 @@ int mouse_button_state(int button) void mouse_toggle_cursor(int activate) { Mouse.cursor_enabled = (activate && !GameArg.CtlNoMouse); - if (Mouse.cursor_enabled) - { - if (GameArg.CtlGrabMouse) - SDL_WM_GrabInput(SDL_GRAB_OFF); - } - else - { + if (!Mouse.cursor_enabled) SDL_ShowCursor(SDL_DISABLE); - if (GameArg.CtlGrabMouse) - SDL_WM_GrabInput(SDL_GRAB_ON); - } } -/* - * Here we check what to do with our mouse: - * If we want to display/hide cursor, do so if not already and also hide it automatically after some time. - * If we want to grab/release cursor, do so if not already. - */ -void mouse_update_cursor_and_grab() +// If we want to display/hide cursor, do so if not already and also hide it automatically after some time. +void mouse_cursor_autohide() { - int show = SDL_ShowCursor(SDL_QUERY), grab = SDL_WM_GrabInput(SDL_QUERY); + int show = SDL_ShowCursor(SDL_QUERY); if (Mouse.cursor_enabled) { @@ -269,15 +254,10 @@ void mouse_update_cursor_and_grab() SDL_ShowCursor(SDL_ENABLE); else if ( (Mouse.cursor_time + (F1_0*2)) < timer_query() && show) SDL_ShowCursor(SDL_DISABLE); - - if (grab) - SDL_WM_GrabInput(SDL_GRAB_OFF); } else { if (show) SDL_ShowCursor(SDL_DISABLE); - if (!grab && GameArg.CtlGrabMouse) - SDL_WM_GrabInput(SDL_GRAB_ON); } } diff --git a/d1x.ini b/d1x.ini index 3a0328493..5709399d0 100644 --- a/d1x.ini +++ b/d1x.ini @@ -18,8 +18,7 @@ ;-nomouse Deactivate mouse ;-nojoystick Deactivate joystick ;-mouselook Activate mouselook. Works in singleplayer only -;-grabmouse Keeps the mouse from wandering out of the window -;-nostickykeys Make CapsLock and NumLock non-sticky so they can be used as normal keys +;-nostickykeys Make CapsLock and NumLock non-sticky so they can be used as normal keys Sound: @@ -36,9 +35,9 @@ ;-multimessages Only show player-chat important Multiplayer messages ;-ipxnetwork Use IPX network number -;-udp_hostaddr When manually joining a game use default IP Address to connect to -;-udp_hostport When manually joining a game use default UDP Port to connect to -;-udp_myport When hosting/joining a game use default UDP Port to send packets from +;-udp_hostaddr When manually joining a game use default IP Address to connect to +;-udp_hostport When manually joining a game use default UDP Port to connect to +;-udp_myport When hosting/joining a game use default UDP Port to send packets from Debug (use only if you know what you're doing): diff --git a/include/args.h b/include/args.h index 477361a24..9bb1e7a90 100644 --- a/include/args.h +++ b/include/args.h @@ -56,7 +56,6 @@ typedef struct Arg int CtlNoMouse; int CtlNoJoystick; int CtlMouselook; - int CtlGrabMouse; int SndNoSound; int SndNoMusic; int SndDisableSdlMixer; diff --git a/main/automap.c b/main/automap.c index d62caddd3..cea17028d 100644 --- a/main/automap.c +++ b/main/automap.c @@ -509,11 +509,11 @@ int automap_handler(window *wind, d_event *event, automap *am) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); - mouse_toggle_cursor(0); + event_toggle_focus(1); break; case EVENT_WINDOW_DEACTIVATED: - mouse_toggle_cursor(1); + event_toggle_focus(0); break; case EVENT_KEY_COMMAND: @@ -528,7 +528,7 @@ int automap_handler(window *wind, d_event *event, automap *am) break; case EVENT_WINDOW_CLOSE: - mouse_toggle_cursor(1); + event_toggle_focus(0); #ifdef OGL gr_free_bitmap_data(&am->automap_background); #endif diff --git a/main/config.c b/main/config.c index 0a0e48823..225e728e2 100644 --- a/main/config.c +++ b/main/config.c @@ -62,6 +62,7 @@ static char *WindowModeStr="WindowMode"; static char *TexFiltStr="TexFilt"; static char *VSyncStr="VSync"; static char *MultisampleStr="Multisample"; +static char *GrabinputStr="GrabInput"; int ReadConfigFile() { @@ -108,6 +109,7 @@ int ReadConfigFile() GameCfg.TexFilt = 0; GameCfg.VSync = 0; GameCfg.Multisample = 0; + GameCfg.Grabinput = 1; infile = PHYSFSX_openReadBuffered("descent.cfg"); @@ -211,6 +213,8 @@ int ReadConfigFile() GameCfg.VSync = strtol(value, NULL, 10); else if (!strcmp(token, MultisampleStr)) GameCfg.Multisample = strtol(value, NULL, 10); + else if (!strcmp(token, GrabinputStr)) + GameCfg.Grabinput = strtol(value, NULL, 10); } } @@ -262,6 +266,7 @@ int WriteConfigFile() PHYSFSX_printf(infile, "%s=%i\n", TexFiltStr, GameCfg.TexFilt); PHYSFSX_printf(infile, "%s=%i\n", VSyncStr, GameCfg.VSync); PHYSFSX_printf(infile, "%s=%i\n", MultisampleStr, GameCfg.Multisample); + PHYSFSX_printf(infile, "%s=%i\n", GrabinputStr, GameCfg.Grabinput); PHYSFS_close(infile); diff --git a/main/config.h b/main/config.h index cdbda6285..56417472b 100644 --- a/main/config.h +++ b/main/config.h @@ -46,6 +46,7 @@ typedef struct Cfg int TexFilt; int VSync; int Multisample; + int Grabinput; } __pack__ Cfg; extern struct Cfg GameCfg; diff --git a/main/game.c b/main/game.c index 528bf3ad3..8cb04d219 100644 --- a/main/game.c +++ b/main/game.c @@ -990,7 +990,7 @@ int game_handler(window *wind, d_event *event, void *data) case EVENT_WINDOW_ACTIVATED: set_screen_mode(SCREEN_GAME); - mouse_toggle_cursor(0); + event_toggle_focus(1); game_flush_inputs(); if (time_paused) @@ -1015,7 +1015,7 @@ int game_handler(window *wind, d_event *event, void *data) if (!((Game_mode & GM_MULTI) && (Newdemo_state != ND_STATE_PLAYBACK))) palette_save(); - mouse_toggle_cursor(1); + event_toggle_focus(0); break; case EVENT_MOUSE_BUTTON_UP: @@ -1060,7 +1060,7 @@ int game_handler(window *wind, d_event *event, void *data) Game_mode = GM_GAME_OVER; show_menus(); Game_wind = NULL; - mouse_toggle_cursor(1); + event_toggle_focus(0); break; case EVENT_WINDOW_CLOSED: diff --git a/main/gamecntl.c b/main/gamecntl.c index eb024225e..787801851 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -229,7 +229,7 @@ int pause_handler(window *wind, d_event *event, char *msg) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); - mouse_toggle_cursor(1); + event_toggle_focus(0); break; case EVENT_KEY_COMMAND: @@ -263,7 +263,7 @@ int pause_handler(window *wind, d_event *event, char *msg) break; case EVENT_WINDOW_CLOSE: - mouse_toggle_cursor(0); + event_toggle_focus(1); songs_resume(); d_free(msg); break; diff --git a/main/inferno.c b/main/inferno.c index ff9c1a803..67cbda043 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -121,7 +121,6 @@ void print_commandline_help() printf( " -nomouse %s\n", "Deactivate mouse"); printf( " -nojoystick %s\n", "Deactivate joystick"); printf( " -mouselook %s\n", "Activate mouselook. Works in singleplayer only"); - printf( " -grabmouse %s\n", "Keeps the mouse from wandering out of the window"); printf( " -nostickykeys %s\n", "Make CapsLock and NumLock non-sticky so they can be used as normal keys"); printf( "\n Sound:\n\n"); diff --git a/main/kconfig.c b/main/kconfig.c index 8206bc12a..305d839bb 100644 --- a/main/kconfig.c +++ b/main/kconfig.c @@ -791,7 +791,7 @@ int kconfig_handler(window *wind, d_event *event, kc_menu *menu) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); - mouse_toggle_cursor(1); + event_toggle_focus(0); break; case EVENT_WINDOW_DEACTIVATED: @@ -844,7 +844,7 @@ int kconfig_handler(window *wind, d_event *event, kc_menu *menu) break; case EVENT_WINDOW_CLOSE: - mouse_toggle_cursor(0); + event_toggle_focus(1); d_free(menu); // Update save values... @@ -1162,12 +1162,22 @@ void controls_read_all(int automap_flag) for (i = 0; i < joy_num_axes; i++) { - int joy_null_value = 10; + int joy_null_value = 0; - raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i ); + raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i] ); - if (kc_joystick[23].value==i) // If this is the throttle - joy_null_value = 20; // Then use a larger dead-zone + if (i == kc_joystick[13].value) // Pitch U/D Deadzone + joy_null_value = PlayerCfg.JoystickDead[1]*8; + if (i == kc_joystick[15].value) // Turn L/R Deadzone + joy_null_value = PlayerCfg.JoystickDead[0]*8; + if (i == kc_joystick[17].value) // Slide L/R Deadzone + joy_null_value = PlayerCfg.JoystickDead[2]*8; + if (i == kc_joystick[19].value) // Slide U/D Deadzone + joy_null_value = PlayerCfg.JoystickDead[3]*8; + if (i == kc_joystick[21].value) // Bank Deadzone + joy_null_value = PlayerCfg.JoystickDead[4]*8; + if (i == kc_joystick[23].value) // Throttle - default deadzone + joy_null_value = 20; if (raw_joy_axis[i] > joy_null_value) raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value); @@ -1315,17 +1325,17 @@ void controls_read_all(int automap_flag) // From joystick... if ( (use_joystick)&&(kc_joystick[13].value < 255 )) { if ( !kc_joystick[14].value ) // If not inverted... - Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSensitivityY)/8; + Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSens[1])/8; else - Controls.pitch_time += (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSensitivityY)/8; + Controls.pitch_time += (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSens[1])/8; } // From mouse... if ( (use_mouse)&&(kc_mouse[13].value < 255) ) { if ( !kc_mouse[14].value ) // If not inverted... - Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSensitivityY)/8; + Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSens[1])/8; else - Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSensitivityY)/8; + Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSens[1])/8; } } else { Controls.pitch_time = 0; @@ -1354,17 +1364,17 @@ void controls_read_all(int automap_flag) // From joystick... if ((use_joystick)&&( kc_joystick[13].value < 255 )) { if ( !kc_joystick[14].value ) // If not inverted... - Controls.vertical_thrust_time += (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSensitivityY)/8; + Controls.vertical_thrust_time += (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSens[3])/8; else - Controls.vertical_thrust_time -= (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSensitivityY)/8; + Controls.vertical_thrust_time -= (joy_axis[kc_joystick[13].value]*PlayerCfg.JoystickSens[3])/8; } // From mouse... if ( (use_mouse)&&(kc_mouse[13].value < 255 )) { if ( !kc_mouse[14].value ) // If not inverted... - Controls.vertical_thrust_time -= (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSensitivityY)/8; + Controls.vertical_thrust_time -= (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSens[3])/8; else - Controls.vertical_thrust_time += (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSensitivityY)/8; + Controls.vertical_thrust_time += (mouse_axis[kc_mouse[13].value]*PlayerCfg.MouseSens[3])/8; } } @@ -1377,9 +1387,9 @@ void controls_read_all(int automap_flag) // From joystick... if ((use_joystick)&&( kc_joystick[19].value < 255 )) { if ( !kc_joystick[20].value ) // If not inverted... - Controls.vertical_thrust_time -= (joy_axis[kc_joystick[19].value]*PlayerCfg.JoystickSensitivityY)/8; + Controls.vertical_thrust_time -= (joy_axis[kc_joystick[19].value]*PlayerCfg.JoystickSens[3])/8; else - Controls.vertical_thrust_time += (joy_axis[kc_joystick[19].value]*PlayerCfg.JoystickSensitivityY)/8; + Controls.vertical_thrust_time += (joy_axis[kc_joystick[19].value]*PlayerCfg.JoystickSens[3])/8; } // From joystick buttons @@ -1395,9 +1405,9 @@ void controls_read_all(int automap_flag) // From mouse... if ( (use_mouse)&&(kc_mouse[19].value < 255 )) { if ( !kc_mouse[20].value ) // If not inverted... - Controls.vertical_thrust_time += (mouse_axis[kc_mouse[19].value]*PlayerCfg.MouseSensitivityY)/8; + Controls.vertical_thrust_time += (mouse_axis[kc_mouse[19].value]*PlayerCfg.MouseSens[3])/8; else - Controls.vertical_thrust_time -= (mouse_axis[kc_mouse[19].value]*PlayerCfg.MouseSensitivityY)/8; + Controls.vertical_thrust_time -= (mouse_axis[kc_mouse[19].value]*PlayerCfg.MouseSens[3])/8; } //Read primary cycle @@ -1453,17 +1463,17 @@ void controls_read_all(int automap_flag) // From joystick... if ( (use_joystick)&&(kc_joystick[15].value < 255 )) { if ( !kc_joystick[16].value ) // If not inverted... - Controls.heading_time += (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.heading_time += (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSens[0])/8; else - Controls.heading_time -= (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.heading_time -= (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSens[0])/8; } // From mouse... if ( (use_mouse)&&(kc_mouse[15].value < 255 )) { if ( !kc_mouse[16].value ) // If not inverted... - Controls.heading_time += (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.heading_time += (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSens[0])/8; else - Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSens[0])/8; } } else { Controls.heading_time = 0; @@ -1489,17 +1499,17 @@ void controls_read_all(int automap_flag) // From joystick... if ( (use_joystick)&&(kc_joystick[15].value < 255 )) { if ( !kc_joystick[16].value ) // If not inverted... - Controls.sideways_thrust_time += (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.sideways_thrust_time += (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSens[2])/8; else - Controls.sideways_thrust_time -= (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.sideways_thrust_time -= (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSens[2])/8; } // From mouse... if ( (use_mouse)&&(kc_mouse[15].value < 255 )) { if ( !kc_mouse[16].value ) // If not inverted... - Controls.sideways_thrust_time += (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.sideways_thrust_time += (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSens[2])/8; else - Controls.sideways_thrust_time -= (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.sideways_thrust_time -= (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSens[2])/8; } } @@ -1512,9 +1522,9 @@ void controls_read_all(int automap_flag) // From joystick... if ( (use_joystick)&&(kc_joystick[17].value < 255 )) { if ( !kc_joystick[18].value ) // If not inverted... - Controls.sideways_thrust_time += (joy_axis[kc_joystick[17].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.sideways_thrust_time += (joy_axis[kc_joystick[17].value]*PlayerCfg.JoystickSens[2])/8; else - Controls.sideways_thrust_time -= (joy_axis[kc_joystick[17].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.sideways_thrust_time -= (joy_axis[kc_joystick[17].value]*PlayerCfg.JoystickSens[2])/8; } // From joystick buttons @@ -1530,9 +1540,9 @@ void controls_read_all(int automap_flag) // From mouse... if ( (use_mouse)&&(kc_mouse[17].value < 255 )) { if ( !kc_mouse[18].value ) // If not inverted... - Controls.sideways_thrust_time += (mouse_axis[kc_mouse[17].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.sideways_thrust_time += (mouse_axis[kc_mouse[17].value]*PlayerCfg.MouseSens[2])/8; else - Controls.sideways_thrust_time -= (mouse_axis[kc_mouse[17].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.sideways_thrust_time -= (mouse_axis[kc_mouse[17].value]*PlayerCfg.MouseSens[2])/8; } } @@ -1553,17 +1563,17 @@ void controls_read_all(int automap_flag) // From joystick... if ( (use_joystick)&&(kc_joystick[15].value < 255) ) { if ( !kc_joystick[16].value ) // If not inverted... - Controls.bank_time -= (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.bank_time -= (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSens[4])/8; else - Controls.bank_time += (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSensitivityX)/8; + Controls.bank_time += (joy_axis[kc_joystick[15].value]*PlayerCfg.JoystickSens[4])/8; } // From mouse... if ( (use_mouse)&&(kc_mouse[15].value < 255 )) { if ( !kc_mouse[16].value ) // If not inverted... - Controls.bank_time += (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.bank_time += (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSens[4])/8; else - Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSensitivityX)/8; + Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*PlayerCfg.MouseSens[4])/8; } } diff --git a/main/menu.c b/main/menu.c index f7cc27bf6..c8e2dd716 100644 --- a/main/menu.c +++ b/main/menu.c @@ -997,7 +997,47 @@ void change_res() } } -int input_menuset(newmenu *menu, d_event *event, void *userdata) +void input_config_sensitivity() +{ + newmenu_item m[20]; + int i = 0, nitems = 0, joysens = 0, joydead = 0, mousesens = 0; + + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = "Joystick Sensitivity:"; nitems++; + joysens = nitems; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_TURN_LR; m[nitems].value = PlayerCfg.JoystickSens[0]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_PITCH_UD; m[nitems].value = PlayerCfg.JoystickSens[1]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_SLIDE_LR; m[nitems].value = PlayerCfg.JoystickSens[2]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_SLIDE_UD; m[nitems].value = PlayerCfg.JoystickSens[3]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_BANK_LR; m[nitems].value = PlayerCfg.JoystickSens[4]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = ""; nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = "Joystick Deadzone:"; nitems++; + joydead = nitems; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_TURN_LR; m[nitems].value = PlayerCfg.JoystickDead[0]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_PITCH_UD; m[nitems].value = PlayerCfg.JoystickDead[1]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_SLIDE_LR; m[nitems].value = PlayerCfg.JoystickDead[2]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_SLIDE_UD; m[nitems].value = PlayerCfg.JoystickDead[3]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_BANK_LR; m[nitems].value = PlayerCfg.JoystickDead[4]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = ""; nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = "Mouse Sensitivity:"; nitems++; + mousesens = nitems; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_TURN_LR; m[nitems].value = PlayerCfg.MouseSens[0]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_PITCH_UD; m[nitems].value = PlayerCfg.MouseSens[1]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_SLIDE_LR; m[nitems].value = PlayerCfg.MouseSens[2]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_SLIDE_UD; m[nitems].value = PlayerCfg.MouseSens[3]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + m[nitems].type = NM_TYPE_SLIDER; m[nitems].text = TXT_BANK_LR; m[nitems].value = PlayerCfg.MouseSens[4]; m[nitems].min_value = 0; m[nitems].max_value = 16; nitems++; + + newmenu_do1(NULL, "SENSITIVITY & DEADZONE", nitems, m, NULL, NULL, 1); + + for (i = 0; i <= 4; i++) + { + PlayerCfg.JoystickSens[i] = m[joysens+i].value; + PlayerCfg.JoystickDead[i] = m[joydead+i].value; + PlayerCfg.MouseSens[i] = m[mousesens+i].value; + } +} + +static int opt_ic_usejoy = 0, opt_ic_usemouse = 0, opt_ic_confkey = 0, opt_ic_confjoy = 0, opt_ic_confmouse = 0, opt_ic_confweap = 0, opt_ic_joymousesens = 0, opt_ic_grabinput = 0, opt_ic_mousefilt = 0, opt_ic_help0 = 0, opt_ic_help1 = 0, opt_ic_help2 = 0; +int input_config_menuset(newmenu *menu, d_event *event, void *userdata) { newmenu_item *items = newmenu_get_items(menu); int citem = newmenu_get_citem(menu); @@ -1007,44 +1047,33 @@ int input_menuset(newmenu *menu, d_event *event, void *userdata) switch (event->type) { case EVENT_NEWMENU_CHANGED: - switch (citem) - { - case 0: (items[citem].value)?(PlayerCfg.ControlType|=CONTROL_USING_JOYSTICK):(PlayerCfg.ControlType&=~CONTROL_USING_JOYSTICK); break; - case 1: (items[citem].value)?(PlayerCfg.ControlType|=CONTROL_USING_MOUSE):(PlayerCfg.ControlType&=~CONTROL_USING_MOUSE); break; - case 9: PlayerCfg.JoystickSensitivityX = items[citem].value; break; - case 10: PlayerCfg.JoystickSensitivityY = items[citem].value; break; - case 11: PlayerCfg.JoystickDeadzone = items[citem].value; break; - case 14: PlayerCfg.MouseSensitivityX = items[citem].value; break; - case 15: PlayerCfg.MouseSensitivityY = items[citem].value; break; - case 16: PlayerCfg.MouseFilter = items[citem].value; break; - } + if (citem == opt_ic_usejoy) + (items[citem].value)?(PlayerCfg.ControlType|=CONTROL_USING_JOYSTICK):(PlayerCfg.ControlType&=~CONTROL_USING_JOYSTICK); + if (citem == opt_ic_usemouse) + (items[citem].value)?(PlayerCfg.ControlType|=CONTROL_USING_MOUSE):(PlayerCfg.ControlType&=~CONTROL_USING_MOUSE); + if (citem == opt_ic_grabinput) + GameCfg.Grabinput = items[citem].value; + if (citem == opt_ic_mousefilt) + PlayerCfg.MouseFilter = items[citem].value; break; case EVENT_NEWMENU_SELECTED: - switch (citem) - { - case 3: - kconfig(0, "KEYBOARD"); - break; - case 4: - kconfig(1, "JOYSTICK"); - break; - case 5: - kconfig(2, "MOUSE"); - break; - case 6: - kconfig(3, "WEAPON KEYS"); - break; - case 18: - show_help(); - break; - case 19: - show_netgame_help(); - break; - case 20: - show_newdemo_help(); - break; - } + if (citem == opt_ic_confkey) + kconfig(0, "KEYBOARD"); + if (citem == opt_ic_confjoy) + kconfig(1, "JOYSTICK"); + if (citem == opt_ic_confmouse) + kconfig(2, "MOUSE"); + if (citem == opt_ic_confweap) + kconfig(3, "WEAPON KEYS"); + if (citem == opt_ic_joymousesens) + input_config_sensitivity(); + if (citem == opt_ic_help0) + show_help(); + if (citem == opt_ic_help1) + show_netgame_help(); + if (citem == opt_ic_help2) + show_newdemo_help(); return 1; // stay in menu break; @@ -1057,32 +1086,39 @@ int input_menuset(newmenu *menu, d_event *event, void *userdata) void input_config() { - newmenu_item m[21]; - int nitems = 21; + newmenu_item m[16]; + int nitems = 0; - m[0].type = NM_TYPE_CHECK; m[0].text = "USE JOYSTICK"; m[0].value = (PlayerCfg.ControlType&CONTROL_USING_JOYSTICK); - m[1].type = NM_TYPE_CHECK; m[1].text = "USE MOUSE"; m[1].value = (PlayerCfg.ControlType&CONTROL_USING_MOUSE); - m[2].type = NM_TYPE_TEXT; m[2].text = ""; - m[3].type = NM_TYPE_MENU; m[3].text = "CUSTOMIZE KEYBOARD"; - m[4].type = NM_TYPE_MENU; m[4].text = "CUSTOMIZE JOYSTICK"; - m[5].type = NM_TYPE_MENU; m[5].text = "CUSTOMIZE MOUSE"; - m[6].type = NM_TYPE_MENU; m[6].text = "CUSTOMIZE WEAPON KEYS"; - m[7].type = NM_TYPE_TEXT; m[7].text = ""; - m[8].type = NM_TYPE_TEXT; m[8].text = "Joystick"; - m[9].type = NM_TYPE_SLIDER; m[9].text="X Sensitivity"; m[9].value=PlayerCfg.JoystickSensitivityX; m[9].min_value = 0; m[9].max_value = 16; - m[10].type = NM_TYPE_SLIDER; m[10].text="Y Sensitivity"; m[10].value=PlayerCfg.JoystickSensitivityY; m[10].min_value = 0; m[10].max_value = 16; - m[11].type = NM_TYPE_SLIDER; m[11].text="Deadzone"; m[11].value=PlayerCfg.JoystickDeadzone; m[11].min_value=0; m[11].max_value = 16; - m[12].type = NM_TYPE_TEXT; m[12].text = ""; - m[13].type = NM_TYPE_TEXT; m[13].text = "Mouse"; - m[14].type = NM_TYPE_SLIDER; m[14].text="X Sensitivity"; m[14].value=PlayerCfg.MouseSensitivityX; m[14].min_value = 0; m[14].max_value = 16; - m[15].type = NM_TYPE_SLIDER; m[15].text="Y Sensitivity"; m[15].value=PlayerCfg.MouseSensitivityY; m[15].min_value = 0; m[15].max_value = 16; - m[16].type = NM_TYPE_CHECK; m[16].text="Mouse Smoothing/Filtering"; m[16].value=PlayerCfg.MouseFilter; - m[17].type = NM_TYPE_TEXT; m[17].text = ""; - m[18].type = NM_TYPE_MENU; m[18].text = "GAME SYSTEM KEYS"; - m[19].type = NM_TYPE_MENU; m[19].text = "NETGAME SYSTEM KEYS"; - m[20].type = NM_TYPE_MENU; m[20].text = "DEMO SYSTEM KEYS"; + opt_ic_usejoy = nitems; + m[nitems].type = NM_TYPE_CHECK; m[nitems].text = "USE JOYSTICK"; m[nitems].value = (PlayerCfg.ControlType&CONTROL_USING_JOYSTICK); nitems++; + opt_ic_usemouse = nitems; + m[nitems].type = NM_TYPE_CHECK; m[nitems].text = "USE MOUSE"; m[nitems].value = (PlayerCfg.ControlType&CONTROL_USING_MOUSE); nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = ""; nitems++; + opt_ic_confkey = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "CUSTOMIZE KEYBOARD"; nitems++; + opt_ic_confjoy = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "CUSTOMIZE JOYSTICK"; nitems++; + opt_ic_confmouse = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "CUSTOMIZE MOUSE"; nitems++; + opt_ic_confweap = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "CUSTOMIZE WEAPON KEYS"; nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = ""; nitems++; + opt_ic_joymousesens = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "SENSITIVITY & DEADZONE"; nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = ""; nitems++; + opt_ic_grabinput = nitems; + m[nitems].type = NM_TYPE_CHECK; m[nitems].text= "Keyboard/Mouse input focused"; m[nitems].value = GameCfg.Grabinput; nitems++; + opt_ic_mousefilt = nitems; + m[nitems].type = NM_TYPE_CHECK; m[nitems].text= "Mouse Smoothing/Filtering"; m[nitems].value = PlayerCfg.MouseFilter; nitems++; + m[nitems].type = NM_TYPE_TEXT; m[nitems].text = ""; nitems++; + opt_ic_help0 = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "GAME SYSTEM KEYS"; nitems++; + opt_ic_help1 = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "NETGAME SYSTEM KEYS"; nitems++; + opt_ic_help2 = nitems; + m[nitems].type = NM_TYPE_MENU; m[nitems].text = "DEMO SYSTEM KEYS"; nitems++; - newmenu_do1(NULL, TXT_CONTROLS, nitems, m, input_menuset, NULL, 3); + newmenu_do1(NULL, TXT_CONTROLS, nitems, m, input_config_menuset, NULL, 3); } void do_graphics_menu() diff --git a/main/newmenu.c b/main/newmenu.c index b9e62b522..f022fa6be 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -1461,11 +1461,11 @@ int newmenu_handler(window *wind, d_event *event, newmenu *menu) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); - mouse_toggle_cursor(1); + event_toggle_focus(0); break; case EVENT_WINDOW_DEACTIVATED: - mouse_toggle_cursor(0); + event_toggle_focus(1); menu->mouse_state = 0; break; @@ -2009,11 +2009,11 @@ int listbox_handler(window *wind, d_event *event, listbox *lb) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); - mouse_toggle_cursor(1); + event_toggle_focus(0); break; case EVENT_WINDOW_DEACTIVATED: - mouse_toggle_cursor(0); + event_toggle_focus(1); break; case EVENT_MOUSE_BUTTON_DOWN: diff --git a/main/playsave.c b/main/playsave.c index d4af351cf..956c8e9c4 100644 --- a/main/playsave.c +++ b/main/playsave.c @@ -75,10 +75,9 @@ int new_player_config() PlayerCfg.NHighestLevels = 1; PlayerCfg.HighestLevels[0].Shortname[0] = 0; //no name for mission 0 PlayerCfg.HighestLevels[0].LevelNum = 1; //was highest level in old struct - PlayerCfg.JoystickSensitivityX = 8; - PlayerCfg.JoystickSensitivityY = 8; - PlayerCfg.MouseSensitivityX = 8; - PlayerCfg.MouseSensitivityY = 8; + PlayerCfg.JoystickSens[0] = PlayerCfg.JoystickSens[1] = PlayerCfg.JoystickSens[2] = PlayerCfg.JoystickSens[3] = PlayerCfg.JoystickSens[4] = 8; + PlayerCfg.JoystickDead[0] = PlayerCfg.JoystickDead[1] = PlayerCfg.JoystickDead[2] = PlayerCfg.JoystickDead[3] = PlayerCfg.JoystickDead[4] = 0; + PlayerCfg.MouseSens[0] = PlayerCfg.MouseSens[1] = PlayerCfg.MouseSens[2] = PlayerCfg.MouseSens[3] = PlayerCfg.MouseSens[4] = 8; PlayerCfg.MouseFilter = 0; PlayerCfg.CockpitMode[0] = PlayerCfg.CockpitMode[1] = CM_FULL_COCKPIT; PlayerCfg.ReticleOn = 1; @@ -203,12 +202,26 @@ int read_player_d1x(char *filename) while(!strstr(word,"END") && !PHYSFS_eof(f)) { - if(!strcmp(word,"SENSITIVITYX")) - PlayerCfg.JoystickSensitivityX = atoi(line); - if(!strcmp(word,"SENSITIVITYY")) - PlayerCfg.JoystickSensitivityY = atoi(line); - if(!strcmp(word,"DEADZONE")) - PlayerCfg.JoystickDeadzone = atoi(line); + if(!strcmp(word,"SENSITIVITY0")) + PlayerCfg.JoystickSens[0] = atoi(line); + if(!strcmp(word,"SENSITIVITY1")) + PlayerCfg.JoystickSens[1] = atoi(line); + if(!strcmp(word,"SENSITIVITY2")) + PlayerCfg.JoystickSens[2] = atoi(line); + if(!strcmp(word,"SENSITIVITY3")) + PlayerCfg.JoystickSens[3] = atoi(line); + if(!strcmp(word,"SENSITIVITY4")) + PlayerCfg.JoystickSens[4] = atoi(line); + if(!strcmp(word,"DEADZONE0")) + PlayerCfg.JoystickDead[0] = atoi(line); + if(!strcmp(word,"DEADZONE1")) + PlayerCfg.JoystickDead[1] = atoi(line); + if(!strcmp(word,"DEADZONE2")) + PlayerCfg.JoystickDead[2] = atoi(line); + if(!strcmp(word,"DEADZONE3")) + PlayerCfg.JoystickDead[3] = atoi(line); + if(!strcmp(word,"DEADZONE4")) + PlayerCfg.JoystickDead[4] = atoi(line); d_free(word); cfgets(line,50,f); word=splitword(line,'='); @@ -224,10 +237,16 @@ int read_player_d1x(char *filename) while(!strstr(word,"END") && !PHYSFS_eof(f)) { - if(!strcmp(word,"SENSITIVITYX")) - PlayerCfg.MouseSensitivityX = atoi(line); - if(!strcmp(word,"SENSITIVITYY")) - PlayerCfg.MouseSensitivityY = atoi(line); + if(!strcmp(word,"SENSITIVITY0")) + PlayerCfg.MouseSens[0] = atoi(line); + if(!strcmp(word,"SENSITIVITY1")) + PlayerCfg.MouseSens[1] = atoi(line); + if(!strcmp(word,"SENSITIVITY2")) + PlayerCfg.MouseSens[2] = atoi(line); + if(!strcmp(word,"SENSITIVITY3")) + PlayerCfg.MouseSens[3] = atoi(line); + if(!strcmp(word,"SENSITIVITY4")) + PlayerCfg.MouseSens[4] = atoi(line); if(!strcmp(word,"FILTER")) PlayerCfg.MouseFilter = atoi(line); d_free(word); @@ -527,13 +546,23 @@ int write_player_d1x(char *filename) PHYSFSX_printf(fout,"cycle secondary=0x%x,0x%x\n",PlayerCfg.KeySettingsD1X[22],PlayerCfg.KeySettingsD1X[23]); PHYSFSX_printf(fout,"[end]\n"); PHYSFSX_printf(fout,"[joystick]\n"); - PHYSFSX_printf(fout,"sensitivityx=%d\n",PlayerCfg.JoystickSensitivityX); - PHYSFSX_printf(fout,"sensitivityy=%d\n",PlayerCfg.JoystickSensitivityY); - PHYSFSX_printf(fout,"deadzone=%i\n",PlayerCfg.JoystickDeadzone); + PHYSFSX_printf(fout,"sensitivity0=%d\n",PlayerCfg.JoystickSens[0]); + PHYSFSX_printf(fout,"sensitivity1=%d\n",PlayerCfg.JoystickSens[1]); + PHYSFSX_printf(fout,"sensitivity2=%d\n",PlayerCfg.JoystickSens[2]); + PHYSFSX_printf(fout,"sensitivity3=%d\n",PlayerCfg.JoystickSens[3]); + PHYSFSX_printf(fout,"sensitivity4=%d\n",PlayerCfg.JoystickSens[4]); + PHYSFSX_printf(fout,"deadzone0=%d\n",PlayerCfg.JoystickDead[0]); + PHYSFSX_printf(fout,"deadzone1=%d\n",PlayerCfg.JoystickDead[1]); + PHYSFSX_printf(fout,"deadzone2=%d\n",PlayerCfg.JoystickDead[2]); + PHYSFSX_printf(fout,"deadzone3=%d\n",PlayerCfg.JoystickDead[3]); + PHYSFSX_printf(fout,"deadzone4=%d\n",PlayerCfg.JoystickDead[4]); PHYSFSX_printf(fout,"[end]\n"); PHYSFSX_printf(fout,"[mouse]\n"); - PHYSFSX_printf(fout,"sensitivityx=%d\n",PlayerCfg.MouseSensitivityX); - PHYSFSX_printf(fout,"sensitivityy=%d\n",PlayerCfg.MouseSensitivityY); + PHYSFSX_printf(fout,"sensitivity0=%d\n",PlayerCfg.MouseSens[0]); + PHYSFSX_printf(fout,"sensitivity1=%d\n",PlayerCfg.MouseSens[1]); + PHYSFSX_printf(fout,"sensitivity2=%d\n",PlayerCfg.MouseSens[2]); + PHYSFSX_printf(fout,"sensitivity3=%d\n",PlayerCfg.MouseSens[3]); + PHYSFSX_printf(fout,"sensitivity4=%d\n",PlayerCfg.MouseSens[4]); PHYSFSX_printf(fout,"filter=%d\n",PlayerCfg.MouseFilter); PHYSFSX_printf(fout,"[end]\n"); PHYSFSX_printf(fout,"[cockpit]\n"); @@ -899,7 +928,7 @@ int write_player_file() if(errno_ret == EZERO) { - ubyte old_avg_joy_sensitivity = ((PlayerCfg.JoystickSensitivityX+PlayerCfg.JoystickSensitivityY+1)/2); + ubyte old_avg_joy_sensitivity = 8; if (PHYSFS_write( file, &PlayerCfg.ControlType, sizeof(ubyte), 1 )!=1) errno_ret=errno; else if (PHYSFS_write( file, &old_avg_joy_sensitivity, sizeof(ubyte), 1 )!=1) diff --git a/main/playsave.h b/main/playsave.h index a7c388115..ad5719af8 100644 --- a/main/playsave.h +++ b/main/playsave.h @@ -59,12 +59,10 @@ typedef struct player_config int AutoLeveling; short NHighestLevels; hli HighestLevels[MAX_MISSIONS]; - ubyte MouseSensitivityX; - ubyte MouseSensitivityY; + int JoystickSens[5]; + int JoystickDead[5]; + int MouseSens[5]; int MouseFilter; - ubyte JoystickSensitivityX; - ubyte JoystickSensitivityY; - int JoystickDeadzone; int CockpitMode[2]; // 0 saves the "real" cockpit, 1 also saves letterbox and rear. Used to properly switch between modes and restore the real one. char NetworkMessageMacro[4][MAX_MESSAGE_LEN]; int NetlifeKills; diff --git a/misc/args.c b/misc/args.c index 7a3db4145..aa2f30ea5 100644 --- a/misc/args.c +++ b/misc/args.c @@ -159,7 +159,6 @@ void ReadCmdArgs(void) GameArg.CtlNoMouse = FindArg("-nomouse"); GameArg.CtlNoJoystick = FindArg("-nojoystick"); GameArg.CtlMouselook = FindArg("-mouselook"); - GameArg.CtlGrabMouse = FindArg("-grabmouse"); if (FindArg("-nostickykeys")) // no GameArg, just an environment variable. Must happen before SDL_Init! SDL_putenv("SDL_DISABLE_LOCK_KEYS=1"); else