From 6f6073be5de8c8598c4af7f38c90c3f83b5bf1bf Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 18 Dec 2018 21:08:20 +0100 Subject: Hacky mouse-based fluid interaction --- src/glfw/window.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/glfw/window.cc') 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 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); } -- cgit v1.2.3