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; break;
case EVENT_CMD_GRAB_MOUSE_TOGGLE: case EVENT_CMD_GRAB_MOUSE_TOGGLE:
{ {
bool ret = false;
static bool grab_mouse_state = false; static bool grab_mouse_state = false;
bool grab_mouse_state_tmp;
grab_mouse_state = !grab_mouse_state; grab_mouse_state = !grab_mouse_state;
if (!input_driver_ctl(RARCH_INPUT_CTL_GRAB_MOUSE, &grab_mouse_state)) if (grab_mouse_state)
return false; {
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", RARCH_LOG("%s: %s.\n",
msg_hash_to_str(MSG_GRAB_MOUSE_STATE), msg_hash_to_str(MSG_GRAB_MOUSE_STATE),
grab_mouse_state ? "yes" : "no"); grab_mouse_state ? "yes" : "no");
grab_mouse_state_tmp = !grab_mouse_state; if (!ret)
video_driver_ctl(RARCH_DISPLAY_CTL_SHOW_MOUSE, return false;
&grab_mouse_state_tmp);
} }
break; break;
case EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG: 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: case RARCH_DISPLAY_CTL_SHOW_MOUSE:
if (!video_driver_poke) if (!video_driver_poke)
return false; return false;
if (video_driver_poke->show_mouse)
{ video_driver_poke->show_mouse(video_driver_data, true);
bool *toggle = (bool*)data; break;
case RARCH_DISPLAY_CTL_HIDE_MOUSE:
if (video_driver_poke->show_mouse) if (!video_driver_poke)
video_driver_poke->show_mouse(video_driver_data, *toggle); return false;
} if (video_driver_poke->show_mouse)
video_driver_poke->show_mouse(video_driver_data, false);
break; break;
case RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE: 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_HAS_VALID_FB,
RARCH_DISPLAY_CTL_CACHED_FRAME_SET_PTR, RARCH_DISPLAY_CTL_CACHED_FRAME_SET_PTR,
RARCH_DISPLAY_CTL_SHOW_MOUSE, RARCH_DISPLAY_CTL_SHOW_MOUSE,
RARCH_DISPLAY_CTL_HIDE_MOUSE,
RARCH_DISPLAY_CTL_GET_FRAME_COUNT, RARCH_DISPLAY_CTL_GET_FRAME_COUNT,
RARCH_DISPLAY_CTL_SET_OWN_DRIVER, RARCH_DISPLAY_CTL_SET_OWN_DRIVER,
RARCH_DISPLAY_CTL_UNSET_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 #endif
break; break;
case RARCH_INPUT_CTL_GRAB_MOUSE: case RARCH_INPUT_CTL_GRAB_MOUSE:
{ if (!current_input || !current_input->grab_mouse)
bool *bool_data = (bool*)data; 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; break;
case RARCH_INPUT_CTL_IS_DATA_PTR_SAME: case RARCH_INPUT_CTL_IS_DATA_PTR_SAME:
return (current_input_data == data); return (current_input_data == data);

View File

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