Changeset 290 in flair-src for trunk/tools/Controller/DualShock3
- Timestamp:
- Jan 8, 2019, 5:45:23 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/Controller/DualShock3/src/DualShock3.cpp
r214 r290 39 39 #include <bluetooth/hci.h> 40 40 #include <bluetooth/hci_lib.h> 41 #include <sys/file.h> 41 42 42 43 #define USB_DIR_IN 0x80 … … 156 157 dev_name << "/dev/hidraw" << i; 157 158 if ((usb_fd = open(dev_name.str().c_str(), O_RDONLY)) >= 0) { 158 int res = 0; 159 int res=flock(usb_fd, LOCK_EX|LOCK_NB); 160 if(res<0) { 161 Thread::Warn("%s seems to be locked by another application\n", dev_name.str().c_str()); 162 close(usb_fd); 163 continue; 164 } 165 159 166 struct hidraw_devinfo info; 160 161 167 res = ioctl(usb_fd, HIDIOCGRAWINFO, &info); 162 168 if (res < 0) { 163 Thread::Err("ioctl error (HIDIOCGRAWINFO) on %s\n", 164 dev_name.str().c_str()); 169 Thread::Err("ioctl error (HIDIOCGRAWINFO) on %s\n",dev_name.str().c_str()); 165 170 } else { 166 171 // Printf("%x %x\n", info.vendor, info.product); … … 171 176 } 172 177 } 178 flock(usb_fd, LOCK_UN); 173 179 close(usb_fd); 174 180 } … … 193 199 DualShock3::~DualShock3() { 194 200 if (connectionType == Usb) { 201 flock(usb_fd, LOCK_UN); 195 202 close(usb_fd); 196 203 }
Note:
See TracChangeset
for help on using the changeset viewer.