Repository navigation
Conversation
emberian
force-pushed
the
joystick
branch
2 times, most recently
from
May 22, 2015 04:56
6f14adc to
f3e2741
Compare
Author
|
Action item from IRC: make it separate from |
Contributor
There was a problem hiding this comment.
This will need to be fixed before merging.
Author
|
Action item from IRC: expose both event and poll-based interfaces. Emulate them on platforms where they are different (only XInput comes to mind). |
Contributor
|
All joystick-related stuff could be moved from |
Author
|
Will need to add "ball" support as well, forgot about that. http://www.usb.org/developers/hidpage/Hut1_12v2.pdf has a comprehensive list of all the various kinds of input devices (only some of which Glutin cares about). |
This is essentially the same API that SDL2 and GLFW support. It does not have the limitation of a max number of joysticks. It's possible that we may want to support a max number of joysticks, because that can avoid an allocation, but there's not really a significant amount of allocation that can happen due to this! I've trawled docs for all the major platforms and this API should be fine. SDL2 emulates both a poll and event-based interface, by either polling joystick state during the event loop, or updating a local copy of joystick state and returning that for the poll.
Author
|
@tomaka I will ping you when it's ready for another review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is essentially the same API that SDL2 and GLFW support. It does not
have the limitation of a max number of joysticks. It's possible that we may
want to support a max number of joysticks, because that can avoid an
allocation, but there's not really a significant amount of allocation that
can happen due to this!
I've trawled docs for all the major platforms and this API should be fine.
SDL2 emulates both a poll and event-based interface, by either polling
joystick state during the event loop, or updating a local copy of joystick
state and returning that for the poll.
The way this API will work, is that users are encouraged to call
scan_joystickson startup, when a joystick is detached (noticed bypollreturning
None), and when their game logic wants it ("Player 2 pressstart!"), but not every frame because it can be slow. The
Joystickwillinternally contain an
Rcto any state it needs.pollshould benon-blocking and return whatever state it had at the last poll if it would
block (though I am not sure if there are many devices where that would be
an issue).
On some platforms, rather than polling for joystick state, you get events.
AFAICT the only platform that does not support events is Windows with
XInput.
I'm not sure I like tying this to the Window, as on no platform are
joystick events tied directly to a window. Instead, all applications
observe the same state. Plus, scanning for joysticks can be off-main-thread
for most platforms!
There's a fair amount of room for alternative design. This seems easiest
and most conservative.