-
Notifications
You must be signed in to change notification settings - Fork 526
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
Gamepad API #393
base: master
Are you sure you want to change the base?
Gamepad API #393
Conversation
This looks great! Really well done. Can’t wait to give it a go. |
Hi, I've successfully incorporated your proposed API into my app, but I had to make a few additions to match my use case, which requires detecting whether or not a controller is connected. I've submitted a PR here: Aftnet#1 |
Darn, was hoping this was something that I could use, but the windows version seems to rely on xinput, which disallows you to use gamepads that aren't xbox controllers. |
I've been looking at this dinput implementation, but haven't had time to move forward yet. https://github.com/Kode/Kinc/blob/d153bf0642e7d56b1fa056f01005e979f0ce6267/Backends/System/Windows/Sources/kinc/backend/system.cpp My current implementation is here - https://github.com/meshula/LabCamera/blob/main/examples/Navigator/sokol_gamepad.h - it's moved forward compared to the OP, but hasn't got dinput yet. |
I've found out that XInput is the best simple approach, which allows just Xbox Controllers to work, and controllers that act like those. But I've also been looking at Raw Input, which is what seems to be what the web Gamepad API is based on. I've come across a couple of issues while investigating this myself. :
|
Not sure if it's useful for the discussion, but in Oryol I had a mapping layer over the gamepad input because axis and button indices are not standardized in some APIs. The mapping layer is basically a dictionary of device id strings (or some sort of string pattern?) which maps raw axis and button indices to "semantic" names. Oryol came with builtin mappings for Xbox and PS4 controllers but user code could add additional mappings: https://github.com/floooh/oryol/tree/master/code/Modules/Input#gamepad-input (the Windows side also simply used XInput though, IFIR I had ripped the code from GLFW) |
Proposal for a sokol gamepad API
@floooh sorry it took this long to get back to you. This is the gamepad API I made and have been using.
The only annoyance is that Android only handles input via events and I had to hook into sokol_app to get it working there - for the other platforms this is standalone.
I kept changes to sokol_app as minimal as I could to get things working.