10 #if defined(VRPN_USE_HID) 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;
24 , _toggle_light(toggle_light)
34 vrpn_uint8 outputs[9] = {0};
49 vrpn_uint8 outputs[9] = {0};
65 vrpn_uint8 outputs[9] = {0};
78 vrpn_uint8 outputs[9] = {0};
121 for (
size_t i = 0; i < bytes / 11; i++) {
122 vrpn_uint8 *
report = buffer + (i * 11);
124 if (!(
report[10] & 0x08)) {
126 fprintf(stderr,
"vrpn_Xkeys_Desktop: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
134 for (
int btn = 0; btn < 20; btn++) {
135 vrpn_uint8 *offset, mask;
137 offset =
report + btn / 5;
138 mask =
static_cast<vrpn_uint8
>(1 << (btn % 5));
140 buttons[btn + 1] = (*offset & mask) != 0;
211 channel[0] =
static_cast<float>(
static_cast<signed char>(buffer[0])) / 7.0;
212 channel[1] =
static_cast<float>(buffer[1]);
227 for (
int btn = 0; btn < 35; btn++) {
228 vrpn_uint8 *offset, mask;
230 offset = buffer + btn / 7 + 3;
231 mask =
static_cast<vrpn_uint8
>(1 << (btn % 7));
233 buttons[btn + 1] = (*offset & mask) != 0;
236 }
else if (bytes == 6) {
238 if (!(buffer[5] & 0x08)) {
240 fprintf(stderr,
"vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
245 buttons[0] = (buffer[5] & 0x10) != 0;
251 for (
int btn = 35; btn < 58; btn++) {
252 vrpn_uint8 *offset, mask;
253 int local_btn = btn - 35;
255 offset = buffer + local_btn / 7;
256 mask =
static_cast<vrpn_uint8
>(1 << (local_btn % 7));
258 buttons[btn + 1] = (*offset & mask) != 0;
261 }
else if (bytes == 14) {
266 for (i = 0; i < bytes / 14; i++) {
267 vrpn_uint8 *
report = buffer + (i * 14);
269 if (!(
report[13] & 0x08)) {
271 fprintf(stderr,
"vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
281 for (
int btn = 0; btn < 58; btn++) {
282 vrpn_uint8 *offset, mask;
284 offset =
report + btn / 7 + 3;
285 mask =
static_cast<vrpn_uint8
>(1 << (btn % 7));
287 buttons[btn + 1] = (*offset & mask) != 0;
294 channel[0] =
static_cast<float>(
static_cast<signed char>(
report[0])) / 7.0;
306 fprintf(stderr,
"vrpn_Xkeys_Jog_And_Shuttle::decodePacket(): Unrecognized packet length (%u)\n", static_cast<unsigned>(bytes));
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;
376 for (
int btn = 0; btn < 35; btn++) {
377 vrpn_uint8 *offset, mask;
379 offset = buffer + btn / 7 + 3;
380 mask =
static_cast<vrpn_uint8
>(1 << (btn % 7));
382 buttons[btn + 1] = (*offset & mask) != 0;
385 }
else if (bytes == 6) {
387 if (!(buffer[5] & 0x08)) {
389 fprintf(stderr,
"vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
394 buttons[0] = (buffer[5] & 0x10) != 0;
400 for (
int btn = 35; btn < 58; btn++) {
401 vrpn_uint8 *offset, mask;
402 int local_btn = btn - 35;
404 offset = buffer + local_btn / 7;
405 mask =
static_cast<vrpn_uint8
>(1 << (local_btn % 7));
407 buttons[btn + 1] = (*offset & mask) != 0;
410 }
else if (bytes == 14) {
415 for (i = 0; i < bytes / 14; i++) {
416 vrpn_uint8 *
report = buffer + (i * 14);
418 if (!(
report[13] & 0x08)) {
420 fprintf(stderr,
"vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
430 for (
int btn = 0; btn < 58; btn++) {
431 vrpn_uint8 *offset, mask;
433 offset =
report + btn / 7 + 3;
434 mask =
static_cast<vrpn_uint8
>(1 << (btn % 7));
436 buttons[btn + 1] = (*offset & mask) != 0;
445 fprintf(stderr,
"vrpn_Xkeys_Joystick::decodePacket(): Unrecognized packet length (%u)\n", static_cast<unsigned>(bytes));
499 for (
int btn = 0; btn < 35; btn++) {
500 vrpn_uint8 *offset, mask;
502 offset = buffer + btn / 7 + 3;
503 mask =
static_cast<vrpn_uint8
>(1 << (btn % 7));
505 buttons[btn + 1] = (*offset & mask) != 0;
508 }
else if (bytes == 6) {
510 if (!(buffer[5] & 0x08)) {
512 fprintf(stderr,
"vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
517 buttons[0] = (buffer[5] & 0x10) != 0;
523 for (
int btn = 35; btn < 58; btn++) {
524 vrpn_uint8 *offset, mask;
525 int local_btn = btn - 35;
527 offset = buffer + local_btn / 7;
528 mask =
static_cast<vrpn_uint8
>(1 << (local_btn % 7));
530 buttons[btn + 1] = (*offset & mask) != 0;
533 }
else if (bytes == 14) {
540 for (i = 0; i < bytes / 14; i++) {
541 vrpn_uint8 *
report = buffer + (i * 14);
543 if (!(
report[13] & 0x08)) {
545 fprintf(stderr,
"vrpn_Xkeys: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
555 for (
int btn = 0; btn < 58; btn++) {
556 vrpn_uint8 *offset, mask;
558 offset = buffer + btn / 7 + 3;
559 mask =
static_cast<vrpn_uint8
>(1 << (btn % 7));
561 buttons[btn + 1] = (*offset & mask) != 0;
565 fprintf(stderr,
"vrpn_Xkeys_Pro::decodePacket(): Unrecognized packet length (%u)\n", static_cast<unsigned>(bytes));
606 for (
size_t i = 0; i < bytes / 32; i++) {
607 vrpn_uint8 *
report = buffer + (i * 32);
613 fprintf(stderr,
"vrpn_Xkeys_XK3: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p)
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...
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 ...
void report_changes(void)
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p)
void report_changes(void)
vrpn_Xkeys_XK3(const char *name, vrpn_Connection *c=0)
vrpn_Xkeys_Pro(const char *name, vrpn_Connection *c=0)
virtual void report_changes(void)
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
vrpn_float64 channel[vrpn_CHANNEL_MAX]
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Accepts any device with the given vendor and product IDs.
Generic connection class not specific to the transport mechanism.
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 mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Xkeys_Desktop(const char *name, vrpn_Connection *c=0)
const char * vrpn_dropped_last_connection
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
vrpn_Xkeys_Jog_And_Shuttle(const char *name, vrpn_Connection *c=0)
virtual void report(void)
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)
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
void report_changes(void)
vrpn_HidAcceptor * _filter
const char * vrpn_got_connection
vrpn_Xkeys_Joystick(const char *name, vrpn_Connection *c=0)
struct timeval _timestamp
#define vrpn_gettimeofday
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.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
virtual vrpn_int32 register_message_type(const char *name)
vrpn_float64 last[vrpn_CHANNEL_MAX]
vrpn_float64 dials[vrpn_DIAL_MAX]