Skip to content

Commit

Permalink
Do not grab mouse for joystick-only configs #499
Browse files Browse the repository at this point in the history
  • Loading branch information
matlo committed Jan 13, 2018
1 parent 9cc9790 commit 0be8e7d
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions core/gimx.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ s_gimx_params gimx_params =
.logfilename = NULL,
.logfile = NULL,
.skip_leds = 0,
.ff_conv = 0,
.inactivity_timeout = 0,
};

#ifdef WIN32
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -396,6 +416,8 @@ int main(int argc, char *argv[])
cfg_read_calibration();
}

auto_grab();

ginput_release_unused();

macros_init();
Expand Down

0 comments on commit 0be8e7d

Please sign in to comment.