vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Xkeys.C
Go to the documentation of this file.
1 // vrpn_Xkeys.C: VRPN driver for P.I. Engineering's X-Keys devices
2 
3 #include <stdio.h> // for fprintf, stderr, NULL
4 #include <string.h> // for memset
5 
6 #include "vrpn_Xkeys.h"
7 
9 
10 #if defined(VRPN_USE_HID)
11 
12 // USB vendor and product IDs for the models we support
13 static const vrpn_uint16 XKEYS_VENDOR = 0x05F3;
14 static const vrpn_uint16 XKEYS_DESKTOP = 0x0281;
15 static const vrpn_uint16 XKEYS_JOG_AND_SHUTTLE = 0x0241;
16 static const vrpn_uint16 XKEYS_PRO = 0x0291;
17 static const vrpn_uint16 XKEYS_JOYSTICK = 0x0251;
18 static const vrpn_uint16 XKEYS_XK3 = 0x042C;
19 
20 vrpn_Xkeys::vrpn_Xkeys(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c, bool toggle_light)
21  : _filter(filter)
22  , vrpn_HidInterface(filter)
23  , vrpn_BaseClass(name, c)
24  , _toggle_light(toggle_light)
25 {
26  init_hid();
27 }
28 
30 {
31  if (_toggle_light) {
32  // Indicate we're no longer waiting for a connection by
33  // turning off both the red and green LEDs.
34  vrpn_uint8 outputs[9] = {0};
35  outputs[8] = 0;
36  send_data(9, outputs);
37 
38  }
39  delete _filter;
40 }
41 
43  // Get notifications when clients connect and disconnect
46 
47  // Indicate we're waiting for a connection by turning on the red LED
48  if (_toggle_light) {
49  vrpn_uint8 outputs[9] = {0};
50  outputs[8] = 128;
51  send_data(9, outputs);
52  }
53 }
54 
55 void vrpn_Xkeys::on_data_received(size_t bytes, vrpn_uint8 *buffer)
56 {
57  decodePacket(bytes, buffer);
58 }
59 
61 {
62  vrpn_Xkeys *me = static_cast<vrpn_Xkeys *>(thisPtr);
63  if (me->_toggle_light) {
64  // Set light to red to indicate we have no active connections
65  vrpn_uint8 outputs[9] = {0};
66  outputs[8] = 128;
67  me->send_data(9, outputs);
68  }
69  return 0;
70 }
71 
72 int vrpn_Xkeys::on_connect(void *thisPtr, vrpn_HANDLERPARAM /*p*/)
73 {
74  vrpn_Xkeys *me = static_cast<vrpn_Xkeys *>(thisPtr);
75 
76  if (me->_toggle_light) {
77  // Set light to green to indicate we have an active connection
78  vrpn_uint8 outputs[9] = {0};
79  outputs[8] = 64;
80  me->send_data(9, outputs);
81  }
82  return 0;
83 }
84 
86  : vrpn_Xkeys(_filter = new vrpn_HidProductAcceptor(XKEYS_VENDOR, XKEYS_DESKTOP), name, c)
87  , vrpn_Button_Filter(name, c)
88 {
89  // 21 buttons (don't forget about button 0)
91 
92  // Initialize the state of all the buttons
93  memset(buttons, 0, sizeof(buttons));
94  memset(lastbuttons, 0, sizeof(lastbuttons));
95 }
96 
98 {
99  update();
100  server_mainloop();
102  report_changes();
103 
105 }
106 
110 }
111 
115 }
116 
117 void vrpn_Xkeys_Desktop::decodePacket(size_t bytes, vrpn_uint8 *buffer) {
118  // Decode all full reports, each of which is 11 bytes long.
119  // Because there is only one type of report, the initial "0" report-type
120  // byte is removed by the HIDAPI driver.
121  for (size_t i = 0; i < bytes / 11; i++) {
122  vrpn_uint8 *report = buffer + (i * 11);
123 
124  if (!(report[10] & 0x08)) {
125  // Apparently we got a corrupted report; skip this one.
126  fprintf(stderr, "vrpn_Xkeys_Desktop: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
127  continue;
128  }
129 
130  // Decode the "programming switch"
131  buttons[0] = (report[10] & 0x10) != 0;
132 
133  // Decode the other buttons into column-major order
134  for (int btn = 0; btn < 20; btn++) {
135  vrpn_uint8 *offset, mask;
136 
137  offset = report + btn / 5;
138  mask = static_cast<vrpn_uint8>(1 << (btn % 5));
139 
140  buttons[btn + 1] = (*offset & mask) != 0;
141  }
142  }
143 }
144 
146  : vrpn_Xkeys(_filter = new vrpn_HidProductAcceptor(XKEYS_VENDOR, XKEYS_JOG_AND_SHUTTLE), name, c)
147  , vrpn_Button_Filter(name, c)
148  , vrpn_Analog(name, c)
149  , vrpn_Dial(name, c)
150 {
153  vrpn_Button::num_buttons = 59; // Don't forget button 0
154 
155  // Initialize the state of all the analogs, buttons, and dials
156  _lastDial = 0;
157  memset(buttons, 0, sizeof(buttons));
158  memset(lastbuttons, 0, sizeof(lastbuttons));
159  memset(channel, 0, sizeof(channel));
160  memset(last, 0, sizeof(last));
161 }
162 
164 {
165  update();
166  server_mainloop();
168  report_changes();
169 
173 }
174 
175 void vrpn_Xkeys_Jog_And_Shuttle::report(vrpn_uint32 class_of_service) {
179 
180  vrpn_Analog::report(class_of_service);
183 }
184 
185 void vrpn_Xkeys_Jog_And_Shuttle::report_changes(vrpn_uint32 class_of_service) {
189 
190  vrpn_Analog::report_changes(class_of_service);
193 }
194 
195 void vrpn_Xkeys_Jog_And_Shuttle::decodePacket(size_t bytes, vrpn_uint8 *buffer)
196 {
197  // Decode all full reports.
198  // Full reports for all of the pro devices are 15 bytes long.
199  // Because there is only one type of report, the initial "0" report-type
200  // byte is removed by the HIDAPI driver, leaving 14 bytes.
201  // Also, it appears as though the
202  // remaining 14-byte command is split into two, one 8-byte that is sent
203  // first and then a 6-byte that is sent later. So we need to check the
204  // length of the packet to see which it is and then parse it appropriately.
205  if (bytes == 8) { // The first 8 bytes of a report (happens on Linux)
206 
207  // Report jog dial as analog and dial
208  // Report shuttle knob as analog
209 
210  // Double cast on channel 0 ensures negative values stay negative
211  channel[0] = static_cast<float>(static_cast<signed char>(buffer[0])) / 7.0;
212  channel[1] = static_cast<float>(buffer[1]);
213 
214  // Do the unsigned/signed conversion at the last minute so the
215  // signed values work properly.
216  dials[0] = static_cast<vrpn_int8>(buffer[1] - _lastDial) / 256.0;
217 
218  // Store the current dial position for the next delta
219  _lastDial = buffer[1];
220 
221  // Decode the other buttons in column-major order. We skip the
222  // first three bytes, which record the joystick value or the
223  // shuttle/jog value (depending on device).
224  // This results in some gaps when using a shuttle or joystick model,
225  // but there really aren't any internally consistent numbering schemes.
226  // The first 35 buttons are in this report, the remaining 23 in the next.
227  for (int btn = 0; btn < 35; btn++) {
228  vrpn_uint8 *offset, mask;
229 
230  offset = buffer + btn / 7 + 3;
231  mask = static_cast<vrpn_uint8>(1 << (btn % 7));
232 
233  buttons[btn + 1] = (*offset & mask) != 0;
234  }
235 
236  } else if (bytes == 6) { // The last 6 bytes of a report (happens on Linux)
237 
238  if (!(buffer[5] & 0x08)) {
239  // Garbled report; skip it
240  fprintf(stderr, "vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
241  return;
242  }
243 
244  // Decode the "programming switch"
245  buttons[0] = (buffer[5] & 0x10) != 0;
246 
247  // Decode the other buttons in column-major order.
248  // This results in some gaps when using a shuttle or joystick model,
249  // but there really aren't any internally consistent numbering schemes.
250  // The last 23 buttons are in this report, the remaining 23 in the next.
251  for (int btn = 35; btn < 58; btn++) {
252  vrpn_uint8 *offset, mask;
253  int local_btn = btn - 35;
254 
255  offset = buffer + local_btn / 7;
256  mask = static_cast<vrpn_uint8>(1 << (local_btn % 7));
257 
258  buttons[btn + 1] = (*offset & mask) != 0;
259  }
260 
261  } else if (bytes == 14) { // A full report in one swoop (happens on Windows)
262  // Full reports for all of the pro devices are 15 bytes long.
263  // Because there is only one type of report, the initial "0" report-type
264  // byte is removed by the HIDAPI driver, leaving 14 bytes.
265  size_t i;
266  for (i = 0; i < bytes / 14; i++) {
267  vrpn_uint8 *report = buffer + (i * 14);
268 
269  if (!(report[13] & 0x08)) {
270  // Garbled report; skip it
271  fprintf(stderr, "vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
272  continue;
273  }
274 
275  // Decode the "programming switch"
276  buttons[0] = (report[13] & 0x10) != 0;
277 
278  // Decode the other buttons in column-major order
279  // This results in some gaps when using a shuttle or joystick model,
280  // but there really aren't any internally consistent numbering schemes.
281  for (int btn = 0; btn < 58; btn++) {
282  vrpn_uint8 *offset, mask;
283 
284  offset = report + btn / 7 + 3;
285  mask = static_cast<vrpn_uint8>(1 << (btn % 7));
286 
287  buttons[btn + 1] = (*offset & mask) != 0;
288  }
289 
290  // Report jog dial as analog and dial
291  // Report shuttle knob as analog
292 
293  // Double cast on channel 0 ensures negative values stay negative
294  channel[0] = static_cast<float>(static_cast<signed char>(report[0])) / 7.0;
295  channel[1] = static_cast<float>(report[1]);
296 
297  // Do the unsigned/signed conversion at the last minute so the
298  // signed values work properly.
299  dials[0] = static_cast<vrpn_int8>(report[1] - _lastDial) / 256.0;
300 
301  // Store the current dial position for the next delta
302  _lastDial = report[1];
303 
304  }
305  } else {
306  fprintf(stderr,"vrpn_Xkeys_Jog_And_Shuttle::decodePacket(): Unrecognized packet length (%u)\n", static_cast<unsigned>(bytes));
307  return;
308  }
309 }
310 
312  : vrpn_Xkeys(_filter = new vrpn_HidProductAcceptor(XKEYS_VENDOR, XKEYS_JOYSTICK), name, c)
313  , vrpn_Button_Filter(name, c)
314  , vrpn_Analog(name, c)
315 {
317  vrpn_Button::num_buttons = 59; // Don't forget button 0
318 
319  // Initialize the state of all the analogs and buttons
320  memset(buttons, 0, sizeof(buttons));
321  memset(lastbuttons, 0, sizeof(lastbuttons));
322  memset(channel, 0, sizeof(channel));
323  memset(last, 0, sizeof(last));
324 }
325 
327 {
328  update();
329  server_mainloop();
331  report_changes();
332 
335 }
336 
337 void vrpn_Xkeys_Joystick::report(vrpn_uint32 class_of_service) {
340 
341  vrpn_Analog::report(class_of_service);
343 }
344 
345 void vrpn_Xkeys_Joystick::report_changes(vrpn_uint32 class_of_service) {
348 
349  vrpn_Analog::report_changes(class_of_service);
351 }
352 
353 void vrpn_Xkeys_Joystick::decodePacket(size_t bytes, vrpn_uint8 *buffer)
354 {
355  // Decode all full reports.
356  // Full reports for all of the pro devices are 15 bytes long.
357  // Because there is only one type of report, the initial "0" report-type
358  // byte is removed by the HIDAPI driver, leaving 14 bytes.
359  // Also, it appears as though the
360  // remaining 14-byte command is split into two, one 8-byte that is sent
361  // first and then a 6-byte that is sent later. So we need to check the
362  // length of the packet to see which it is and then parse it appropriately.
363  if (bytes == 8) { // The first 8 bytes of a report
364 
365  // Report joystick axes as analogs
366  channel[0] = (static_cast<float>(buffer[0]) - 128) / 128.0;
367  channel[1] = (static_cast<float>(buffer[1]) - 128) / 128.0;
368  channel[2] = (static_cast<float>(buffer[2]) - 128) / 128.0;
369 
370  // Decode the other buttons in column-major order. We skip the
371  // first three bytes, which record the joystick value or the
372  // shuttle/jog value (depending on device).
373  // This results in some gaps when using a shuttle or joystick model,
374  // but there really aren't any internally consistent numbering schemes.
375  // The first 35 buttons are in this report, the remaining 23 in the next.
376  for (int btn = 0; btn < 35; btn++) {
377  vrpn_uint8 *offset, mask;
378 
379  offset = buffer + btn / 7 + 3;
380  mask = static_cast<vrpn_uint8>(1 << (btn % 7));
381 
382  buttons[btn + 1] = (*offset & mask) != 0;
383  }
384 
385  } else if (bytes == 6) { // The last 6 bytes of a report
386 
387  if (!(buffer[5] & 0x08)) {
388  // Garbled report; skip it
389  fprintf(stderr, "vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
390  return;
391  }
392 
393  // Decode the "programming switch"
394  buttons[0] = (buffer[5] & 0x10) != 0;
395 
396  // Decode the other buttons in column-major order.
397  // This results in some gaps when using a shuttle or joystick model,
398  // but there really aren't any internally consistent numbering schemes.
399  // The last 23 buttons are in this report, the remaining 23 in the next.
400  for (int btn = 35; btn < 58; btn++) {
401  vrpn_uint8 *offset, mask;
402  int local_btn = btn - 35;
403 
404  offset = buffer + local_btn / 7;
405  mask = static_cast<vrpn_uint8>(1 << (local_btn % 7));
406 
407  buttons[btn + 1] = (*offset & mask) != 0;
408  }
409 
410  } else if (bytes == 14) { // A full report in one swoop (happens on Windows)
411  // Full reports for all of the pro devices are 15 bytes long.
412  // Because there is only one type of report, the initial "0" report-type
413  // byte is removed by the HIDAPI driver, leaving 14 bytes.
414  size_t i;
415  for (i = 0; i < bytes / 14; i++) {
416  vrpn_uint8 *report = buffer + (i * 14);
417 
418  if (!(report[13] & 0x08)) {
419  // Garbled report; skip it
420  fprintf(stderr, "vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
421  continue;
422  }
423 
424  // Decode the "programming switch"
425  buttons[0] = (report[13] & 0x10) != 0;
426 
427  // Decode the other buttons in column-major order
428  // This results in some gaps when using a shuttle or joystick model,
429  // but there really aren't any internally consistent numbering schemes.
430  for (int btn = 0; btn < 58; btn++) {
431  vrpn_uint8 *offset, mask;
432 
433  offset = report + btn / 7 + 3;
434  mask = static_cast<vrpn_uint8>(1 << (btn % 7));
435 
436  buttons[btn + 1] = (*offset & mask) != 0;
437  }
438 
439  // Report joystick axes as analogs
440  channel[0] = (static_cast<float>(report[0]) - 128) / 128.0;
441  channel[1] = (static_cast<float>(report[1]) - 128) / 128.0;
442  channel[2] = (static_cast<float>(report[2]) - 128) / 128.0;
443  }
444  } else {
445  fprintf(stderr,"vrpn_Xkeys_Joystick::decodePacket(): Unrecognized packet length (%u)\n", static_cast<unsigned>(bytes));
446  return;
447  }
448 }
449 
451  : vrpn_Xkeys(_filter = new vrpn_HidProductAcceptor(XKEYS_VENDOR, XKEYS_PRO), name, c)
452  , vrpn_Button_Filter(name, c)
453 {
454  vrpn_Button::num_buttons = 59; // Don't forget button 0
455 
456  // Initialize the state of all the buttons
457  memset(buttons, 0, sizeof(buttons));
458  memset(lastbuttons, 0, sizeof(lastbuttons));
459 }
460 
462 {
463  update();
464  server_mainloop();
466  report_changes();
467 
469 }
470 
474 }
475 
479 }
480 
481 void vrpn_Xkeys_Pro::decodePacket(size_t bytes, vrpn_uint8 *buffer)
482 {
483  // Decode all full reports.
484  // Full reports for all of the pro devices are 15 bytes long.
485  // Because there is only one type of report, the initial "0" report-type
486  // byte is removed by the HIDAPI driver, leaving 14 bytes.
487  // Also, it appears as though the
488  // remaining 14-byte command is split into two, one 8-byte that is sent
489  // first and then a 6-byte that is sent later. So we need to check the
490  // length of the packet to see which it is and then parse it appropriately.
491  if (bytes == 8) { // The first 8 bytes of a report
492 
493  // Decode the other buttons in column-major order. We skip the
494  // first three bytes, which record the joystick value or the
495  // shuttle/jog value (depending on device).
496  // This results in some gaps when using a shuttle or joystick model,
497  // but there really aren't any internally consistent numbering schemes.
498  // The first 35 buttons are in this report, the remaining 23 in the next.
499  for (int btn = 0; btn < 35; btn++) {
500  vrpn_uint8 *offset, mask;
501 
502  offset = buffer + btn / 7 + 3;
503  mask = static_cast<vrpn_uint8>(1 << (btn % 7));
504 
505  buttons[btn + 1] = (*offset & mask) != 0;
506  }
507 
508  } else if (bytes == 6) { // The last 6 bytes of a report
509 
510  if (!(buffer[5] & 0x08)) {
511  // Garbled report; skip it
512  fprintf(stderr, "vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
513  return;
514  }
515 
516  // Decode the "programming switch"
517  buttons[0] = (buffer[5] & 0x10) != 0;
518 
519  // Decode the other buttons in column-major order.
520  // This results in some gaps when using a shuttle or joystick model,
521  // but there really aren't any internally consistent numbering schemes.
522  // The last 23 buttons are in this report, the remaining 23 in the next.
523  for (int btn = 35; btn < 58; btn++) {
524  vrpn_uint8 *offset, mask;
525  int local_btn = btn - 35;
526 
527  offset = buffer + local_btn / 7;
528  mask = static_cast<vrpn_uint8>(1 << (local_btn % 7));
529 
530  buttons[btn + 1] = (*offset & mask) != 0;
531  }
532 
533  } else if (bytes == 14) { // A full report in one swoop (happens on Windows)
534  // Full reports for all of the pro devices are 15 bytes long.
535  // Because there is only one type of report, the initial "0" report-type
536  // byte is removed by the HIDAPI driver, leaving 14 bytes.
537  size_t i;
538  // Decode all full reports.
539  // Full reports for all of the pro devices are 15 bytes long.
540  for (i = 0; i < bytes / 14; i++) {
541  vrpn_uint8 *report = buffer + (i * 14);
542 
543  if (!(report[13] & 0x08)) {
544  // Garbled report; skip it
545  fprintf(stderr, "vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
546  continue;
547  }
548 
549  // Decode the "programming switch"
550  buttons[0] = (report[13] & 0x10) != 0;
551 
552  // Decode the other buttons in column-major order
553  // This results in some gaps when using a shuttle or joystick model,
554  // but there really aren't any internally consistent numbering schemes.
555  for (int btn = 0; btn < 58; btn++) {
556  vrpn_uint8 *offset, mask;
557 
558  offset = buffer + btn / 7 + 3;
559  mask = static_cast<vrpn_uint8>(1 << (btn % 7));
560 
561  buttons[btn + 1] = (*offset & mask) != 0;
562  }
563  }
564  } else {
565  fprintf(stderr,"vrpn_Xkeys_Pro::decodePacket(): Unrecognized packet length (%u)\n", static_cast<unsigned>(bytes));
566  return;
567  }
568 }
569 
571  : vrpn_Xkeys(_filter = new vrpn_HidProductAcceptor(XKEYS_VENDOR, XKEYS_XK3), name, c, false)
572  , vrpn_Button_Filter(name, c)
573 {
574  // 3 buttons
576 
577  // Initialize the state of all the buttons
578  memset(buttons, 0, sizeof(buttons));
579  memset(lastbuttons, 0, sizeof(lastbuttons));
580 }
581 
583 {
584  update();
585  server_mainloop();
587  report_changes();
588 
590 }
591 
595 }
596 
600 }
601 
602 void vrpn_Xkeys_XK3::decodePacket(size_t bytes, vrpn_uint8 *buffer) {
603  // Decode all full reports, each of which is 32 bytes long.
604  // Because there is only one type of report, the initial "0" report-type
605  // byte is removed by the HIDAPI driver.
606  for (size_t i = 0; i < bytes / 32; i++) {
607  vrpn_uint8 *report = buffer + (i * 32);
608 
609  // The first two bytes of the report always seem to be
610  // 0x00 0x01.
611  if ((report[0] != 0x00) || (report[1] != 0x01) ) {
612  // Apparently we got a corrupted report; skip this one.
613  fprintf(stderr, "vrpn_Xkeys_XK3: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
614  continue;
615  }
616 
617  // The left button is bit 1 (value 0x02) in the third byte
618  // The middle button is bit 2 (value 0x04) in the third byte
619  // The right button is bit 3 (value 0x08) in the third byte
620  buttons[0] = (report[2] & 0x02) != 0;
621  buttons[1] = (report[2] & 0x04) != 0;
622  buttons[2] = (report[2] & 0x08) != 0;
623  }
624 }
625 
626 // End of VRPN_USE_HID
627 #endif
static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p)
Definition: vrpn_Xkeys.C:72
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
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...
Definition: vrpn_Analog.C:71
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Definition: vrpn_Xkeys.C:97
void init_hid()
Definition: vrpn_Xkeys.C:42
void report_changes(void)
Definition: vrpn_Xkeys.C:597
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Definition: vrpn_Xkeys.C:582
static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p)
Definition: vrpn_Xkeys.C:60
void report(void)
Definition: vrpn_Xkeys.C:107
void report_changes(void)
Definition: vrpn_Xkeys.C:112
vrpn_Xkeys_XK3(const char *name, vrpn_Connection *c=0)
Definition: vrpn_Xkeys.C:570
vrpn_Xkeys_Pro(const char *name, vrpn_Connection *c=0)
Definition: vrpn_Xkeys.C:450
virtual void report_changes(void)
Definition: vrpn_Dial.C:54
vrpn_int32 num_buttons
Definition: vrpn_Button.h:47
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Definition: vrpn_Xkeys.C:353
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Definition: vrpn_Xkeys.C:163
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
Definition: vrpn_Xkeys.C:55
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Definition: vrpn_Xkeys.C:117
vrpn_float64 channel[vrpn_CHANNEL_MAX]
Definition: vrpn_Analog.h:38
bool _toggle_light
Definition: vrpn_Xkeys.h:53
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Definition: vrpn_Xkeys.C:602
Accepts any device with the given vendor and product IDs.
struct timeval timestamp
Definition: vrpn_Dial.h:28
Generic connection class not specific to the transport mechanism.
vrpn_int32 num_dials
Definition: vrpn_Dial.h:27
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 ...
Definition: vrpn_Analog.C:94
#define VRPN_SUPPRESS_EMPTY_OBJECT_WARNING()
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Definition: vrpn_Xkeys.C:461
virtual ~vrpn_Xkeys()
Definition: vrpn_Xkeys.C:29
vrpn_Xkeys_Desktop(const char *name, vrpn_Connection *c=0)
Definition: vrpn_Xkeys.C:85
const char * vrpn_dropped_last_connection
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Definition: vrpn_Xkeys.C:195
virtual void report_changes(void)
Definition: vrpn_Button.C:382
virtual void report_changes(void)
Definition: vrpn_Button.C:422
vrpn_int32 num_channel
Definition: vrpn_Analog.h:40
vrpn_Xkeys_Jog_And_Shuttle(const char *name, vrpn_Connection *c=0)
Definition: vrpn_Xkeys.C:145
virtual void report(void)
Definition: vrpn_Dial.C:82
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
vrpn_Connection * d_connection
Connection that this object talks to.
This structure is what is passed to a vrpn_Connection message callback.
vrpn_Xkeys(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c=0, bool toggle_light=true)
Definition: vrpn_Xkeys.C:20
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Definition: vrpn_Xkeys.C:481
void report(void)
Definition: vrpn_Xkeys.C:592
void report_changes(void)
Definition: vrpn_Xkeys.C:476
vrpn_HidAcceptor * _filter
Definition: vrpn_Xkeys.h:52
const char * vrpn_got_connection
vrpn_Xkeys_Joystick(const char *name, vrpn_Connection *c=0)
Definition: vrpn_Xkeys.C:311
struct timeval timestamp
Definition: vrpn_Button.h:48
struct timeval _timestamp
Definition: vrpn_Xkeys.h:51
#define vrpn_gettimeofday
Definition: vrpn_Shared.h:89
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
void send_data(size_t bytes, const vrpn_uint8 *buffer)
Call this to send data to the device.
All button servers should derive from this class, which provides the ability to turn any of the butto...
Definition: vrpn_Button.h:65
void report(void)
Definition: vrpn_Xkeys.C:471
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Definition: vrpn_Xkeys.C:326
unsigned char lastbuttons[vrpn_BUTTON_MAX_BUTTONS]
Definition: vrpn_Button.h:45
void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
Definition: vrpn_Xkeys.C:337
unsigned char buttons[vrpn_BUTTON_MAX_BUTTONS]
Definition: vrpn_Button.h:44
virtual vrpn_int32 register_message_type(const char *name)
struct timeval timestamp
Definition: vrpn_Analog.h:41
vrpn_float64 last[vrpn_CHANNEL_MAX]
Definition: vrpn_Analog.h:39
vrpn_float64 dials[vrpn_DIAL_MAX]
Definition: vrpn_Dial.h:26