-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
How to get analog joystick positions for proportional projects ? #23
Comments
Right now the library is "reactive": if the user sets a function for an event, it will trigger it when the event happens. For example, you can set functions for "up", "right", "down", or "left" that will be triggered when the first analog axis moves (you can listen to the different analogs by using up0, up1,...) // examples
gamepad.on('left', characterGoLeft);
gamepad.on('right', characterGoRight);
gamepad.on('button0', characterJump); Is that what you want? |
I have a plan to revamp the library so it is more "proactive": if an event happens, it will trigger a custom event and the user can listen to it. That way, the notation will be less jQuery-looking and more native-JS-looking (keeping both methods for a while). But that won't happen in the short term. |
I want to add the Joystick support for a robotic web remote : https://www.vigibot.com/ |
I don't think your answer is for proportional analog values / joystick positions I need for my project :( Some robot are very powerful and high torque, starting at 100% full power are dangerously to fast for them. We use flying drone also need proportional piloting you can't fly a drone with keyboard like inputs! |
I think I see the problem now: the way it is right now, the direction/joystick is triggered or not, it doesn't take into account the actual value, just the threshold, then it's all in or nothing at all. Is that the issue? If it is, we could update the callback for the axes, so it includes the "force" as a [0..1] value. That way you know if the joystick was moved AND how much. (e.g., 0.5 would be half strength, 1.0 would be full strength). Would that work? That way, you could do something like this: // example
gamepad.on('left', function(value) {
if (value < 0.5) {
moveCharacterLeftSlow();
} else if (value < 0.9) {
moveCharacterLeftNormal();
} else {
moveCharacterLeftFast();
}
}); |
Looks OK, so far I've used the native gamepad API and developed a user-configurable abstraction layer myself. I even made a configurable dead zone like this. Here is the "analog" part I required when I opened this ticket
|
I think I have all the "Button" functionality of your lib in this. I give you all my work extracted from my project. User gamepad button mapping (multiple buttons for one function is OK) JSON config object :
Initialization (once) :
Event loop to get DOWN and UP event for any gamepad button on any browser (tested on chrome firefox ...) :
|
Hi! Thanks :-) |
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I need to read X / Y values of joystick
Describe the solution you'd like
A clear and concise description of what you want to happen.
An analog axis move event
The text was updated successfully, but these errors were encountered: