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.cpp39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/Support.cpp b/src/Support.cpp
index 33794d9..4703b14 100644
--- a/src/Support.cpp
+++ b/src/Support.cpp
@@ -6,7 +6,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include <SDL/SDL.h>
+#include <GLFW/glfw3.h>
 #include <vorbis/vorbisfile.h>
 
 #include "Support.h"
@@ -21,38 +21,23 @@ int Random()
 #endif
 }
 
-void Microseconds(UnsignedWide *microTickCount)
-{
-	/* NOTE: hi isn't used in BS, so it's not implemented here */
-	/* TODO: does game need microsecond precision? */
-	microTickCount->hi = 0;
-	microTickCount->lo = SDL_GetTicks() * 1000;
-}
-
 void GetMouse(Point *p)
 {
-	int x;
-	int y;
-
-	SDL_GetMouseState(&x, &y);
-
-	p->h = x;
-	p->v = y;
+	double xpos, ypos;
+	glfwGetCursorPos(glfwGetCurrentContext(), &xpos, &ypos);
+	p->h = xpos;
+	p->v = ypos;
 }
 
 void GetMouseRel(Point *p)
 {
-	int x;
-	int y;
-
-	SDL_GetRelativeMouseState(&x, &y);
-
-	p->h = x;
-	p->v = y;
+	return GetMouse(p);
 }
+
 int Button(void)
 {
-	return (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1));
+	auto window = glfwGetCurrentContext();
+	return glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS;
 }
 
 void MoveMouse(int xcoord, int ycoord, Point *mouseloc)
@@ -61,6 +46,12 @@ void MoveMouse(int xcoord, int ycoord, Point *mouseloc)
 	GetMouse(mouseloc);
 }
 
+bool IsKeyDown(int key)
+{
+	auto window = glfwGetCurrentContext();
+	return glfwGetKey(window, key) == GLFW_PRESS;
+}
+
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif