-
Notifications
You must be signed in to change notification settings - Fork 84
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
Allow Ports To Configure Default Button Mappings #724
Conversation
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.
overall the logic looks reasonable, but i'm not a huge fan of the LUS_BTN_*
names
although verbose, i'd prefer something more descriptive such as LUS_DEFAULT_KB_MAPPING_*
edit: also, the name of this pr feels a little misleading. LUS already has default keyboard mappings, if i were to name the PR i'd call it "allow ports to configure default keyboard button mappings"
I agree with Bria's naming suggestion here. Can we get this in? |
Done! (Albeit, I feel like I'm now in a sort of time distortion because I can't get in again what I've already gotten in) |
Don't merge yet. Starship wants controller defaults |
that doesn't need to be the same PR though right? |
i suggested "allow ports to configure default keyboard button mappings" and the title is currently "Allow Keyboard Button Mapping Configuration In Games" "Allow Keyboard Button Mapping Configuration In Games" is ambiguous, players can already configure keyboard button mappings. this PR is replacing hardcoded default keyboard button mappings with cmake variables. come to think of it that'd be another reasonable title - "replace hardcoded default keyboard button mappings with cmake variables" |
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.
the controller side of things feels a bit more complex because it uses both SDLButtonToButtonMapping
and SDLAxisDirectionToButtonMapping
the current implementation allows ports to
- set any SDL button to:
- any N64 button (including dpad and c buttons)
- kind of configure SDL axes for the c buttons (axis vs axis direction issues)
the current implementation does not allow port to
- set SDL buttons to analog stick axis directions
- set SDL axis directions to any non-c-stick buttons
my opinion is the controller stuff requires quite a bit more architectural thinking than the keyboard stuff does, and it should be split out into a separate PR
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CLEFT, | ||
SDL_CONTROLLER_AXIS_RIGHTX, -1)); | ||
LUS_DEFAULT_CONT_MAPPING_CLEFT, -1)); | ||
if (isGameCube) { | ||
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_CLEFT, | ||
SDL_CONTROLLER_BUTTON_Y)); | ||
LUS_DEFAULT_CONT_MAPPING_CLEFT2)); |
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.
these would benefit from more descriptive names. a consumer of LUS shouldn't have to know that CLEFT2
is for an SDLButton
only on gamecube controllers and CLEFT
is for an SDLAxisDirection
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.
My bad, I didn't see the conditional gamecube statement.
cmake/cvars.cmake
Outdated
set(LUS_DEFAULT_KB_MAPPING_DLEFT KbScancode::LUS_KB_F CACHE STRING "") | ||
set(LUS_DEFAULT_KB_MAPPING_DRIGHT KbScancode::LUS_KB_H CACHE STRING "") | ||
|
||
set(LUS_DEFAULT_CONT_MAPPING_A SDL_CONTROLLER_BUTTON_A CACHE STRING "") |
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.
curious as to what others think about the naming here. considering these are used specifically for SDL
, i think i'd prefer LUS_DEFAULT_SDL_MAPPING_*
over LUS_DEFAULT_CONT_MAPPING_*
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.
Sure! But for me I didn't realize at first that SDL referred to a physical gamepad.
} | ||
break; | ||
case BTN_CLEFT: | ||
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CLEFT, | ||
SDL_CONTROLLER_AXIS_RIGHTX, -1)); | ||
LUS_DEFAULT_CONT_MAPPING_CLEFT, -1)); |
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.
the -1
is important here as it is what determines that we mean left on the x axis instead of right. LUS_DEFAULT_CONT_MAPPING_CLEFT
is only the axis part of AxisDirection
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.
I was copying the name of BTN_CLEFT
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.
you replaced SDL_CONTROLLER_AXIS_RIGHTX
with LUS_DEFAULT_CONT_MAPPING_CLEFT
SDL_CONTROLLER_AXIS_RIGHTX
is used for both left and right
Would any port actually want to override where the analogue stick goes? I think usually with the different brands of controllers the main issue is the face buttons are different like A/B and X/Square or whatever. At the very least, with starship's release coming up, I think the point is moreso about having the ability to set what they need, and not necessarily a full blown implementation. |
i still think the controller part should be a separate PR. the axis direction vs button stuff is more complex than the keyboard stuff. let's land the keyboard stuff and figure out what an MVP for controller stuff looks like after. |
this shouldn't land as-is. the controller stuff either needs to be reworked or removed. the keyboard stuff seems ok as-is, but if we want to do controller stuff moving away from cmake vars is a better architectural decision. |
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.
even if we decide to add more robust (non-cmake-based) default setting in the future, having this shouldn't get in the way. copying my previous note from discord here so it's in a more permanent place
|
Replaces hardcoded default button mappings with cmake variables
Replace keyboard button enums with default macros set in
cvars.cmake
. This allows ports to define their own default usingCMake/lus-cvars.cmake
file.A PR to SOH and 2Ship should not be necessary because I believe they use the default button mappings.