Forward Ctrl to the device

Now that Meta is used for scrcpy shortcuts, Ctrl can be forwarded to the
device.

This allows to trigger Android shortcuts.

Fixes #555 <https://github.com/Genymobile/scrcpy/issues/555>
This commit is contained in:
Romain Vimont 2020-05-29 22:16:35 +02:00
parent f650b0195f
commit 26cadf1022
2 changed files with 9 additions and 3 deletions

View File

@ -92,6 +92,8 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod,
MAP(SDLK_LEFT, AKEYCODE_DPAD_LEFT);
MAP(SDLK_DOWN, AKEYCODE_DPAD_DOWN);
MAP(SDLK_UP, AKEYCODE_DPAD_UP);
MAP(SDLK_LCTRL, AKEYCODE_CTRL_LEFT);
MAP(SDLK_RCTRL, AKEYCODE_CTRL_RIGHT);
}
if (!(mod & (KMOD_NUM | KMOD_SHIFT))) {

View File

@ -263,9 +263,8 @@ input_manager_process_key(struct input_manager *im,
bool alt = event->keysym.mod & (KMOD_LALT | KMOD_RALT);
bool meta = event->keysym.mod & (KMOD_LGUI | KMOD_RGUI);
if (alt || ctrl) {
// No shortcuts involve Alt or Ctrl, and they are not forwarded to the
// device
if (alt) {
// No shortcuts involve Alt, and it is not forwarded to the device
return;
}
@ -273,6 +272,11 @@ input_manager_process_key(struct input_manager *im,
// Capture all Meta events
if (meta) {
if (ctrl) {
// No shortcuts involve Ctrl+Meta
return;
}
SDL_Keycode keycode = event->keysym.sym;
bool down = event->type == SDL_KEYDOWN;
int action = down ? ACTION_DOWN : ACTION_UP;