Skip to content
Snippets Groups Projects
Verified Commit 8962f2e5 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#60] Added support for multiple joysticks

parent 2baccb09
No related branches found
No related tags found
1 merge request!65Resolve "Kamera - Steuerung mittels Controller"
Pipeline #25999 passed
...@@ -81,7 +81,12 @@ namespace vkcv { ...@@ -81,7 +81,12 @@ namespace vkcv {
} }
glfwPollEvents(); glfwPollEvents();
onGamepadEvent(GLFW_JOYSTICK_1);
for (int gamepadIndex = GLFW_JOYSTICK_1; gamepadIndex <= GLFW_JOYSTICK_LAST; gamepadIndex++) {
if (glfwJoystickPresent(gamepadIndex)) {
onGamepadEvent(gamepadIndex);
}
}
for (auto glfwWindow : s_Windows) { for (auto glfwWindow : s_Windows) {
auto window = static_cast<Window *>(glfwGetWindowUserPointer(glfwWindow)); auto window = static_cast<Window *>(glfwGetWindowUserPointer(glfwWindow));
...@@ -152,7 +157,7 @@ namespace vkcv { ...@@ -152,7 +157,7 @@ namespace vkcv {
activeWindowIndex *= (activeWindowIndex < s_Windows.size()); // fixes index getting out of bounds (e.g. if there is no focused window) activeWindowIndex *= (activeWindowIndex < s_Windows.size()); // fixes index getting out of bounds (e.g. if there is no focused window)
auto window = static_cast<Window *>(glfwGetWindowUserPointer(s_Windows[activeWindowIndex])); auto window = static_cast<Window *>(glfwGetWindowUserPointer(s_Windows[activeWindowIndex]));
if (window != nullptr && glfwJoystickPresent(gamepadIndex)) { if (window != nullptr) {
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