raylib
raylib copied to clipboard
[rcore] Gamepad detected, input not detected (linux)
Hi Raysan, thank you for your time and Raylib.
- [x] I tested it on latest raylib version from master branch
- [x] I checked there is no similar issue already reported
- [x] I checked the documentation on the wiki
- [x] My code has no errors or misuse of raylib
Issue description
Gamepad is detected correctly, but no button presses or joystick movements are detected.
Environment
Arch Linux X11, OpenGL 4.6, Intel UHD Graphics 620
Issue Screenshot
Code Example
I discovered the issue in my project that uses Odin, so I tested in C.
I have tried with a fresh build of cloned master using the examples/core_input_gamepad binary.
I also tested GLFW by itself and can confirm the gamepad is working there, using this code:
In Odin:
package main
import "core:fmt"
import "vendor:glfw"
main :: proc() {
glfw.Init()
window := glfw.CreateWindow(640, 480, "GLFW Gamepad Test", nil, nil)
for !glfw.WindowShouldClose(window) {
if glfw.JoystickIsGamepad(0) {
fmt.println("Gamepad here")
}
button_states := glfw.GetJoystickButtons(0)
fmt.println(button_states)
glfw.SwapBuffers(window)
glfw.PollEvents()
}
}
In C, from glfw/master:
#include <stdio.h>
#include <GLFW/glfw3.h>
int main() {
glfwInit();
GLFWwindow *window = glfwCreateWindow(640, 480, "GLFW Gamepad Test", 0, 0);
while (!glfwWindowShouldClose(window)) {
if (glfwJoystickIsGamepad(0)) {
printf("Gamepad here\n");
}
int count = 0;
const unsigned char *button_states = glfwGetJoystickButtons(0, &count);
for (int i = 0; i < count; i += 1) {
printf("%d -> %d\n", i, button_states[i]);
}
glfwSwapBuffers(window);
glfwPollEvents();
}
return 0;
}
Gamepad does work for me on this page: https://www.raylib.com/examples/core/loader.html?name=core_input_gamepad
If there's anything I can do to help, please let me know.
Cheers, Dylan
@Falconerd Thanks for reporting, it seems it could be related to ARch Linux but I'm afraid I don't have a paltform configured to review it. If anyone could confirm if it works in other Linux distributions...
@Falconerd which gamepad are you using?
@Falconerd which gamepad are you using?
Xbox Elite 2
I have found some things I think are bugs with GLFW after some testing.
glfw.GetGamepadState does not update the current state of the gamepad
glfw.GetJoystickButtons does give the expected results
glfw.JoystickIsGamepad always returns false
I'm going to take this issue over to GLFW.
Cheers.
@Falconerd I have similar problems with my own controller I couldn't figure, I just used SDL for the inputs instead. You can use it alongside glfw if you're willing to call it specifically, or you can compile raylib to use it as a "backend". I did the former.
It seems the issue could be GLFW related, closing it.