summary refs log tree commit diff
path: root/src/Support.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Support.cpp')
-rw-r--r--src/Support.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Support.cpp b/src/Support.cpp
index 4703b14..a233dd7 100644
--- a/src/Support.cpp
+++ b/src/Support.cpp
@@ -25,30 +25,33 @@ void GetMouse(Point *p)
 {
 	double xpos, ypos;
 	glfwGetCursorPos(glfwGetCurrentContext(), &xpos, &ypos);
-	p->h = xpos;
-	p->v = ypos;
+	p->h = floor(xpos);
+	p->v = floor(ypos);
 }
 
 void GetMouseRel(Point *p)
 {
-	return GetMouse(p);
+	const auto window = glfwGetCurrentContext();
+	glfwGetWindowSize(window, &p->h, &p->v);
+	p->h /= 2;
+	p->v /= 2;
+
+	double xpos, ypos;
+	glfwGetCursorPos(window, &xpos, &ypos);
+	glfwSetCursorPos(window, p->h, p->v); // we shouldn't need this
+	p->h = floor(xpos) - p->h;
+	p->v = floor(ypos) - p->v;
 }
 
 int Button(void)
 {
-	auto window = glfwGetCurrentContext();
+	const auto window = glfwGetCurrentContext();
 	return glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS;
 }
 
-void MoveMouse(int xcoord, int ycoord, Point *mouseloc)
-{
-	/* TODO: mouse warp is annoying when we can just grab the mouse */
-	GetMouse(mouseloc);
-}
-
 bool IsKeyDown(int key)
 {
-	auto window = glfwGetCurrentContext();
+	const auto window = glfwGetCurrentContext();
 	return glfwGetKey(window, key) == GLFW_PRESS;
 }