Support relative mouse mode

This commit is contained in:
Nikita Lisitsa 2020-09-27 20:43:17 +03:00
parent e73da04a31
commit 9cf5a88afd
2 changed files with 3 additions and 2 deletions

View file

@ -16,7 +16,7 @@ namespace psemek::app
virtual void on_focus_gained() {} virtual void on_focus_gained() {}
virtual void on_focus_lost() {} virtual void on_focus_lost() {}
virtual void on_mouse_move(int /* x */, int /* y */) {} virtual void on_mouse_move(int /* x */, int /* y */, int /* dx */, int /* dy */) {}
virtual void on_mouse_wheel(int /* delta */) {} virtual void on_mouse_wheel(int /* delta */) {}
virtual void on_left_button_down() {} virtual void on_left_button_down() {}
virtual void on_left_button_up() {} virtual void on_left_button_up() {}

View file

@ -140,7 +140,7 @@ namespace psemek::app
} }
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
handler->on_mouse_move(e.motion.x, e.motion.y); handler->on_mouse_move(e.motion.x, e.motion.y, e.motion.xrel, e.motion.yrel);
break; break;
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
handler->on_mouse_wheel(e.wheel.y); handler->on_mouse_wheel(e.wheel.y);
@ -229,6 +229,7 @@ namespace psemek::app
void app::show_cursor(bool show) void app::show_cursor(bool show)
{ {
SDL_ShowCursor(show ? SDL_TRUE : SDL_FALSE); SDL_ShowCursor(show ? SDL_TRUE : SDL_FALSE);
SDL_SetRelativeMouseMode(show ? SDL_FALSE : SDL_TRUE);
} }
float app::time() const float app::time() const