Forward copy-cut shortcuts
For convenience, forward RCtrl+c (or Cmd+c) and and RCtrl+x (or Cmd+x) as LCtrl+c and LCtrl+x to the device. This allows to use the "natural" keys for copy-paste (especially on macOS).
This commit is contained in:
parent
cac1765091
commit
ddb36e3436
@ -242,6 +242,25 @@ convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
inject_as_ctrl(struct input_manager *im, const SDL_KeyboardEvent *event) {
|
||||
struct control_msg msg;
|
||||
|
||||
if (!convert_input_key(event, &msg, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable RCtrl and Meta
|
||||
msg.inject_keycode.metastate &=
|
||||
~(AMETA_CTRL_RIGHT_ON | AMETA_META_LEFT_ON | AMETA_META_RIGHT_ON);
|
||||
// Enable LCtrl
|
||||
msg.inject_keycode.metastate |= AMETA_CTRL_LEFT_ON;
|
||||
|
||||
if (!controller_push_msg(im->controller, &msg)) {
|
||||
LOGW("Could not request 'inject keycode'");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
input_manager_process_key(struct input_manager *im,
|
||||
const SDL_KeyboardEvent *event,
|
||||
@ -382,6 +401,15 @@ input_manager_process_key(struct input_manager *im,
|
||||
rotate_device(controller);
|
||||
}
|
||||
return;
|
||||
case SDLK_c:
|
||||
case SDLK_x:
|
||||
if (control && !shift) {
|
||||
// For convenience, forward shortcut_key+c and
|
||||
// shortcut_key+x as Ctrl+c and Ctrl+x (typically "copy" and
|
||||
// "cut", but not always) to the device
|
||||
inject_as_ctrl(im, event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user