From ccf3ac8d0c95f6edbb967d62862681da1a89bb01 Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Sun, 9 Apr 2023 14:36:09 +0200 Subject: Drop second socket for input handling and use just one --- input.c | 10 ++++++---- main.c | 10 +++------- 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 : :", argv[0]); + if (argc < 2) { + LOG("Usage: %s :", 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; -- cgit v1.2.3