Changeset 22 in pacpussensors for trunk/Dualshock
- Timestamp:
- Aug 2, 2013, 4:19:44 PM (11 years ago)
- Location:
- trunk/Dualshock
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Dualshock/controller.cpp
r21 r22 1 /********************************************************************* 2 // created: 2012/03/01 - 14:06 3 // filename: controller.cpp 4 // 5 // author: Pierre Hudelaine 6 // Copyright Heudiasyc UMR UTC/CNRS 7253 7 // 8 // version: $Id: $ 9 // 10 // purpose: Read the dualshock 3 button using bluetooth 11 // 12 *********************************************************************/ 13 1 14 #include "controller.h" 2 15 … … 45 58 struct dualshockButtons_s d; 46 59 d.available = controller.paired; 60 d.timeout = controller.timeout; 47 61 d.buttons = controller.buttons; 48 62 d.time = road_time(); … … 73 87 //std::cerr << " elem\n"; 74 88 //std::cerr << "Select\n"; 75 struct timeval tv = {2, 0}; //timeout = 2s 76 if (select(fdmax + 1, &fds, NULL, NULL, &tv) < 0) 89 struct timeval tv = {0, 500 * 1000}; //timeout = 0.5s 90 int ret = 0; 91 ret = select(fdmax + 1, &fds, NULL, NULL, &tv); 92 if (ret < 0) 77 93 throw "Select"; 94 95 controller.timeout = (ret == 0 && controller.paired); 78 96 79 97 if (FD_ISSET(csk, &fds)) … … 87 105 handle_report(report, nr); 88 106 } 107 update_shared_memory(); 89 108 } 90 109 quit = 2; … … 129 148 controller.addr = baddr; 130 149 controller.paired = 1; 150 controller.timeout = 0; 131 151 controller.csk = cs; 132 152 controller.isk = is; … … 149 169 HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUTPUT, 0x01, 150 170 '\00', '\00', '\00', '\00', '\00', '\00', '\00', '\00', 151 '\00', static_cast<char>( ledmask[index % 10]<< 1),171 '\00', static_cast<char>(index << 1), 152 172 LED_PERMANENT, 153 173 LED_PERMANENT, … … 217 237 controller.buttons.axis.z = buf[47]; 218 238 controller.buttons.axis.gZ = buf[47]; 219 220 update_shared_memory();221 239 } 222 240 -
trunk/Dualshock/controller.h
r21 r22 1 /********************************************************************* 2 // created: 2012/03/01 - 14:06 3 // filename: controller.cpp 4 // 5 // author: Pierre Hudelaine 6 // Copyright Heudiasyc UMR UTC/CNRS 7253 7 // 8 // version: $Id: $ 9 // 10 // purpose: Read the dualshock 3 button using bluetooth 11 // 12 *********************************************************************/ 13 1 14 #ifndef CONTROLLER_H 2 15 # define CONTROLLER_H … … 86 99 int isk; 87 100 int paired; 101 int timeout; 88 102 unsigned index; 89 103 }; … … 93 107 struct buttons_s buttons; 94 108 int available; 109 int timeout; 95 110 }; 96 111 -
trunk/Dualshock/dualshock.cpp
r21 r22 1 /********************************************************************* 2 // created: 2012/03/01 - 14:06 3 // filename: dualshock.cpp 4 // 5 // author: Pierre Hudelaine 6 // Copyright Heudiasyc UMR UTC/CNRS 7253 7 // 8 // version: $Id: $ 9 // 10 // purpose: Read the dualshock 3 button using bluetooth 11 // 12 *********************************************************************/ 13 1 14 #include "dualshock.h" 2 15 -
trunk/Dualshock/dualshock.h
r21 r22 1 /********************************************************************* 2 // created: 2012/03/01 - 14:06 3 // filename: dualshock.cpp 4 // 5 // author: Pierre Hudelaine 6 // Copyright Heudiasyc UMR UTC/CNRS 7253 7 // 8 // version: $Id: $ 9 // 10 // purpose: Read the dualshock 3 button using bluetooth 11 // 12 *********************************************************************/ 13 1 14 #ifndef DUALSHOCK_H 2 15 # define DUALSHOCK_H
Note:
See TracChangeset
for help on using the changeset viewer.