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

Rename keys like LAlt to AltLeft #8792

Merged
merged 3 commits into from
Jun 15, 2023
Merged

Conversation

jim-ec
Copy link
Contributor

@jim-ec jim-ec commented Jun 8, 2023

Objective

The KeyCode enum cases LWin and RWin are too opinionated because they are also assigned meaning by non-Windows operating systems. macOS calls the keys completely different.

Solution

Match winits approach naming convention.


Migration Guide

Migrate by replacing:

  • LAltAltLeft
  • RAltAltRight
  • LBracketBracketLeft
  • RBracketBracketRight
  • LControlControlLeft
  • RControlControlRight
  • LShiftShiftLeft
  • RShiftShiftRight
  • LWinSuperLeft
  • RWinSuperRight

Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

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

While this differs from winit's KeyCode naming, I think this makes things a bit clearer for non-Windows users.

I might be biased though: #3240 (my first ever issue for Bevy)

@alice-i-cecile alice-i-cecile added A-Input Player input via keyboard, mouse, gamepad, and more C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Jun 8, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

LGTM, but if possible we should add a doc alias to the enum variant. No idea if that's supported though :)

@CGMossa
Copy link
Contributor

CGMossa commented Jun 8, 2023

This needs a little more careful consideration.

@mockersf
Copy link
Member

mockersf commented Jun 8, 2023

This is also part of the winit update (#8745). LWin will be called SuperLeft on the next winit version.

@jim-ec
Copy link
Contributor Author

jim-ec commented Jun 8, 2023

I could add doc aliases to the enum cases. Something like #[doc(alias("RWin", "RMeta"))]. I just verified that it works.

@alice-i-cecile
Copy link
Member

Great, I like the doc aliases regardless of the final decision here.

/// Generic keyboards usually display this key with the *Microsoft Windows* logo.
/// Apple keyboards call this key the *Command Key* and display it using the ⌘ character.
#[doc(alias("LWin", "LMeta", "LLogo"))]
LSuper,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
LSuper,
SuperLeft,

We should align with #8745 to avoid conflicts (and keep consistency with upstream).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't we then also rename LAlt, LBracket, LControl, and LShift to LeftAlt etc.?

Copy link
Member

Choose a reason for hiding this comment

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

AltLeft, but yes, I agree. I think that the increased clarity is worth the extra characters.

Copy link
Member

Choose a reason for hiding this comment

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

I'm sure @mockersf has opinions though :p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case we should also adjust the doc aliases to WinLeft etc.

Copy link
Member

Choose a reason for hiding this comment

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

I'm sure @mockersf has opinions though :p

If we change one, we should change them all... but no opinion on wether to do it now or with winit update later

/// Generic keyboards usually display this key with the *Microsoft Windows* logo.
/// Apple keyboards call this key the *Command Key* and display it using the ⌘ character.
#[doc(alias("RWin", "RMeta", "RLogo"))]
RSuper,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
RSuper,
SuperRight,

@Vrixyz
Copy link
Member

Vrixyz commented Jun 8, 2023

As author of in #8792, I saw this PR linked, I'm ok with handling the potential conflicts due to merging this PR :)

The PR description mentions winit's ModifiersKeys ; but as hinted in the comments, I think I'd prefer to keep our namings matched to winit's KeyCode.

While this differs from winit's KeyCode naming

I'm alright with temporary winit difference, if consensus is that it's clearer. If there's no issue with #8745, namings should be back to similar after we update to winit 0.29 (hopefully bevy 0.12).

@jim-ec
Copy link
Contributor Author

jim-ec commented Jun 8, 2023

So I renamed the key codes to SuperLeft etc. to be consistent with winit.

@MrGVSV
Copy link
Member

MrGVSV commented Jun 9, 2023

Also, the title and description (at least the migration guide) should probably be updated to make the changelog work easier for 0.11

@jim-ec jim-ec changed the title Rename LWin and RWin to LSuper and RSuper Rename keys like LAlt to AltLeft Jun 9, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jun 10, 2023
@alice-i-cecile alice-i-cecile requested a review from mockersf June 10, 2023 23:20
Comment on lines +321 to +322
/// The `Left Alt` key. Maps to `Left Option` on Mac.
AltLeft,
Copy link
Contributor

Choose a reason for hiding this comment

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

Very minor thing: The doc string is now the reverse of the actual name.
Not sure if this matters though.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I'm not a fan of winit's naming here but it makes sense to be consistent with them

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think this is fine.

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Jun 15, 2023

Alright, merging this in as no one else has expressed opposition after more socialization and there's consensus that these names are clearer :)

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 15, 2023
Merged via the queue into bevyengine:main with commit 13f50c7 Jun 15, 2023
@jim-ec jim-ec deleted the rename-win-key branch June 15, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants