Commits

criptych committed 531ad77

added love.mouse.getRelativePosition

  • Participants
  • Parent commits 0c3e703

Comments (0)

Files changed (5)

File src/modules/mouse/Mouse.h

 	virtual int getX() const = 0;
 	virtual int getY() const = 0;
 	virtual void getPosition(int &x, int &y) const = 0;
+	virtual void getRelativePosition(int &x, int &y) const = 0;
 	virtual void setX(int x) = 0;
 	virtual void setY(int y) = 0;
 	virtual void setPosition(int x, int y) = 0;

File src/modules/mouse/sdl/Mouse.cpp

 	SDL_GetMouseState(&x, &y);
 }
 
+void Mouse::getRelativePosition(int &x, int &y) const
+{
+	SDL_GetRelativeMouseState(&x, &y);
+}
+
 void Mouse::setPosition(int x, int y)
 {
 	SDL_WarpMouse(x, y);

File src/modules/mouse/sdl/Mouse.h

 	int getX() const;
 	int getY() const;
 	void getPosition(int &x, int &y) const;
+	void getRelativePosition(int &x, int &y) const;
 	void setX(int x);
 	void setY(int y);
 	void setPosition(int x, int y);

File src/modules/mouse/wrap_Mouse.cpp

 	return 2;
 }
 
+int w_getRelativePosition(lua_State *L)
+{
+	int x, y;
+	instance->getRelativePosition(x, y);
+	lua_pushinteger(L, x);
+	lua_pushinteger(L, y);
+	return 2;
+}
+
 int w_setX(lua_State *L)
 {
 	int x = luaL_checkint(L, 1);
 	{ "setVisible", w_setVisible },
 	{ "isVisible", w_isVisible },
 	{ "getPosition", w_getPosition },
+	{ "getRelativePosition", w_getRelativePosition },
 	{ "setGrab", w_setGrab },
 	{ "isGrabbed", w_isGrabbed },
 	{ 0, 0 }

File src/modules/mouse/wrap_Mouse.h

 int w_getX(lua_State *L);
 int w_getY(lua_State *L);
 int w_getPosition(lua_State *L);
+int w_getRelativePosition(lua_State *L);
 int w_setX(lua_State *L);
 int w_setY(lua_State *L);
 int w_setPosition(lua_State *L);