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

Use the APPLE_STYLE_KEYS define consistently for macOS shortcuts #47619

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Apr 4, 2021

While working on #47618, I noticed that APPLE_STYLE_KEYS is always defined when OSX_ENABLED is defined (and vice versa). The point of that define is to semantically distinguish between alternate codepaths for shortcuts from alternate codepaths for other purposes (such as code signing).

Alternatively, if we deem that doing this separation isn't important, we could remove APPLE_STYLE_KEYS entirely and replace all its existing uses with OSX_ENABLED.

`APPLE_STYLE_KEYS` is always defined when `OSX_ENABLED` is defined
(and vice versa). The point of that define is to semantically
distinguish between alternate codepaths for shortcuts from alternate
codepaths for other purposes (such as code signing).
@Calinou Calinou requested review from a team as code owners April 4, 2021 13:21
@Calinou Calinou added this to the 4.0 milestone Apr 4, 2021
@Calinou Calinou requested review from a team and removed request for a team April 4, 2021 13:22
Comment on lines +3155 to 3158
#ifdef APPLE_STYLE_KEYS
if (k->get_keycode() == KEY_META) {
#else
if (k->get_keycode() == KEY_CONTROL) {
Copy link
Member Author

@Calinou Calinou Apr 4, 2021

Choose a reason for hiding this comment

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

I wonder if we could have an OS-specific keycode to avoid this kind of #ifdef. Something like KEY_MASK_CMD, but for standard keys rather than modifiers (KEY_CMD?).

cc @bruvzg

Copy link
Member

Choose a reason for hiding this comment

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

Adding KEY_CMD define to the core/os/keyboard.h/core/core_constants.cpp should work in the same way.

// core/os/keyboard.h //
#ifdef APPLE_STYLE_KEYS
	KEY_CMD = KEY_META,
#else
	KEY_CMD = KEY_CONTROL,
#endif
// core/core_constants.cpp //
BIND_CORE_ENUM_CONSTANT_NO_VAL(KEY_CMD); //to avoid listing value in the docs

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, but I might leave this for a future PR.

Copy link
Contributor

@EricEzaM EricEzaM Apr 4, 2021

Choose a reason for hiding this comment

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

@Calinou #43888 (comment)

  • I added bool Input::is_modifier_pressed(int p_keycode_mask) where you can pass a mask like KEY_MASK_CMD or KEY_MASK_SHIFT and it will return whether one of the keys that make up that mask is pressed.

Does something like that. I think in that PR I also replace all cases like this #ifdef with that method usage.

@akien-mga
Copy link
Member

This was superseded by #65241.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants