Ignore:
Timestamp:
03/10/22 14:18:58 (2 years ago)
Author:
Sanahuja Guillaume
Message:

add timeout for ds3 input event

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/Controller/DualShock3/src/DualShock3.cpp

    r467 r470  
    382382    return parse_report_sixaxis_ds3(report, nr);
    383383  } else if (connectionType == UsbEvent) {
    384     return parse_input_event();
     384    return parse_input_event(100);
    385385  }
    386386  return false;
     
    391391}
    392392
    393 bool DualShock3::parse_input_event(void) {
     393bool DualShock3::parse_input_event(int timeout_ms) {
    394394  struct input_event ev[64];
    395         int i, rd;
    396 
     395  int i, rd;
     396  fd_set set;
     397  struct timeval timeout;
     398 
     399  FD_ZERO(&set);         // clear the set
     400  FD_SET(usb_fd, &set); // add our file descriptor to the set
     401
     402  timeout.tv_sec = 0;
     403  timeout.tv_usec = timeout_ms * 1000;
     404
     405  int rv = select(FD_SETSIZE, &set, NULL, NULL, &timeout);
     406   
     407  if (rv <=0) {
     408    return false;
     409  }
     410   
    397411  rd = read(usb_fd, ev, sizeof(struct input_event) * 64);
    398412
Note: See TracChangeset for help on using the changeset viewer.