aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/citra
diff options
context:
space:
mode:
authorGravatar bunnei <bunneidev@gmail.com>2015-03-08 03:19:33 -0400
committerGravatar bunnei <bunneidev@gmail.com>2015-03-10 18:05:18 -0400
commitdd73217ae388a74f0c4d000ef52edd0f2b7fa64c (patch)
tree2702f3504baf5dedb892ca6f93e77bd69c8657e7 /src/citra
parent543232436fae8d1d0f9fdd94baf0ca88d4eea067 (diff)
GLFW: Implemented EmuWindow touchpad support.
Diffstat (limited to 'src/citra')
-rw-r--r--src/citra/emu_window/emu_window_glfw.cpp22
-rw-r--r--src/citra/emu_window/emu_window_glfw.h4
2 files changed, 26 insertions, 0 deletions
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp
index 81231e1e..8a0cd9b5 100644
--- a/src/citra/emu_window/emu_window_glfw.cpp
+++ b/src/citra/emu_window/emu_window_glfw.cpp
@@ -16,6 +16,26 @@ EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) {
return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win));
}
+void EmuWindow_GLFW::OnMouseButtonEvent(GLFWwindow* window, int button, int action, int mods) {
+ if (button == GLFW_MOUSE_BUTTON_LEFT) {
+ auto layout = GetEmuWindow(window)->GetFramebufferLayout();
+ double x, y;
+ glfwGetCursorPos(window, &x, &y);
+
+ if (action == GLFW_PRESS) {
+ EmuWindow::TouchPressed(layout, static_cast<u16>(x), static_cast<u16>(y));
+ } else if (action == GLFW_RELEASE) {
+ EmuWindow::TouchReleased(layout, static_cast<u16>(x), static_cast<u16>(y));
+ }
+ }
+}
+
+void EmuWindow_GLFW::OnCursorPosEvent(GLFWwindow* window, double x, double y) {
+
+ auto layout = GetEmuWindow(window)->GetFramebufferLayout();
+ EmuWindow::TouchMoved(layout, static_cast<u16>(x), static_cast<u16>(y));
+}
+
/// Called by GLFW when a key event occurs
void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) {
@@ -88,6 +108,8 @@ EmuWindow_GLFW::EmuWindow_GLFW() {
// Setup callbacks
glfwSetKeyCallback(m_render_window, OnKeyEvent);
+ glfwSetMouseButtonCallback(m_render_window, OnMouseButtonEvent);
+ glfwSetCursorPosCallback(m_render_window, OnCursorPosEvent);
glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent);
glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent);
diff --git a/src/citra/emu_window/emu_window_glfw.h b/src/citra/emu_window/emu_window_glfw.h
index 5252fccc..16c109b7 100644
--- a/src/citra/emu_window/emu_window_glfw.h
+++ b/src/citra/emu_window/emu_window_glfw.h
@@ -27,6 +27,10 @@ public:
static void OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods);
+ static void OnMouseButtonEvent(GLFWwindow* window, int button, int action, int mods);
+
+ static void OnCursorPosEvent(GLFWwindow* window, double x, double y);
+
/// Whether the window is still open, and a close request hasn't yet been sent
const bool IsOpen();