From 858661fa7e0888eda1dbe1211c41212d92be3a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 16 Nov 2012 11:56:57 +0100 Subject: [PATCH] Sdl2Application: support for mouse locking. --- src/Platform/Sdl2Application.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Platform/Sdl2Application.h b/src/Platform/Sdl2Application.h index bc416956a..ba9e3a1fd 100644 --- a/src/Platform/Sdl2Application.h +++ b/src/Platform/Sdl2Application.h @@ -122,6 +122,22 @@ class Sdl2Application { /** @{ @name Mouse handling */ + /** @brief Whether mouse is locked */ + inline bool isMouseLocked() const { + return SDL_GetRelativeMouseMode(); + } + + /** + * @brief Enable or disable mouse locking + * + * When mouse is locked, the cursor is hidden and only + * MouseMoveEvent::relativePosition() is changing, absolute position + * stays the same. + */ + inline void setMouseLocked(bool enabled) { + SDL_SetRelativeMouseMode(enabled ? SDL_TRUE : SDL_FALSE); + } + /** * @brief Mouse press event *