11#if defined(VRPN_USE_HID)
16static const vrpn_uint16 GRIFFIN_VENDOR = 0x077d;
17static const vrpn_uint16 GRIFFIN_POWERMATE = 0x0410;
19static void normalize_axis(
const unsigned int value,
const short deadzone,
const vrpn_float64 scale, vrpn_float64& channel) {
20 channel = (
static_cast<float>(value) - 128.0f);
21 if (fabs(channel) < deadzone)
30 if (channel < -1.0) { channel = -1.0; }
31 if (channel > 1.0) { channel = 1.0; }
48 fprintf(stderr,
"vrpn_Griffin::~vrpn_Griffin(): delete failed\n");
96 struct timeval current_time;
174 dials[0] =
static_cast<vrpn_int8
>(buffer[1]);
177 normalize_axis(buffer[1], 5, 1.0f,
channel[0]);
184 for (
int btn = 0; btn < 1; btn++) {
185 vrpn_uint8 mask =
static_cast<vrpn_uint8
>(1 << (btn % 8));
186 buttons[btn] = ((value & mask) != 0);
189 fprintf(stderr,
"vrpn_Griffin_PowerMate: Found a corrupted report; # total bytes = %u\n",
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 ...
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.
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_float64 dials[vrpn_DIAL_MAX]
virtual void report(void)
vrpn_Dial(const char *name, vrpn_Connection *c=NULL)
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_Griffin_PowerMate(const char *name, vrpn_Connection *c=0)
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
vrpn_Griffin(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c=0, vrpn_uint16 vendor=0, vrpn_uint16 product=0)
vrpn_HidAcceptor * _filter
static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p)
static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p)
struct timeval _timestamp
virtual ~vrpn_Griffin(void)
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.
This structure is what is passed to a vrpn_Connection message callback.
const char * vrpn_dropped_last_connection
const char * vrpn_got_connection
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
#define vrpn_gettimeofday