aboutsummaryrefslogtreecommitdiff
path: root/src/glfw/window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/glfw/window.cc')
-rw-r--r--src/glfw/window.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/glfw/window.cc b/src/glfw/window.cc
index 9e76b57..98890b7 100644
--- a/src/glfw/window.cc
+++ b/src/glfw/window.cc
@@ -37,6 +37,19 @@ int Window::getHeight() const {
return _height;
}
-KeyWatcher Window::getKeyWatcher(int key) {
+std::tuple<bool,int,int> Window::getMouse() const {
+ const bool clicked = glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS;
+
+ double x, y;
+ glfwGetCursorPos(_handle, &x, &y);
+
+ return std::make_tuple(
+ clicked,
+ x - int(getWidth()/2),
+ int(getHeight()/2 - y)
+ );
+}
+
+KeyWatcher Window::getKeyWatcher(int key) const {
return KeyWatcher(_handle, key);
}