mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-27 18:55:50 +00:00
GLFW: Implemented EmuWindow touchpad support.
This commit is contained in:
parent
543232436f
commit
dd73217ae3
|
@ -16,6 +16,26 @@ EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) {
|
||||||
return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(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
|
/// Called by GLFW when a key event occurs
|
||||||
void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) {
|
void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) {
|
||||||
|
|
||||||
|
@ -88,6 +108,8 @@ EmuWindow_GLFW::EmuWindow_GLFW() {
|
||||||
|
|
||||||
// Setup callbacks
|
// Setup callbacks
|
||||||
glfwSetKeyCallback(m_render_window, OnKeyEvent);
|
glfwSetKeyCallback(m_render_window, OnKeyEvent);
|
||||||
|
glfwSetMouseButtonCallback(m_render_window, OnMouseButtonEvent);
|
||||||
|
glfwSetCursorPosCallback(m_render_window, OnCursorPosEvent);
|
||||||
glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent);
|
glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent);
|
||||||
glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent);
|
glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ public:
|
||||||
|
|
||||||
static void OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods);
|
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
|
/// Whether the window is still open, and a close request hasn't yet been sent
|
||||||
const bool IsOpen();
|
const bool IsOpen();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue