-
Notifications
You must be signed in to change notification settings - Fork 7
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
API Proposal #1
Comments
Look good to me, and as you said, it is an very abstract representation for all input devices. Just a little questions for clarify, how uni-pad mapping these values ? For examples, when a pressed X in my xbox controller, would |
That's probably one of the trickiest part. So far i've no idea if all platforms use the same button ids but there probably need to be some mapping done at some point, similar to the keyboard mapping in uni-app. We can probably settle for a convention so that at least standard gamepads (with XYAB buttons) have a consistent behaviour, but there are a lot of different controllers with different buttons. In the end, the unrust user (and probably the player) should be able to define his own mapping. |
Sound reasonable, would you mind to start the Windows implementation first ? I would like to follow your code styles and implement back the MacOS and Linux part. |
ok, i'll have a look at current gilrs linux implementation too to avoid being too influenced by windows API (there are 3 one on windows btw... winapi, directinput and xinput...) |
Thanks, and i think XInput is more reliable, right ? (I don't know about gamepad api a lot) |
XInput is the latest and bestest API but it only supports XBOX360 controllers. DirectInput is older, but more generic and plays more gently with exotic controllers. |
It is up to you to use which one, i have no idea (I have a XBox360 controller anyway ) |
ok I've got a working XInput implementation at https://github.com/jice-nospam/gamepad-rs |
So fast~~~, I am looking on your code now, Here are some ideas on
|
And i just tested it (Windows/Xbox 360 controller), it works perfectly even hot plugged, great !! |
Nice :) About your ideas :
|
RB and LB buttons works in my system.
And we can lazy update the ControllerInfo and poll updating |
There are some warnings when i compiled, and i think this session :
Are all these missing xinput:: in front of each enum ?? Because rust cannot find the symbol, it treat all symbols as variables. And it equal to :
So only the first arm will be matched. |
Ah thanks, I didn't understand where these warnings were from. Since the symbols were not used, I wonder why this compiled...
If I remove the pub, the end user can't use the functions from the trait... bah I'll just remove the trait, no?
Ok, but the game should call update() then, not the engine (unrust) else you'll have to update all controllers whereas the game might only need one (if it's a single player game) |
For example , the following code :
will print 2, Rust just treat XINPUT_DEVSUBTYPE_GAMEPAD as variable.
I think remove the trait is fine. ;)
That's fine. :) |
btw it's done, but the linux port is still wip. Do I create a PR on main repo to be able to integrate this into uni-pad or do you prefer to wait for the linux port to be finished ? |
Maybe create a PR on gamepad-rs first, then i could work on the mac side
based on ur api. And setup the travis and add some auto test on it.
I think we don’t rush to add it in unrust now, because we would like to
move the uni-pad crate to an individual crate in here too.
The reason behind that is, maybe we would other game engine to use to this
gamepad library for more tester to involve.
On Mon, 30 Apr 2018 at 15:50, jice-nospam ***@***.***> wrote:
btw it's done, but the linux port is still wip. Do I create a PR on main
repo to be able to integrate this into uni-pad or do you prefer to wait for
the linux port to be finished ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKgP52AOKohxwmVN_Q-mff36RFHuBYhlks5ttsJcgaJpZM4Th50q>
.
--
Cheers,
Edwin Cheng
|
So this library should provide low level access to gamepad/joystick input, and we have to keep in mind that we have to create a unified API for web and native. I'd rather go for a pragmatic API like this :
This might not be doable on every platform so we'll probably have to iterate a bit. it's a starting point.
Also, this is not compilable rust but you get the idea.
This also helps to define the perimeter of what we want to support with this library as this can go pretty wild (gamepad only or joystick/motion sensor? vibrations ? headsets ?) keeping in mind that high level features like key-repeat, key-mapping or dead zone should not be part of this low level library but rather on top of uni-pad.
In case a controller is not available anymore because it was unplugged, the API should return some default values so that end user doesn't have to deal with Option.
If you have 2 controllers plugged : 0 and 1 and you unplug 0, 1 is still available at index 1. 0 returns a default value with a status indicating it's unpluged.
[edit] status should be obviously in ControllerState. Also added sequence field
The text was updated successfully, but these errors were encountered: