-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Use the APPLE_STYLE_KEYS
define consistently for macOS shortcuts
#47619
Conversation
`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).
#ifdef APPLE_STYLE_KEYS | ||
if (k->get_keycode() == KEY_META) { | ||
#else | ||
if (k->get_keycode() == KEY_CONTROL) { |
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 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
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.
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
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.
Sounds good, but I might leave this for a future PR.
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 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.
This was superseded by #65241. |
While working on #47618, I noticed that
APPLE_STYLE_KEYS
is always defined whenOSX_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 withOSX_ENABLED
.