static void HandleMouseEvent(MirPointerEvent const* pointer, SDL_Window* sdl_window) { SDL_SetMouseFocus(sdl_window); switch (MIR_mir_pointer_event_action(pointer)) { case mir_pointer_action_button_down: HandleMouseButton(sdl_window, SDL_PRESSED, pointer); break; case mir_pointer_action_button_up: HandleMouseButton(sdl_window, SDL_RELEASED, pointer); break; case mir_pointer_action_motion: { int x, y; int hscroll, vscroll; SDL_Mouse* mouse = SDL_GetMouse(); x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x); y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y); if (mouse) { if (mouse->relative_mode) { int relative_x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_x); int relative_y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_y); HandleMouseMotion(sdl_window, relative_x, relative_y); } else if (mouse->x != x || mouse->y != y) { HandleMouseMotion(sdl_window, x, y); } } hscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_hscroll); vscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_vscroll); if (vscroll != 0 || hscroll != 0) HandleMouseScroll(sdl_window, hscroll, vscroll); } break; case mir_pointer_action_leave: SDL_SetMouseFocus(NULL); break; case mir_pointer_action_enter: default: break; } }
static void HandleMouseEvent(MirMotionEvent const motion, int cord_index, SDL_Window* sdl_window) { SDL_SetMouseFocus(sdl_window); switch (motion.action) { case mir_motion_action_down: case mir_motion_action_pointer_down: HandleMouseButton(sdl_window, SDL_PRESSED, motion.button_state); break; case mir_motion_action_up: case mir_motion_action_pointer_up: HandleMouseButton(sdl_window, SDL_RELEASED, motion.button_state); break; case mir_motion_action_hover_move: case mir_motion_action_move: HandleMouseMotion(sdl_window, motion.pointer_coordinates[cord_index].x, motion.pointer_coordinates[cord_index].y); break; case mir_motion_action_outside: SDL_SetMouseFocus(NULL); break; case mir_motion_action_scroll: HandleMouseScroll(sdl_window, motion.pointer_coordinates[cord_index].hscroll, motion.pointer_coordinates[cord_index].vscroll); break; case mir_motion_action_cancel: case mir_motion_action_hover_enter: case mir_motion_action_hover_exit: break; default: break; } }
void MGLInput::MouseScrollCallBack(GLFWwindow* window, GLdouble xOffset, GLdouble yOffset) { static auto game = static_cast<MGLInput*>(glfwGetWindowUserPointer(window)); game->HandleMouseScroll(xOffset, yOffset); }