Accept Cmd for shortcuts on macOS

For convenience (and to keep the existing behavior), also accept
shortcuts using Cmd instead of RCtrl.
This commit is contained in:
Romain Vimont 2020-06-01 16:14:51 +02:00
parent a253164237
commit ded6215362
2 changed files with 16 additions and 4 deletions

View File

@ -560,6 +560,9 @@ Also see [issue #14].
`RCtrl` is the right `Ctrl` key (the left `Ctrl` key is forwarded to the
device).
On macOS, `Cmd` also works (for shortcuts which are not already captured by the
system).
| Action | Shortcut
| ------------------------------------------- |:-----------------------------
| Switch fullscreen mode | `RCtrl`+`f`

View File

@ -254,9 +254,18 @@ input_manager_process_key(struct input_manager *im,
bool meta = event->keysym.mod & (KMOD_LGUI | KMOD_RGUI);
bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
if (alt || meta) {
// No shortcuts involve Alt or Meta, and they are not forwarded to the
// device
bool shortcut_key = rctrl;
#ifdef __APPLE__
shortcut_key |= meta;
#else
if (meta) {
// No shortcut involve Meta, and it is not forwarded to the device
return;
}
#endif
if (alt) {
// No shortcuts involve Alt, and it is not forwarded to the device
return;
}
@ -266,7 +275,7 @@ input_manager_process_key(struct input_manager *im,
bool down = event->type == SDL_KEYDOWN;
// Capture all RCtrl events
if (rctrl) {
if (shortcut_key) {
int action = down ? ACTION_DOWN : ACTION_UP;
bool repeat = event->repeat;
switch (keycode) {