diff options
| author | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-09 14:36:09 +0200 | 
|---|---|---|
| committer | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-09 14:36:09 +0200 | 
| commit | ccf3ac8d0c95f6edbb967d62862681da1a89bb01 (patch) | |
| tree | b23943d1b0a4fbecf2c18127a9db2405142fdcb2 | |
| parent | e2adf0059fee7d486fe00bb2585de1133115b87f (diff) | |
Drop second socket for input handling and use just one
| -rw-r--r-- | input.c | 10 | ||||
| -rw-r--r-- | main.c | 10 | 
2 files changed, 9 insertions, 11 deletions
| @@ -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;  } @@ -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; | 
