aboutsummaryrefslogtreecommitdiff
path: root/src/glfw
diff options
context:
space:
mode:
Diffstat (limited to 'src/glfw')
-rw-r--r--src/glfw/window.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/glfw/window.cc b/src/glfw/window.cc
index 4f14501..c0074ad 100644
--- a/src/glfw/window.cc
+++ b/src/glfw/window.cc
@@ -38,21 +38,20 @@ int Window::getHeight() const {
}
std::tuple<int,int,int> Window::getMouse() const {
- int state = 0;
+ double x, y;
+ glfwGetCursorPos(_handle, &x, &y);
+ x = int(x - getWidth()/2);
+ y = int(getHeight()/2 - y);
+
if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS ) {
- state = 1;
- } else if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS ) {
- state = 2;
+ return std::make_tuple(1, x, y);
}
- double x, y;
- glfwGetCursorPos(_handle, &x, &y);
+ if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS ) {
+ return std::make_tuple(2, x, y);
+ }
- return std::make_tuple(
- state,
- x - int(getWidth()/2),
- int(getHeight()/2 - y)
- );
+ return std::make_tuple(0, x, y);
}
KeyWatcher Window::getKeyWatcher(int key) const {