Reimplement grab mouse code a bit - we really need to drastically

rewrite this
This commit is contained in:
twinaphex 2016-03-14 14:37:18 +01:00
parent 3f3983c19d
commit 2e080967b0
5 changed files with 32 additions and 19 deletions

View File

@ -1664,21 +1664,28 @@ bool event_cmd_ctl(enum event_command cmd, void *data)
break;
case EVENT_CMD_GRAB_MOUSE_TOGGLE:
{
bool ret = false;
static bool grab_mouse_state = false;
bool grab_mouse_state_tmp;
grab_mouse_state = !grab_mouse_state;
if (!input_driver_ctl(RARCH_INPUT_CTL_GRAB_MOUSE, &grab_mouse_state))
return false;
if (grab_mouse_state)
{
ret = input_driver_ctl(RARCH_INPUT_CTL_GRAB_MOUSE, NULL);
video_driver_ctl(RARCH_DISPLAY_CTL_SHOW_MOUSE, NULL);
}
else
{
ret = input_driver_ctl(RARCH_INPUT_CTL_UNGRAB_MOUSE, NULL);
video_driver_ctl(RARCH_DISPLAY_CTL_HIDE_MOUSE, NULL);
}
RARCH_LOG("%s: %s.\n",
msg_hash_to_str(MSG_GRAB_MOUSE_STATE),
grab_mouse_state ? "yes" : "no");
grab_mouse_state_tmp = !grab_mouse_state;
video_driver_ctl(RARCH_DISPLAY_CTL_SHOW_MOUSE,
&grab_mouse_state_tmp);
if (!ret)
return false;
}
break;
case EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG:

View File

@ -1451,13 +1451,14 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
case RARCH_DISPLAY_CTL_SHOW_MOUSE:
if (!video_driver_poke)
return false;
{
bool *toggle = (bool*)data;
if (video_driver_poke->show_mouse)
video_driver_poke->show_mouse(video_driver_data, *toggle);
}
if (video_driver_poke->show_mouse)
video_driver_poke->show_mouse(video_driver_data, true);
break;
case RARCH_DISPLAY_CTL_HIDE_MOUSE:
if (!video_driver_poke)
return false;
if (video_driver_poke->show_mouse)
video_driver_poke->show_mouse(video_driver_data, false);
break;
case RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE:
{

View File

@ -136,6 +136,7 @@ enum rarch_display_ctl_state
RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB,
RARCH_DISPLAY_CTL_CACHED_FRAME_SET_PTR,
RARCH_DISPLAY_CTL_SHOW_MOUSE,
RARCH_DISPLAY_CTL_HIDE_MOUSE,
RARCH_DISPLAY_CTL_GET_FRAME_COUNT,
RARCH_DISPLAY_CTL_SET_OWN_DRIVER,
RARCH_DISPLAY_CTL_UNSET_OWN_DRIVER,

View File

@ -836,13 +836,16 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
#endif
break;
case RARCH_INPUT_CTL_GRAB_MOUSE:
{
bool *bool_data = (bool*)data;
if (!current_input || !current_input->grab_mouse)
return false;
if (!current_input || !current_input->grab_mouse)
return false;
current_input->grab_mouse(current_input_data, *bool_data);
}
current_input->grab_mouse(current_input_data, true);
break;
case RARCH_INPUT_CTL_UNGRAB_MOUSE:
if (!current_input || !current_input->grab_mouse)
return false;
current_input->grab_mouse(current_input_data, false);
break;
case RARCH_INPUT_CTL_IS_DATA_PTR_SAME:
return (current_input_data == data);

View File

@ -84,6 +84,7 @@ enum rarch_input_ctl_state
RARCH_INPUT_CTL_REMOTE_DEINIT,
RARCH_INPUT_CTL_KEY_PRESSED,
RARCH_INPUT_CTL_GRAB_MOUSE,
RARCH_INPUT_CTL_UNGRAB_MOUSE,
RARCH_INPUT_CTL_IS_DATA_PTR_SAME
};