Support controller analog triggers#600
Support controller analog triggers#600Lgt2x wants to merge 12 commits intoDescentDevelopers:mainfrom
Conversation
|
I've tested on Xbox Series controller on Linux, there some improvements compared to current main branch, no uncontrolled rotation anymore, but now my ship is constantly moving up, like left trigger constantly pushed. If I push right trigger, ship goes down, but after release ship again goes up. |
You've mapped triggers to something like pitch? It's possible that default deadzone is too high, how does it go when you increase it here ? https://github.com/DescentDevelopers/Descent3/pull/600/files#diff-7f049cd870d2530a44058475c2746ae9ba2f1bddf3995756061cf046e72fc2cfR1332 And the mapping part goes smoothly? |
|
Just retested on new pilot with default configs, same thing happens. |
Ok then that's the analog trigger detection threshold that's not set correctly. Migrating to the SDL2 GameController API will solve that |
|
I could reproduce the problem on an actual Xbox series controller, it's a problem with the default mapping that uses a trigger as an axis. While it can be remapped easily, short-term solution is to disable this default mapping. I'll update the PR later. |
3a52d34 to
4ec78bf
Compare
|
Alright, finally came around to finishing this one! I'm not done at all with controllers, but at least I'm building familiarity. Triggers can be mapped to direction functions, and default mappings should not force them to be real axis anymore. XBox series controller should now work properly. Firing with trigger buttons is not supported yet. Ready for anyone to test & review! |
4ec78bf to
12ab2a7
Compare
Default axis mappings could map controller triggers to functions that require bi-directional axis to work properly
|
@winterheart could you please review and test this branch? thanks! |
winterheart
left a comment
There was a problem hiding this comment.
New code eliminates uncontrolled rotation and elevate movements. There no forward / back, up / down movements on default joystick configuration, but I think we can do more polishing in SDL_GameController() enabling iteration.
lib/joystick.h
Outdated
| #define JOYSTICK_H | ||
|
|
||
| #include <cstdint> | ||
| #include <vector> |
There was a problem hiding this comment.
vector declaration is unused in header.
12ab2a7 to
deb9749
Compare
Indeed, that's the very next steps, but out of scope for this PR. Movement mapped manually is always better than uncontrolled movement that you cannot remap. Comments fixed otherwise. Thanks for testing! |
| if (ctl_hlb.value > 0.0f) | ||
| controls->heading_thrust += ctl_hlb.value; | ||
| if (ctl_hrb.value > 0.0f) | ||
| controls->heading_thrust -= ctl_hlb.value; |
There was a problem hiding this comment.
Is this a copy-paste error? Shouldn't it be -= ctl_hrb.value?
| if (ctl_blb.value > 0.0f) | ||
| controls->bank_thrust += ctl_blb.value; | ||
| if (ctl_brb.value > 0.0f) | ||
| controls->bank_thrust -= ctl_blb.value; |
|
I tried with a PS5 controller on Windows 11. Analog triggers are detected as normal axis. The Line 167 in deb9749 is always 0 for all axis/triggers.
If I try to force the code to go into that I haven't found anything yet, to distinguish an analog trigger from an axis for the PS5 controller. |
|
Ugh that's a pain... No choice but to use the SDL2 game controller database to identify axes then. I'll update this PR for that. |
|
Closing this, I'll rework the PR after we have SDL3 (#663) with the new game controller API |
Pull Request Type
Description
Add support for analog triggers, such as those used in the xbox controllers. They are detected as axis by SDL2, but are unidirectional, so they should be mapped to functions expecting a [-1;1] range. We allow mapping them to other buttons. Button controls have also been made analog when it made sense, so triggers can have fine control over movement.
Left to do in this MR: implement
ctTimeandctDownCountfor analog triggers so they can be used for weapons, refine detection threshold for mappingsThe controller code is a mess, this will need other passes to make it better.
Related Issues
Close #496
Screenshots (if applicable)
Checklist
Additional Comments