mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Added new event callback love.mousemoved(x, y, xrel, yrel), where xrel and yrel are the amount of pixels moved since the last event. Added love.mouse.setRelative(bool relative) and love.mouse.isRelative. Resolves issue #470.
Enabling relative mouse mode will hide the cursor and let the system generate relative mouse move events while preventing the mouse from getting stuck at the edges of the screen (i.e. you can keep moving the mouse in one direction forever and the relative movement events will be generated accordingly.) The reported absolute mouse position is not updated while relative mode is enabled, even while relative movement events are generated.
This commit is contained in:
@@ -211,6 +211,16 @@ bool Mouse::isGrabbed() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Mouse::setRelative(bool relative)
|
||||
{
|
||||
return SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE) == 0;
|
||||
}
|
||||
|
||||
bool Mouse::isRelative() const
|
||||
{
|
||||
return SDL_GetRelativeMouseMode() != SDL_FALSE;
|
||||
}
|
||||
|
||||
} // sdl
|
||||
} // mouse
|
||||
} // love
|
||||
|
||||
@@ -64,6 +64,8 @@ public:
|
||||
bool isVisible() const;
|
||||
void setGrabbed(bool grab);
|
||||
bool isGrabbed() const;
|
||||
bool setRelative(bool relative);
|
||||
bool isRelative() const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user