diff --git a/core/gimx.c b/core/gimx.c index 64ab1f37..1b82517a 100755 --- a/core/gimx.c +++ b/core/gimx.c @@ -60,6 +60,8 @@ s_gimx_params gimx_params = .logfilename = NULL, .logfile = NULL, .skip_leds = 0, + .ff_conv = 0, + .inactivity_timeout = 0, }; #ifdef WIN32 @@ -181,6 +183,29 @@ void show_config() } } +void auto_grab() +{ + if(gimx_params.grab) + { + int grab = 0; + int i; + for (i = 0; i < MAX_CONTROLLERS; ++i) + { + // check if config has a keyboard binding or a mouse binding + // in most cases window focus is required for getting keyboard/mouse events + // if config only has joystick bindings, window focus is not required, and grabbing mouse is not needed + if(adapter_get_device(E_DEVICE_TYPE_MOUSE, i) != -1 || adapter_get_device(E_DEVICE_TYPE_KEYBOARD, i) != -1) + { + grab = 1; + } + } + if (grab) + { + ginput_grab(); + } + } +} + int main(int argc, char *argv[]) { e_gimx_status status = E_GIMX_STATUS_SUCCESS; @@ -362,11 +387,6 @@ int main(int argc, char *argv[]) show_config(); } - if(gimx_params.grab) - { - ginput_grab(); - } - if(gimx_params.config_file) { cal_init(); @@ -396,6 +416,8 @@ int main(int argc, char *argv[]) cfg_read_calibration(); } + auto_grab(); + ginput_release_unused(); macros_init();