Create input_driver_grab_mouse

This commit is contained in:
twinaphex 2015-03-23 04:31:11 +01:00
parent 5f8407e16c
commit 0d164162fc
3 changed files with 19 additions and 3 deletions

View File

@ -258,3 +258,17 @@ uint64_t input_driver_get_capabilities(void)
return driver->input->get_capabilities(driver->input_data);
return 0;
}
bool input_driver_grab_mouse(bool state)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return false;
if (!driver->input)
return false;
if (!driver->input->grab_mouse)
return false;
driver->input->grab_mouse(driver->input_data, state);
return true;
}

View File

@ -148,6 +148,8 @@ uint64_t input_driver_get_capabilities(void);
const rarch_joypad_driver_t * input_driver_get_joypad_driver(void);
bool input_driver_grab_mouse(bool state);
#ifdef __cplusplus
}
#endif

View File

@ -2930,13 +2930,13 @@ bool rarch_main_command(unsigned cmd)
{
static bool grab_mouse_state = false;
if (!driver->input || !driver->input->grab_mouse)
grab_mouse_state = !grab_mouse_state;
if (!driver->input || !input_driver_grab_mouse(grab_mouse_state))
return false;
grab_mouse_state = !grab_mouse_state;
RARCH_LOG("Grab mouse state: %s.\n",
grab_mouse_state ? "yes" : "no");
driver->input->grab_mouse(driver->input_data, grab_mouse_state);
video_driver_show_mouse(!grab_mouse_state);
}