2022-04-13 05:59:01 +08:00
|
|
|
#ifndef SC_RECEIVER_H
|
|
|
|
#define SC_RECEIVER_H
|
2019-05-30 06:25:37 +08:00
|
|
|
|
2021-01-09 02:24:51 +08:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-05-30 06:25:37 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
Wait SET_CLIPBOARD ack before Ctrl+v via HID
To allow seamless copy-paste, on Ctrl+v, a SET_CLIPBOARD request is
performed before injecting Ctrl+v.
But when HID keyboard is enabled, the Ctrl+v injection is not sent on
the same channel as the clipboard request, so they are not serialized,
and may occur in any order. If Ctrl+v happens to be injected before the
new clipboard content is set, then the old content is pasted instead,
which is incorrect.
To minimize the probability of occurrence of the wrong order, a delay of
2 milliseconds was added before injecting Ctrl+v. Then 5ms. But even
with 5ms, the wrong behavior sometimes happens.
To handle it properly, add an acknowledgement mechanism, so that Ctrl+v
is injected over AOA only after the SET_CLIPBOARD request has been
performed and acknowledged by the server.
Refs e4163321f00bb3830c6049bdb6c1515e7cc668a0
Refs 45b0f8123a52f5c73a5860d616f4ceba2766ca6a
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814>
2021-11-22 00:40:11 +08:00
|
|
|
#include "util/acksync.h"
|
2019-11-24 18:53:00 +08:00
|
|
|
#include "util/net.h"
|
2021-02-01 01:24:35 +08:00
|
|
|
#include "util/thread.h"
|
2019-05-30 06:25:37 +08:00
|
|
|
|
|
|
|
// receive events from the device
|
|
|
|
// managed by the controller
|
|
|
|
struct receiver {
|
2021-10-27 04:49:45 +08:00
|
|
|
sc_socket control_socket;
|
2021-02-01 01:24:35 +08:00
|
|
|
sc_thread thread;
|
|
|
|
sc_mutex mutex;
|
Wait SET_CLIPBOARD ack before Ctrl+v via HID
To allow seamless copy-paste, on Ctrl+v, a SET_CLIPBOARD request is
performed before injecting Ctrl+v.
But when HID keyboard is enabled, the Ctrl+v injection is not sent on
the same channel as the clipboard request, so they are not serialized,
and may occur in any order. If Ctrl+v happens to be injected before the
new clipboard content is set, then the old content is pasted instead,
which is incorrect.
To minimize the probability of occurrence of the wrong order, a delay of
2 milliseconds was added before injecting Ctrl+v. Then 5ms. But even
with 5ms, the wrong behavior sometimes happens.
To handle it properly, add an acknowledgement mechanism, so that Ctrl+v
is injected over AOA only after the SET_CLIPBOARD request has been
performed and acknowledged by the server.
Refs e4163321f00bb3830c6049bdb6c1515e7cc668a0
Refs 45b0f8123a52f5c73a5860d616f4ceba2766ca6a
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814>
2021-11-22 00:40:11 +08:00
|
|
|
|
|
|
|
struct sc_acksync *acksync;
|
2019-05-30 06:25:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
Wait SET_CLIPBOARD ack before Ctrl+v via HID
To allow seamless copy-paste, on Ctrl+v, a SET_CLIPBOARD request is
performed before injecting Ctrl+v.
But when HID keyboard is enabled, the Ctrl+v injection is not sent on
the same channel as the clipboard request, so they are not serialized,
and may occur in any order. If Ctrl+v happens to be injected before the
new clipboard content is set, then the old content is pasted instead,
which is incorrect.
To minimize the probability of occurrence of the wrong order, a delay of
2 milliseconds was added before injecting Ctrl+v. Then 5ms. But even
with 5ms, the wrong behavior sometimes happens.
To handle it properly, add an acknowledgement mechanism, so that Ctrl+v
is injected over AOA only after the SET_CLIPBOARD request has been
performed and acknowledged by the server.
Refs e4163321f00bb3830c6049bdb6c1515e7cc668a0
Refs 45b0f8123a52f5c73a5860d616f4ceba2766ca6a
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814>
2021-11-22 00:40:11 +08:00
|
|
|
receiver_init(struct receiver *receiver, sc_socket control_socket,
|
|
|
|
struct sc_acksync *acksync);
|
2019-05-30 06:25:37 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
receiver_destroy(struct receiver *receiver);
|
|
|
|
|
|
|
|
bool
|
|
|
|
receiver_start(struct receiver *receiver);
|
|
|
|
|
|
|
|
// no receiver_stop(), it will automatically stop on control_socket shutdown
|
|
|
|
|
|
|
|
void
|
|
|
|
receiver_join(struct receiver *receiver);
|
|
|
|
|
|
|
|
#endif
|