From 7ae851a0b8b8a1cbf4dfbb570a30904128ab5a82 Mon Sep 17 00:00:00 2001 From: Vanessa Karolek <vaka1997@uni-koblenz.de> Date: Wed, 16 Jun 2021 23:17:20 +0200 Subject: [PATCH] [#60] use glfw pointer function to retrieve window --- src/vkcv/Window.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vkcv/Window.cpp b/src/vkcv/Window.cpp index 70cfb153..d29dd94a 100644 --- a/src/vkcv/Window.cpp +++ b/src/vkcv/Window.cpp @@ -55,11 +55,12 @@ namespace vkcv { glfwSetScrollCallback(m_window, Window::onMouseScrollEvent); + glfwSetJoystickCallback(nullptr); // use this before to avoid crashing glfwSetJoystickUserPointer(GLFW_JOYSTICK_1, this); } void Window::pollEvents() { - onGamepadEvent(GLFW_JOYSTICK_1, this); + onGamepadEvent(GLFW_JOYSTICK_1); glfwPollEvents(); } @@ -103,7 +104,8 @@ namespace vkcv { } } - void Window::onGamepadEvent(int gamepadIndex, Window *window) { + void Window::onGamepadEvent(int gamepadIndex) { + auto window = static_cast<Window *>(glfwGetJoystickUserPointer(gamepadIndex)); if (glfwJoystickPresent(gamepadIndex)) { window->e_gamepad(gamepadIndex); } -- GitLab