Changeset 470 in flair-src


Ignore:
Timestamp:
Mar 10, 2022, 2:18:58 PM (3 years ago)
Author:
Sanahuja Guillaume
Message:

add timeout for ds3 input event

Location:
trunk/tools/Controller/DualShock3/src
Files:
2 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
  • trunk/tools/Controller/DualShock3/src/DualShock3.h

    r467 r470  
    7979  void setup_device(struct motion_dev *dev);
    8080  bool parse_report_sixaxis_ds3(unsigned char *r, int len);
    81   bool parse_input_event(void);
     81  bool parse_input_event(int timeout_ms);
    8282  int mystr2ba(const char *s, bdaddr_t *ba);
    8383  char *myba2str(const bdaddr_t *ba);
Note: See TracChangeset for help on using the changeset viewer.