PS4 Controller axis behaving differently

Hello, I’m writing 2 GLFW programs that are supposed to behave exactly the same.
One program is in C, the other one is in Go.
On these 2 programs, the binding for my PS4 Controller is not doing the same thing.
I’m testing both programs on the same laptop, Mac OSX arm64.
I’m testing both programs with the exact same controller connected in Bluetooth.
Both programs are using GLFW 7482de6071d21db77a7236155da44c172a7f6c9e (tag 3.3.8)
Both programs are using the same SDL_GameControllerDB.

Yet, axes[GLFW_GAMEPAD_AXIS_RIGHT_Y] reports wrong values in the C version.
Also, glfwGetJoystickName is not reporting the same name in the C version.

In the Go program:

  • the mappings are here ludo/mappings.go at master · libretro/ludo · GitHub
  • glfwGetJoystickName returns “PS4 Controller”
  • GUID is 030000004c050000c405000000010000
  • glfwJoystickPresent returns true
  • This axis behaves correctly: GLFW_GAMEPAD_AXIS_RIGHT_Y value is 0, and varies between -1 and 1 when I move it.

In the C program:

Do you have any idea of what could be causing this difference in glfwGetJoystickName and mapping?

Have you tried the joysticks.c test included with the GLFW source with the default mappings and modified to load your own?

030000004c050000c405000000010000 refers to a “PS4 Controller” in both mappings you link to, as does the default GLFW mapping.

I presume you’ve checked that you are using the same mappings. If you are getting differences they are either being loaded differently or referenced differently so debugging glfwUpdateGamepadMappings to check their loading (or adding printf’s to the source code).

I think the name from glfwGetJoystickName doesn’t use a mapping name but instead uses a system provided name, but the name from glfwGetGamepadName does. Is it possible Go is calling the glfwGetGamepadName function rather than glfwGetJoystickName?

I found what was causing the difference in behaviour.

I was using glfwGetJoystickAxes which returns the values for the axes at the kernel level.

I had to use pad.axes from glfwGetGamepadState(port, &pad) instead, this will return the value of the axes post mapping.

And you were right about glfwGetJoystickName vs glfwGetGamepadName. Thanks for the help.

Excellent, glad you have resolved this.