Skip to content
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

Improved joystick support #255

Merged
merged 11 commits into from
Sep 19, 2023
Merged

Conversation

macsforme
Copy link
Member

This PR implements improved joystick handling per my comments here on issue #72.

This video explains the changes better than I could by typing it out here, so I will leave it at that.

I tested this on my SteelSeries Nimbus, but it would help if anyone with a different model of joystick or controller could also give it a whirl and make sure the effects of the joystick input settings are as expected.

@Ratfink
Copy link

Ratfink commented Jul 7, 2020

The ramp options in the menu aren't named quite right, since they're really using a polynomial function, not exponential. I'd suggest being more concise and just calling the three options "Linear," "Quadratic," and "Cubic."

Copy link
Member

@jwmelto jwmelto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we want to persist in 32-bit floating point interfaces/calculations ... all modern hardware (except for GPU) is faster in 64-bit operations. What are we gaining by constraining precision?

// ballistics
x = (x * abs(x)) / 1000;
y = (y * abs(y)) / 1000;
if (xAxis == "X") x = float(state.lX) / 1000.0f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of superfluous casting here (but at least they are function-style casts and not C-style casts)... the divide by float will do the type promotion, and the type of x will narrow as needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed... thanks.

@blast007 blast007 added this to the 2.6 Release milestone Jul 6, 2021
@macsforme
Copy link
Member Author

This project kind of stalled after I learned that one of the most common controllers out there (the Xbox One controller) has triggers which are treated as axes rather than buttons. Our code currently has no support for the concept of an axis triggering a button event, so this makes the triggers on the Xbox One controller basically useless for their intended purpose. Implementing support for an axis to trigger a button would require consideration of actuation point, release point, etc. Expanding the underlying joystick support code is complicated by the number of platform implementations we have on top of it (EvDev, USB, Windows, SDL 1, SDL 2). Development time and available hardware for testing are also scarce resources.

Any thoughts on how to move forward would be welcome. One valid option may be to simply merge as-is, and ignore the lack of axis->button support for the time being, since we will be no worse off than we were before this patch. However, the EvDev/USB/Windows joystick code should be updated to use the new floating-point axis readings versus the old integer readings (I believe Windows is done, but may need testing), if any of that code is even connected to anything anymore.

@blast007
Copy link
Member

We should remove the non-SDL2 joystick code. That was my plan at least in master once we're done worrying about merging in 2.4 changes. The main reason the Windows joystick code is still in use is because of its Force Feedback support. I do have the start of code that added haptic feedback to our SDL2 joystick code, though.

I was considering an analog-to-digital conversion already to handle menu/UI navigation with analog sticks.

We could also look into use the GameController API that SDL2 provides which has mappings for various controllers.

@blast007 blast007 modified the milestones: 2.6 Release, 2.4.28 Jul 23, 2023
src/bzflag/InputMenu.cxx Fixed Show fixed Hide fixed
src/bzflag/InputMenu.cxx Fixed Show fixed Hide fixed
src/bzflag/InputMenu.cxx Fixed Show fixed Hide fixed
src/bzflag/InputMenu.cxx Fixed Show fixed Hide fixed
@macsforme
Copy link
Member Author

That last commit (dcc3d87) fixes my last concern with this PR, which was an issue where the real coordinates and effective coordinates did not always align due to incorrect math. This video shows that the two are now properly aligned (the red/green lines were a temporary visual aid and are not present in the main PR). Due to the math change, a second set of eyes on that commit would be welcome.

With that, I believe this is ready to merge assuming no other outstanding concerns.

@macsforme macsforme merged commit 57eefc3 into BZFlag-Dev:2.4 Sep 19, 2023
3 checks passed
@macsforme macsforme deleted the joystick_improvements branch September 19, 2023 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants