mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-25 02:00:30 +01:00
Add setRelativeMode for SDL driver (#123)
This commit is contained in:
parent
a0af653c3d
commit
a549d0bfed
@ -160,6 +160,9 @@ namespace gui
|
|||||||
\param rect: A pointer to an reference rectangle or 0 to disable the reference rectangle.*/
|
\param rect: A pointer to an reference rectangle or 0 to disable the reference rectangle.*/
|
||||||
virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
|
virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
|
||||||
|
|
||||||
|
//! Internally fixes the mouse position, and reports relative mouse movement compared to the old position
|
||||||
|
/** Specific to SDL */
|
||||||
|
virtual void setRelativeMode(bool relative) {};
|
||||||
|
|
||||||
//! Sets the active cursor icon
|
//! Sets the active cursor icon
|
||||||
/** Setting cursor icons is so far only supported on Win32 and Linux */
|
/** Setting cursor icons is so far only supported on Win32 and Linux */
|
||||||
|
@ -146,6 +146,12 @@ namespace irr
|
|||||||
void setPosition(s32 x, s32 y) override
|
void setPosition(s32 x, s32 y) override
|
||||||
{
|
{
|
||||||
SDL_WarpMouseInWindow(Device->Window, x, y);
|
SDL_WarpMouseInWindow(Device->Window, x, y);
|
||||||
|
|
||||||
|
if (SDL_GetRelativeMouseMode()) {
|
||||||
|
// There won't be an event for this warp (details on libsdl-org/SDL/issues/6034)
|
||||||
|
Device->MouseX = x;
|
||||||
|
Device->MouseY = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the current position of the mouse cursor.
|
//! Returns the current position of the mouse cursor.
|
||||||
@ -169,6 +175,17 @@ namespace irr
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void setRelativeMode(bool relative) _IRR_OVERRIDE_
|
||||||
|
{
|
||||||
|
// Only change it when necessary, as it flushes mouse motion when enabled
|
||||||
|
if ( relative != SDL_GetRelativeMouseMode()) {
|
||||||
|
if ( relative )
|
||||||
|
SDL_SetRelativeMouseMode( SDL_TRUE );
|
||||||
|
else
|
||||||
|
SDL_SetRelativeMouseMode( SDL_FALSE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void updateCursorPos()
|
void updateCursorPos()
|
||||||
|
Loading…
Reference in New Issue
Block a user