Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller issue on GLFW's end #43

Open
Kouros26 opened this issue Aug 9, 2023 · 13 comments
Open

Controller issue on GLFW's end #43

Kouros26 opened this issue Aug 9, 2023 · 13 comments
Assignees
Labels
Bug: Needs Replicating This bug needs reproducing, as only one person has reported it.
Milestone

Comments

@Kouros26
Copy link
Collaborator

Kouros26 commented Aug 9, 2023

The issue still persists, I used a hack to counter the problem for the time being but it's definitely suboptimal (erased the existence of the back button).

@Kouros26 Kouros26 added the Issue: Bug The issue is a bug report. label Aug 9, 2023
@Rinzii
Copy link
Owner

Rinzii commented Aug 10, 2023

We can of course patch this issue on our end and make a PR on the upstream since we are building from source. Have you been able to identify where the bug originates from? Also could you provide steps on how the bug is produced? Also can you detail exactly what the bug is?

@Kouros26
Copy link
Collaborator Author

Kouros26 commented Aug 10, 2023

Yes so basically you've got all those defines in glfw3.h :

#define GLFW_GAMEPAD_BUTTON_A 0
#define GLFW_GAMEPAD_BUTTON_B 1
#define GLFW_GAMEPAD_BUTTON_X 2
#define GLFW_GAMEPAD_BUTTON_Y 3
#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
#define GLFW_GAMEPAD_BUTTON_BACK 6
#define GLFW_GAMEPAD_BUTTON_START 7
#define GLFW_GAMEPAD_BUTTON_GUIDE 8
#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT

But the back button doesn't exist on my controllers (Xbox) and also on any modern console controller if I'm not mistaken. But glfw doesn't take the fact that I don't have a back button into consideration so the next button on the list (here start) that should normally get defined as 7, gets defined as 6, guide gets defined as 7 instead of 8 and so on until the end of the list.

@karnkaul
Copy link
Collaborator

karnkaul commented Aug 11, 2023

As a data point, this is the controller I have:
image

And GLFW gives me the correct mappings in my engine. (The "back" button is the one with the two rectangles.) Note that I don't bother with the joystick API at all, and only use GLFW gamepads.

recording-2023-08-10_20.24.21.mp4

Sequence: A, B, X, Y, Start, Back, Left Button, Right Button, Left Thumb, Right Thumb.

@Rinzii Rinzii added this to the MVP milestone Aug 11, 2023
@Rinzii
Copy link
Owner

Rinzii commented Aug 11, 2023

@Kouros26 Could you also detail exactly what kind of controller you have? Xbox 360? Xbox One? Xbox Pro?

@Rinzii
Copy link
Owner

Rinzii commented Aug 11, 2023

Yes so basically you've got all those defines in glfw3.h :

#define GLFW_GAMEPAD_BUTTON_A 0 #define GLFW_GAMEPAD_BUTTON_B 1 #define GLFW_GAMEPAD_BUTTON_X 2 #define GLFW_GAMEPAD_BUTTON_Y 3 #define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4 #define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5 #define GLFW_GAMEPAD_BUTTON_BACK 6 #define GLFW_GAMEPAD_BUTTON_START 7 #define GLFW_GAMEPAD_BUTTON_GUIDE 8 #define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9 #define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10 #define GLFW_GAMEPAD_BUTTON_DPAD_UP 11 #define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12 #define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13 #define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14 #define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT

But the back button doesn't exist on my controllers (Xbox) and also on any modern console controller if I'm not mistaken. But glfw doesn't take the fact that I don't have a back button into consideration so the next button on the list (here start) that should normally get defined as 7, gets defined as 6, guide gets defined as 7 instead of 8 and so on until the end of the list.

Also could you detail where this code is located inside of glfw? And can you also detail in your own branch where the issue is arising?

@Rinzii
Copy link
Owner

Rinzii commented Aug 11, 2023

Also can you provide your system specs along with OS version.

@Rinzii
Copy link
Owner

Rinzii commented Aug 11, 2023

I will also try to reproduce the bug sometime this week to see if this is a reproducible issue.

@Kouros26
Copy link
Collaborator Author

Exact same as the one he showed (I think it's an Xbox One X controller) and I got another Xbox Series X controller. So @karnkaul if I understand correctly you don't use the defines I showed earlier ? If not then I might just stop using them, they're probably what's causing the issue

@Kouros26
Copy link
Collaborator Author

Also could you detail where this code is located inside of glfw? And can you also detail in your own branch where the issue is arising?

Yes I'm going to setup a branch with some tests on it so you can see the issue for yourselves.
Intel® Core™ i7-9700KF CPU @ 3.60GHz
NVIDIA GeForce RTX 3080
32GB RAM (DDR4 I think)

Microsoft Windows 10 Professionnal (64 bits) Version (Build) 22H2 (10.0.19045)

@karnkaul
Copy link
Collaborator

karnkaul commented Aug 11, 2023

... if I understand correctly you don't use the defines I showed earlier ? If not then I might just stop using them, they're probably what's causing the issue

I do use them, but I don't know if/how GLFW treats them differently in the joystick vs gamepad APIs. IIRC the joystick API is more low level, and the buttons and axes are in the order presented by the OS. The gamepad API remaps those raw inputs to named buttons and axes, if available in the DB. I'll link the docs around this:
https://www.glfw.org/docs/3.3/input_guide.html#gamepad

(Emphasis added)

The joystick functions provide unlabeled axes, buttons and hats, with no indication of where they are located on the device. Their order may also vary between platforms even with the same device.

To solve this problem the SDL community crowdsourced the SDL_GameControllerDB project, a database of mappings from many different devices to an Xbox-like gamepad.

GLFW supports this mapping format and contains a copy of the mappings available at the time of release.

@Kouros26
Copy link
Collaborator Author

Ok I see, I remember messing with that but something wasn't right, I'll take another look at it tomorrow, might resolve the problem, thanks

@Rinzii
Copy link
Owner

Rinzii commented Aug 27, 2023

Ok I see, I remember messing with that but something wasn't right, I'll take another look at it tomorrow, might resolve the problem, thanks

Any updates on this issue @Kouros26 ?

@Kouros26
Copy link
Collaborator Author

tested and researched some stuff but I didn't go further than that yet, I've had very little time to work on this project since I've started moving out

@Rinzii Rinzii added Bug: Needs Replicating This bug needs reproducing, as only one person has reported it. and removed Issue: Bug The issue is a bug report. labels Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Needs Replicating This bug needs reproducing, as only one person has reported it.
Projects
None yet
Development

No branches or pull requests

3 participants