10#if defined(VRPN_USE_HID)
15static const vrpn_uint16 NVIDIA_VENDOR = 0x955;
16static const vrpn_uint16 NVIDIA_SHIELD_USB = 0x7210;
17static const vrpn_uint16 NVIDIA_SHIELD_STEALTH_USB = 0x7214;
34 fprintf(stderr,
"vrpn_nVidia_shield::~vrpn_nVidia_shield(): delete failed\n");
66 struct timeval current_time;
124 if ( (bytes >= 6) && (buffer[0] == 2) ) {
136 buttons[8] = ( (buffer[1] & (1 << 0)) != 0);
137 buttons[20] = ( (buffer[1] & (1 << 7)) != 0);
138 channel[6] = buffer[2] / 255.0;
139 channel[7] = buffer[4] / 255.0;
141 }
else if ( (bytes == 16) && (buffer[0] == 1) ) {
167 int first_button = 0;
168 for (
int byte = first_byte;
byte < first_byte + num_bytes;
byte++) {
169 vrpn_uint8 value = buffer[byte];
170 for (
int btn = 0; btn < 8; btn++) {
171 vrpn_uint8 mask =
static_cast<vrpn_uint8
>(1 << btn);
172 buttons[8*(
byte - first_byte) + btn + first_button] = ((value & mask) != 0);
271 int first_joy_axis = 4;
272 int num_joy_axis = 4;
273 int first_analog = 0;
274 vrpn_uint8 *bufptr = &buffer[4];
275 for (
int axis = first_joy_axis; axis < first_joy_axis + num_joy_axis; axis++) {
276 vrpn_uint16 raw_val = vrpn_unbuffer_from_little_endian<vrpn_uint16>(bufptr);
277 vrpn_int32 signed_val = raw_val -
static_cast<int>(32767);
278 double value = signed_val / 32768.0;
279 channel[first_analog + axis - first_joy_axis] = value;
284 int first_trigger = 4;
287 bufptr = &buffer[12];
288 for (
int trig = first_trigger; trig < first_trigger + num_trigger; trig++) {
289 vrpn_uint16 raw_val = vrpn_unbuffer_from_little_endian<vrpn_uint16>(bufptr);
290 double value = raw_val / 65535.0;
291 channel[first_analog + trig - first_trigger] = value;
296 if (bytes > 0) {
type = buffer[0]; }
297 fprintf(stderr,
"vrpn_nVidia_shield_USB: Unrecognized report type (%u); # total bytes = %u\n",
type,
static_cast<unsigned>(bytes));
321 struct timeval current_time;
378 if ( (bytes >= 33) && (buffer[0] == 1) ) {
396 int first_button = 0;
397 for (
int byte = first_byte;
byte < first_byte + num_bytes;
byte++) {
398 vrpn_uint8 value = buffer[byte];
399 for (
int btn = 0; btn < 8; btn++) {
400 vrpn_uint8 mask =
static_cast<vrpn_uint8
>(1 << btn);
401 buttons[8*(
byte - first_byte) + btn + first_button] = ((value & mask) != 0);
413 buttons[12] = buffer[17] & 0x01;
414 buttons[11] = buffer[17] & 0x02;
415 buttons[13] = buffer[17] & 0x04;
514 int first_joy_axis = 0;
515 int num_joy_axis = 4;
516 int first_analog = 0;
517 vrpn_uint8 *bufptr = &buffer[9];
518 for (
int axis = first_joy_axis; axis < first_joy_axis + num_joy_axis; axis++) {
519 vrpn_uint16 raw_val = vrpn_unbuffer_from_little_endian<vrpn_uint16>(bufptr);
520 vrpn_int32 signed_val = raw_val -
static_cast<int>(32767);
521 double value = signed_val / 32768.0;
522 channel[first_analog + axis - first_joy_axis] = value;
527 int first_trigger = 0;
531 for (
int trig = first_trigger; trig < first_trigger + num_trigger; trig++) {
532 vrpn_uint16 raw_val = vrpn_unbuffer_from_little_endian<vrpn_uint16>(bufptr);
533 double value = raw_val / 65535.0;
534 channel[first_analog + trig - first_trigger] = value;
539 if (bytes > 0) {
type = buffer[0]; }
540 fprintf(stderr,
"vrpn_nVidia_shield_stealth_USB: Unrecognized report type (%u); # total bytes = %u\n",
type,
static_cast<unsigned>(bytes));
vrpn_float64 last[vrpn_CHANNEL_MAX]
vrpn_float64 channel[vrpn_CHANNEL_MAX]
vrpn_Analog(const char *name, vrpn_Connection *c=NULL)
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
Generic connection class not specific to the transport mechanism.
vrpn_uint16 product() const
Returns USB product ID of connected device May not contain valid if an already-open device was provid...
vrpn_HidInterface(vrpn_HidAcceptor *acceptor, vrpn_uint16 vendor=0, vrpn_uint16 product=0, hid_device *device=NULL)
Constructor If we already have a HID device from some other source, it can be passed and we'll take o...
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
vrpn_uint16 vendor() const
Returns USB vendor ID of connected device May not contain valid if an already-open device was provide...
Accepts any device with the given vendor and product IDs.
void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
vrpn_nVidia_shield_USB(const char *name, vrpn_Connection *c=0)
virtual void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
vrpn_nVidia_shield_stealth_USB(const char *name, vrpn_Connection *c=0)
void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
virtual void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
struct timeval d_timestamp
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
vrpn_nVidia_shield(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c=0, vrpn_uint16 vendor=0, vrpn_uint16 product=0)
virtual ~vrpn_nVidia_shield(void)
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
vrpn_HidAcceptor * d_filter
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
#define vrpn_gettimeofday