-
Notifications
You must be signed in to change notification settings - Fork 329
CHANGE: Removed aliased values in Gamepad enum. (ISXB-543) #1983
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
Conversation
…fic to gamepad buttons. Also removed aliased values in GamepadButton enum
/// The right trigger button on a gamepad. | ||
/// </summary> | ||
RightTrigger = 33, | ||
|
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.
We cannot remove these from this enum without requiring a major version revision since it would break public API for existing customers (and according to semver), hence this is not a viable way forward.
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 hadn't thought of this. I re-added the aliased enum values (although I did not reset them in the other files that used them to move towards north/south/east/west). I also added a slightly modified version of the aliased enum drawer from #1862 where we can remove values from the drawer.
|
||
### Changed | ||
- Use `ProfilerMarker` instead of `Profiler.BeginSample` and `Profiler.EndSample` when appropriate to enable recording of profiling data. | ||
- Removed aliased values in GamepadButton enum. |
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.
We do not want to release a major revision due to this change.
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.
Should we plan to do so down the line? Perhaps mark the aliased values as depricated (I'm not sure how we go about doing this).
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.
We basically shouldn't modify the enum at all, we should aim for a completely editor-based "fix" here. There is no functional issue with the current solution, its only confusing users from UX perspective.
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.
It makes sense though to file an internal ticket to consider removing aliases for control enums down the line (in a major future release). I have now filed it.
I would recommend considering a fix based off this one but with inlined/combined options for aliased entries? #1862 |
Seems like @Billreyn was also considering that unless opinion has shifted, see #1862 (comment) |
…ting projects. Added custom aliased enum drawer base and custom enum drawer for GamepadButton to hide aliased values.
I believe so. Based on our conversation, we want to display only North/South/East/West |
ctx => { ++receivedCalls; }; | ||
action.Enable(); | ||
|
||
var firstState = new GamepadState {buttons = 1 << (int)GamepadButton.B}; |
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 fix shouldn't have any impact on existing tests?
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.
Hence I wouldn't expect any changes to any tests.
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 believe this is due to my first pass where I removed the aliased values. Will revert
|
||
++InputUser.listenForUnpairedDeviceActivity; | ||
|
||
InputSystem.QueueStateEvent(gamepad, new GamepadState { leftStick = new Vector2(1, 0)}.WithButton(GamepadButton.A)); |
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.
This shouldn't need to change either.
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 believe this is due to my first pass where I removed the aliased values. Will revert
Exactly, with emphasis on "display", hence it should be property drawer only changes as I see it. |
/// </summary> | ||
/// <remarks> | ||
/// Identical to <see cref="Y"/> and <see cref="Triangle"/> which are the Xbox and PlayStation controller names for this button. | ||
/// Identical to <see cref="North"/> and <see cref="North"/> which are the Xbox and PlayStation controller names for this button. |
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.
This seems incorrect? Referencing to the same thing
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 believe this is due to my first pass where I removed the aliased values. Will revert
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.
Needs a bit more work I believe
allButtonPresses.Clear(); | ||
|
||
Release(gamepad.buttonSouth); | ||
InputSystem.QueueStateEvent(gamepad, new GamepadState(GamepadButton.A, GamepadButton.B)); |
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.
Not expecting any changes needed to this file
|
||
Assert.That(gamepad.buttonEast.isPressed, Is.False); | ||
|
||
var newState = new GamepadState {buttons = 1 << (int)GamepadButton.B}; |
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.
Not expecting any changes needed to this file
@@ -0,0 +1,72 @@ | |||
#if UNITY_EDITOR |
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 am afraid this is not doing what its supposed to.....
The following things need to be addressed:
- Aliased values should be part of the same entry when the inspector is displayed, e.g. "South / X / A"
- Drop down need to allow all values to be picked, e.g. either "South / X / A" or each one individually would be fine from my perspective.
- At the moment when selecting e.g. South, the value displayed is "North", so something with mapping is incorrect
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'll go over it and make sure it behaves and displays correctly
|
||
private void ProcessDisplayNamesForAliasedEnums() | ||
{ | ||
var enumNamesAndValues = new Dictionary<string, int>(); |
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.
Since the enum is small and we want consistency, maybe skip this base class and just move into specific GamepadButtonPropertyDrawer class and just use a big switch statement to get it right? That would be quite straightforward. Otherwise there needs to be some smartness to get the order of each aliased combination separated by slashes consistent.
…on specific to gamepad buttons. Also removed aliased values in GamepadButton enum" This reverts commit 110e5c6. # Conflicts: # Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/AliasedEnumPropertyDrawer.cs.meta # Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/GpadButtonPropertyDrawer.cs.meta
Removed general AliasedEnumPropertyDrawer script.
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.
Code looks reasonable, one minor recommendation, but I haven't tested it in action.
Suggest adding QA or design for a manual verification
/// Property drawer for <see cref = "GamepadButton" /> | ||
/// </summary > | ||
[CustomPropertyDrawer(typeof(GamepadButton))] | ||
internal class GpadButtonPropertyDrawer : PropertyDrawer |
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.
Minor but can you use a full name here rather than abbreviation
GpadButtonPropertyDrawer ->
GamepadButtonPropertyDrawer
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.
Agree
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.
Which also means renaming file and .meta
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.
Approving this to not block this PR in any way while I have limited accessability. I didn't run it on this review round so recommend checking functionality in QA pass.
|
||
### Changed | ||
- Use `ProfilerMarker` instead of `Profiler.BeginSample` and `Profiler.EndSample` when appropriate to enable recording of profiling data. | ||
- Removed aliased values in GamepadButton enum. |
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.
This should be reverted as well, suggest to change to something like e.g. "Changed representation of GamepadButton enum values in Inspector to display aliased enum values as a single item to avoid confusion around selection and aliased value display when multiple enum items map to the same numerical value."
/// Property drawer for <see cref = "GamepadButton" /> | ||
/// </summary > | ||
[CustomPropertyDrawer(typeof(GamepadButton))] | ||
internal class GpadButtonPropertyDrawer : PropertyDrawer |
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.
Agree
/// Property drawer for <see cref = "GamepadButton" /> | ||
/// </summary > | ||
[CustomPropertyDrawer(typeof(GamepadButton))] | ||
internal class GpadButtonPropertyDrawer : PropertyDrawer |
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.
Which also means renaming file and .meta
|
||
for (var i = 0; i < enumDisplayNames.Length; ++i) | ||
{ | ||
string enumName = enumDisplayNames[i]; |
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.
This assignment could be on line 40 right since overwritten for the special cases?
|
||
if (enumName != null) | ||
{ | ||
enumNamesAndValues.Add(enumName, (int)enumValues.GetValue(i)); |
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.
Could be moved up to the place where it is currently assigned as null?
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 changed it up a little bit. For the cases where we do not want to enter the enum into the list, I continue the for loop, eliminating the need for null/null check. The switch statement sets an string value which is then entered into the list.
Will check this today or tomorrow morning at the latest |
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.
-Renamed GpadButtonPropertyDrawer to GamepadButtonPropertyDrawer. -Fixed nullref issue caused by m_EnumDisplayNames being reset when entering/exiting play mode. -Simplified code for setting up enum list. -Updated CHANGELOG.md
The nullref issue should be fixed now. The value being displayed will be one of the aliased enums for that value so this is to be expected. |
|
||
### Changed | ||
- Use `ProfilerMarker` instead of `Profiler.BeginSample` and `Profiler.EndSample` when appropriate to enable recording of profiling data. | ||
- Changed representation of GamepadButton enum values in Inspector to display aliased enum values as a single item to avoid confusion around selection and aliased value display when multiple enum items map to the same numerical value. |
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.
Changelog entry in the wrong version and no bug issue link
@adrian-koretski-unity3d I approved too hastily, the link has to be to a public issue tracker not our internal jira lol |
Description
Fixing confusing menu when selecting face buttons due to aliased enum values.
Changes made
Removed aliased enum values.
Testing
Manual testing.
Risk
None.
Checklist
Before review:
Changed
,Fixed
,Added
sections.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.After merge: