Skip to content

Commit

Permalink
WIP Synchronize keyboard on Ctrl+v
Browse files Browse the repository at this point in the history
  • Loading branch information
rom1v committed May 29, 2020
1 parent a98b74d commit b330ba4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ input_manager_process_key(struct input_manager *im,
bool ctrl = event->keysym.mod & (KMOD_LCTRL | KMOD_RCTRL);
bool alt = event->keysym.mod & (KMOD_LALT | KMOD_RALT);
bool meta = event->keysym.mod & (KMOD_LGUI | KMOD_RGUI);
bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);

if (alt) {
// No shortcuts involve Alt, and it is not forwarded to the device
Expand All @@ -276,18 +277,18 @@ input_manager_process_key(struct input_manager *im,

struct controller *controller = im->controller;

SDL_Keycode keycode = event->keysym.sym;
bool down = event->type == SDL_KEYDOWN;

// 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;
bool repeat = event->repeat;
bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
switch (keycode) {
case SDLK_h:
if (control && !shift && !repeat) {
Expand Down Expand Up @@ -416,6 +417,14 @@ input_manager_process_key(struct input_manager *im,
return;
}

assert(!meta);

if (ctrl && !shift && keycode == SDLK_v && down) {
// Synchronize the computer clipboard to the device clipboard before
// sending Ctrl+v
set_device_clipboard(controller, false);
}

struct control_msg msg;
if (convert_input_key(event, &msg, im->prefer_text)) {
if (!controller_push_msg(controller, &msg)) {
Expand Down

0 comments on commit b330ba4

Please sign in to comment.