summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2015-03-08 03:19:33 -0400
committerGravatar bunnei2015-03-10 18:05:18 -0400
commitdd73217ae388a74f0c4d000ef52edd0f2b7fa64c (patch)
tree2702f3504baf5dedb892ca6f93e77bd69c8657e7 /src
parentEmuWindow: Added infrastructure code to enable touchpad support. (diff)
downloadyuzu-dd73217ae388a74f0c4d000ef52edd0f2b7fa64c.tar.gz
yuzu-dd73217ae388a74f0c4d000ef52edd0f2b7fa64c.tar.xz
yuzu-dd73217ae388a74f0c4d000ef52edd0f2b7fa64c.zip
GLFW: Implemented EmuWindow touchpad support.
Diffstat (limited to 'src')
-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 81231e1e5..8a0cd9b5a 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) {
16 return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win)); 16 return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win));
17} 17}
18 18
19void EmuWindow_GLFW::OnMouseButtonEvent(GLFWwindow* window, int button, int action, int mods) {
20 if (button == GLFW_MOUSE_BUTTON_LEFT) {
21 auto layout = GetEmuWindow(window)->GetFramebufferLayout();
22 double x, y;
23 glfwGetCursorPos(window, &x, &y);
24
25 if (action == GLFW_PRESS) {
26 EmuWindow::TouchPressed(layout, static_cast<u16>(x), static_cast<u16>(y));
27 } else if (action == GLFW_RELEASE) {
28 EmuWindow::TouchReleased(layout, static_cast<u16>(x), static_cast<u16>(y));
29 }
30 }
31}
32
33void EmuWindow_GLFW::OnCursorPosEvent(GLFWwindow* window, double x, double y) {
34
35 auto layout = GetEmuWindow(window)->GetFramebufferLayout();
36 EmuWindow::TouchMoved(layout, static_cast<u16>(x), static_cast<u16>(y));
37}
38
19/// Called by GLFW when a key event occurs 39/// Called by GLFW when a key event occurs
20void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) { 40void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) {
21 41
@@ -88,6 +108,8 @@ EmuWindow_GLFW::EmuWindow_GLFW() {
88 108
89 // Setup callbacks 109 // Setup callbacks
90 glfwSetKeyCallback(m_render_window, OnKeyEvent); 110 glfwSetKeyCallback(m_render_window, OnKeyEvent);
111 glfwSetMouseButtonCallback(m_render_window, OnMouseButtonEvent);
112 glfwSetCursorPosCallback(m_render_window, OnCursorPosEvent);
91 glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent); 113 glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent);
92 glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent); 114 glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent);
93 115
diff --git a/src/citra/emu_window/emu_window_glfw.h b/src/citra/emu_window/emu_window_glfw.h
index 5252fccc8..16c109b79 100644
--- a/src/citra/emu_window/emu_window_glfw.h
+++ b/src/citra/emu_window/emu_window_glfw.h
@@ -27,6 +27,10 @@ public:
27 27
28 static void OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods); 28 static void OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods);
29 29
30 static void OnMouseButtonEvent(GLFWwindow* window, int button, int action, int mods);
31
32 static void OnCursorPosEvent(GLFWwindow* window, double x, double y);
33
30 /// Whether the window is still open, and a close request hasn't yet been sent 34 /// Whether the window is still open, and a close request hasn't yet been sent
31 const bool IsOpen(); 35 const bool IsOpen();
32 36