summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2023-04-09 14:36:09 +0200
committerMikhail Burakov <mburakov@mailbox.org>2023-04-09 14:36:09 +0200
commitccf3ac8d0c95f6edbb967d62862681da1a89bb01 (patch)
treeb23943d1b0a4fbecf2c18127a9db2405142fdcb2
parente2adf0059fee7d486fe00bb2585de1133115b87f (diff)
Drop second socket for input handling and use just one
-rw-r--r--input.c10
-rw-r--r--main.c10
2 files changed, 9 insertions, 11 deletions
diff --git a/input.c b/input.c
index 3644ef0..2ece28b 100644
--- a/input.c
+++ b/input.c
@@ -251,11 +251,13 @@ bool InputStreamMouseWheel(struct InputStream* input_stream, int delta) {
bool InputStreamHandsoff(struct InputStream* input_stream) {
memset(input_stream->key_state, 0, sizeof(input_stream->key_state));
- static const struct uhid_event uhid_event_input2 = {
- .type = UHID_INPUT2,
+ memset(&input_stream->button_state, 0, sizeof(input_stream->button_state));
+ static const uint8_t uhid_event_input2[] = {
+ UHID_INPUT2, 0x00, 0x00, 0x00, 0x08, 0x00, 1, 0, 0, 0, 0, 0, 0, 0,
+ UHID_INPUT2, 0x00, 0x00, 0x00, 0x07, 0x00, 2, 0, 0, 0, 0, 0, 0,
};
- bool result = Drain(input_stream->fd, &uhid_event_input2,
- sizeof(uhid_event_input2.type));
+ bool result =
+ Drain(input_stream->fd, uhid_event_input2, sizeof(uhid_event_input2));
if (!result) LOG("Failed to drain handsoff");
return result;
}
diff --git a/main.c b/main.c
index e398b51..aaba0ba 100644
--- a/main.c
+++ b/main.c
@@ -137,19 +137,15 @@ static void DecodeContextDtor(struct DecodeContext** decode_context) {
}
int main(int argc, char* argv[]) {
- if (argc < 3) {
- LOG("Usage: %s <ip>:<port> <ip>:<port>", argv[0]);
+ if (argc < 2) {
+ LOG("Usage: %s <ip>:<port>", argv[0]);
return EXIT_FAILURE;
}
int __attribute__((cleanup(SocketDtor))) sock = ConnectSocket(argv[1]);
if (sock == -1) return EXIT_FAILURE;
- // TODO(mburakov): Use sock instead of sock2 once backend is ready.
- int __attribute__((cleanup(SocketDtor))) sock2 = ConnectSocket(argv[2]);
- if (sock2 == -1) return EXIT_FAILURE;
-
struct InputStream __attribute__((cleanup(InputStreamDtor)))* input_stream =
- InputStreamCreate(sock2);
+ InputStreamCreate(sock);
if (!input_stream) {
LOG("Failed to create input stream");
return EXIT_FAILURE;