-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,6 +411,29 @@ convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to, | |
static void | ||
input_manager_process_key_inject(struct input_manager *im, | ||
const SDL_KeyboardEvent *event) { | ||
struct controller *controller = im->controller; | ||
struct control_msg msg; | ||
if (convert_input_key(event, &msg, im->prefer_text, im->repeat)) { | ||
if (!controller_push_msg(controller, &msg)) { | ||
LOGW("Could not request 'inject keycode'"); | ||
} | ||
} | ||
} | ||
|
||
static void | ||
input_manager_process_key_hid(struct input_manager *im, | ||
const SDL_KeyboardEvent *event) { | ||
hid_keyboard_update_state(event); | ||
const unsigned char *hid_event = hid_keyboard_get_hid_event(); | ||
if (aoa_send_hid_event(im->usb_handle, hid_event, | ||
HID_KEYBOARD_KEY_LENGTH) < 0) { | ||
LOGW("Could not send HID event"); | ||
} | ||
} | ||
|
||
static void | ||
input_manager_process_key(struct input_manager *im, | ||
const SDL_KeyboardEvent *event) { | ||
// control: indicates the state of the command-line option --no-control | ||
bool control = im->control; | ||
|
||
|
@@ -562,15 +585,19 @@ input_manager_process_key_inject(struct input_manager *im, | |
} | ||
|
||
if (event->repeat) { | ||
if (!im->forward_key_repeat) { | ||
// In USB HID protocol, key repeat is handle by host (Android in this case), | ||
// so just ignore key repeat here. | ||
if (!im->forward_key_repeat || im->use_hid_over_aoa) { | ||
return; | ||
} | ||
++im->repeat; | ||
} else { | ||
im->repeat = 0; | ||
} | ||
|
||
if (ctrl && !shift && keycode == SDLK_v && down && !repeat) { | ||
// Ctrl+v works as paste in HID mode, I'd prefer not to modify it. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
AlynxZhou
Author
Owner
|
||
if (!im->use_hid_over_aoa && ctrl && !shift && keycode == SDLK_v && down && | ||
!repeat) { | ||
if (im->legacy_paste) { | ||
// inject the text as input events | ||
clipboard_paste(controller); | ||
|
@@ -581,37 +608,6 @@ input_manager_process_key_inject(struct input_manager *im, | |
set_device_clipboard(controller, false); | ||
} | ||
|
||
struct control_msg msg; | ||
if (convert_input_key(event, &msg, im->prefer_text, im->repeat)) { | ||
if (!controller_push_msg(controller, &msg)) { | ||
LOGW("Could not request 'inject keycode'"); | ||
} | ||
} | ||
} | ||
|
||
static void | ||
input_manager_process_key_hid(struct input_manager *im, | ||
const SDL_KeyboardEvent *event) { | ||
// Mirror-only mode. | ||
if (!im->control) { | ||
return; | ||
} | ||
// In USB HID protocol, key repeat is handle by host (Android in this case), | ||
// so just ignore key repeat here. | ||
if (event->repeat) { | ||
return; | ||
} | ||
hid_keyboard_update_state(event); | ||
const unsigned char *hid_event = hid_keyboard_get_hid_event(); | ||
if (aoa_send_hid_event(im->usb_handle, hid_event, | ||
HID_KEYBOARD_KEY_LENGTH) < 0) { | ||
LOGW("Could not send HID event"); | ||
} | ||
} | ||
|
||
static void | ||
input_manager_process_key(struct input_manager *im, | ||
const SDL_KeyboardEvent *event) { | ||
if (im->use_hid_over_aoa) { | ||
input_manager_process_key_hid(im, event); | ||
} else { | ||
|
It also works in
InputManager
injection mode.What is important here is to synchronize the computer clipboard to the device clipboard before injecting Ctrl+v (
set_device_clipboard()
just below).