Skip to content
Snippets Groups Projects
Commit 7ae851a0 authored by Vanessa Karolek's avatar Vanessa Karolek
Browse files

[#60] use glfw pointer function to retrieve window

parent 0bc5fc2f
No related branches found
No related tags found
1 merge request!65Resolve "Kamera - Steuerung mittels Controller"
Pipeline #25799 passed
...@@ -55,11 +55,12 @@ namespace vkcv { ...@@ -55,11 +55,12 @@ namespace vkcv {
glfwSetScrollCallback(m_window, Window::onMouseScrollEvent); glfwSetScrollCallback(m_window, Window::onMouseScrollEvent);
glfwSetJoystickCallback(nullptr); // use this before to avoid crashing
glfwSetJoystickUserPointer(GLFW_JOYSTICK_1, this); glfwSetJoystickUserPointer(GLFW_JOYSTICK_1, this);
} }
void Window::pollEvents() { void Window::pollEvents() {
onGamepadEvent(GLFW_JOYSTICK_1, this); onGamepadEvent(GLFW_JOYSTICK_1);
glfwPollEvents(); glfwPollEvents();
} }
...@@ -103,7 +104,8 @@ namespace vkcv { ...@@ -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)) { if (glfwJoystickPresent(gamepadIndex)) {
window->e_gamepad(gamepadIndex); window->e_gamepad(gamepadIndex);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment