-
-
Notifications
You must be signed in to change notification settings - Fork 477
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/joystick support #151
Comments
Gamepads/joysticks support is definitely something we want. However I don't think the SDL2 mapping format should be part of glutin. It can easily be added later by writing a |
I need this. I'm going to work on this in the next few days for Linux/Windows/Mac (in that order). |
This is quickly turning into more a nightmare than I was expecting. Tons of really ugly platform-specific stuff on each platform. |
Gameplay3d or sdl2 might be decent references perhaps? Gameplay in particular has a pretty simple platform layer to checkout. |
No need to do everything at once! I think it would be a good idea to first get a feel of how the API could look like. From my experience with SDL2 gamepad support, there was a lot of unsafe stuff (passing pointers here and there, checking for length and null and whatnot. For this I actually think simpler is better. The bare minimum for this to be usable would be:
To further extend on this functionality, we could:
|
I'm not fan of this, I think this is too high level. |
I agree with @tomaka. That doesn't belong in glutin. I've already designed an interface that I think will work, I'm solidifying it and working on the platform implementations. |
(I'll share more when I have more ready) |
It has been over a year since this issue was last updated, and I would like controller support in glutin as well - I really don't want to have to switch window management libraries just for controller input. Is this still on the table for potential future support? |
To get support for game controllers done right it's probably not too hard to get into it... but it looks like a lot of tedious busy work. Rather than toss that work into the core glutin project, I was planning to start an exploratory 'glutin_controllers' crate so that controller support could be opted in like it's done in a framework like libGDX. That said, I have 3 kids and a day job so @Kasran I doubt I'd make any headway on this by the time you could use it. |
IIRC the conclusion was that controller support doesn't need to be tied to a windowing library at all, and thus could be a separate crate entirely. |
@fkaa that's certainly where I saw things headed, but I guess this ticket should perhaps be closed now? |
Indeed. There are two intertwined problems: evented vs polling input APIs, and decoupling from the window's event loop. All of the APIs are separate from the window's event loop, and differ in opinion on whether to poll or wait for events. Glutin isn't a good place for this simply due to the first, but the second requires emulation layers depending on which sort of interface you expose, which would force glutin to make a policy choice. |
Fair enough... Out of curiosity, does anyone have any recommendations about what to use that's already out there? |
The most well-developed joystick input crates at the moment appear to be, roughly in order: The traditional way to handle joysticks and game controllers seems to be to treat them as basically the same type of device, and have each device just have a set of "axis" and "button" inputs. So on a PS2 controller the thumbsticks would be axis 0 and 1, while the d-pad might be axis 2, and the buttons would be buttons 0-7 or whatever, while the most primitive joystick would just have one axis for the joystick itself and two buttons. Barring touch devices this model seems to encompass more or less everything, and leaves it up to higher-level abstractions to handle, mapping the differences between, say a PS2 controller and an XBox controller onto a game's inputs. |
@tomaka I see the decision made here and I respect that it was made with the mindset that this is a low level window library, I do want to point out though that the first sentence on this crate's readme says it's a GLFW alternative, GLFW does have a high level controller abstraction. So ideally either a way to accomplish that should be provided in documentation, built into this crate, or we should change the readme to indicate this crate never plans on supporting it. I have controllers and Windows and Linux installations, so I'll be playing around with a way to do controller support on those platforms, either using the crates already listed or just making my own. I can make a PR to this repository if you change your mind and want a controller API. |
For the record, I just want to mention that if anywhere, discussion on this topic would probably now be better suited to the On a related note, a |
I'm confused what you are referring to? glutin bills itself as a GL and Input library. Surely game controller support is within the purview of said 'mission statement'. Supporting SDL2 game controller mapping would be a big part of that. Especially since GLFW 3.3 (which this library claims to mimic) has upcoming support. |
Closed as wontfix. |
Hello!
SDL2 joystick support and it's associated "gamecontroller" mapping support is very useful. It would be wonderful to have something similar that supported the SDL2 mapping format (steam for instance provides this mapping via an environment variable when launching an app or game from big picture mode).
Is anyone already looking into joystick support? I could contribute to linux support, and possibly osx, but I don't own a copy of windows.
The text was updated successfully, but these errors were encountered: