Skip to content

Commit

Permalink
Forward Ctrl to the device
Browse files Browse the repository at this point in the history
Now that Meta is used for scrcpy shortcuts, Ctrl can be forwarded to the
device.

This allows to trigger Android shortcuts.

Fixes #555 <#555>
  • Loading branch information
rom1v committed May 29, 2020
1 parent f650b01 commit 26cadf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/src/event_converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
10 changes: 7 additions & 3 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,20 @@ 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;
}

struct controller *controller = im->controller;

// 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;
Expand Down

0 comments on commit 26cadf1

Please sign in to comment.