-
Notifications
You must be signed in to change notification settings - Fork 793
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
Apple MFi controller buttons with the example of Nimbus+. Hack for a known Nimbus' problem. #1294
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…known Nimbus' problem.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#SDL Joystick axis mapping (circle-pad) | ||
set(JOY_AXIS_LEFTX 0) | ||
set(JOY_AXIS_LEFTY 1) | ||
|
||
#SDL Joystick button mapping (A / B and X / Y inverted for MFi Nimbus Plus, at least) | ||
set(JOY_BUTTON_A 1) | ||
set(JOY_BUTTON_B 0) | ||
set(JOY_BUTTON_X 3) | ||
set(JOY_BUTTON_Y 2) | ||
set(JOY_BUTTON_LEFTSHOULDER 4) | ||
set(JOY_BUTTON_RIGHTSHOULDER 5) | ||
set(JOY_BUTTON_BACK 15) | ||
set(JOY_BUTTON_START 14) | ||
|
||
# No use for it yet! | ||
#set(JOY_BUTTON_MENU 16) | ||
|
||
set(JOY_BUTTON_DPAD_DOWN 11) | ||
set(JOY_BUTTON_DPAD_LEFT 13) | ||
set(JOY_BUTTON_DPAD_UP 10) | ||
set(JOY_BUTTON_DPAD_RIGHT 12) | ||
set(JOY_BUTTON_TRIGGERLEFT 6) | ||
set(JOY_BUTTON_TRIGGERRIGHT 7) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,14 @@ bool Joystick::ProcessAxisMotion(const SDL_Event &event) | |
#endif | ||
#ifdef JOY_AXIS_LEFTY | ||
case JOY_AXIS_LEFTY: | ||
leftStickYUnscaled = -event.jaxis.value; | ||
// Work around Nimbus that reports inverted Y. No known fix, | ||
// AFAIK, and no SDL remapping. | ||
// https://forums.libsdl.org/viewtopic.php?p=51409 | ||
if (nimbus_axis_hack_) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this could be a more general flag option for the ini. Something like: "Joystick Invert Y-Axis". It could even use it as a feature 🤷♂️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was not sure about the usefulness of such a feature outside of this specific vendor, so I'd like to open a discussion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inverted YAxis might happen with other joysticks: |
||
leftStickYUnscaled = event.jaxis.value; | ||
} else { | ||
leftStickYUnscaled = -event.jaxis.value; | ||
} | ||
leftStickNeedsScaling = true; | ||
break; | ||
#endif | ||
|
@@ -263,6 +270,11 @@ void Joystick::Add(int device_index) | |
#ifndef USE_SDL1 | ||
result.instance_id_ = SDL_JoystickInstanceID(result.sdl_joystick_); | ||
#endif | ||
if (strstr(SDL_JoystickNameForIndex(device_index), "Nimbus") != NULL) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove it if you move it to options. |
||
SDL_Log("Applying Nimbus axis hack"); | ||
result.nimbus_axis_hack_ = true; | ||
} | ||
|
||
joysticks_->push_back(result); | ||
sgbControllerActive = true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo those changes should be defined during the cmake step:
Maybe adding this to the wiki page would be a good idea. But let's see what others think.