2
0
mirror of https://github.com/Genymobile/scrcpy synced 2025-08-31 06:15:25 +00:00

Implement device-to-computer clipboard copy

On Ctrl+C:
 - the client sends a GET_CLIPBOARD command to the device;
 - the device retrieve its current clipboard text and sends it in a
   GET_CLIPBOARD device event;
 - the client sets this text as the system clipboard text, so that it
   can be pasted in another application.

Fixes <https://github.com/Genymobile/scrcpy/issues/145>
This commit is contained in:
Romain Vimont
2019-05-30 15:23:01 +02:00
parent 3149e2cf4a
commit 63c078ee6c
13 changed files with 109 additions and 0 deletions

View File

@@ -126,6 +126,16 @@ collapse_notification_panel(struct controller *controller) {
}
}
static void
request_device_clipboard(struct controller *controller) {
struct control_event control_event;
control_event.type = CONTROL_EVENT_TYPE_GET_CLIPBOARD;
if (!controller_push_event(controller, &control_event)) {
LOGW("Cannot get device clipboard");
}
}
static void
switch_fps_counter_state(struct video_buffer *vb) {
mutex_lock(vb->mutex);
@@ -250,6 +260,12 @@ input_manager_process_key(struct input_manager *input_manager,
action_volume_up(input_manager->controller, action);
}
return;
case SDLK_c:
if (control && ctrl && !meta && !shift && !repeat
&& event->type == SDL_KEYDOWN) {
request_device_clipboard(input_manager->controller);
}
return;
case SDLK_v:
if (control && ctrl && !meta && !shift && !repeat
&& event->type == SDL_KEYDOWN) {