mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +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:
@@ -179,6 +179,19 @@ int w_isGrabbed(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_setRelative(lua_State *L)
|
||||
{
|
||||
bool relative = luax_toboolean(L, 1);
|
||||
luax_pushboolean(L, instance()->setRelative(relative));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_isRelative(lua_State *L)
|
||||
{
|
||||
luax_pushboolean(L, instance()->isRelative());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] =
|
||||
{
|
||||
@@ -197,6 +210,8 @@ static const luaL_Reg functions[] =
|
||||
{ "getPosition", w_getPosition },
|
||||
{ "setGrabbed", w_setGrabbed },
|
||||
{ "isGrabbed", w_isGrabbed },
|
||||
{ "setRelative", w_setRelative },
|
||||
{ "isRelative", w_isRelative },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user