vrpn 07.35
Virtual Reality Peripheral Network
 
Loading...
Searching...
No Matches
vrpn_Griffin.h
Go to the documentation of this file.
1#pragma once
2
3#include <stddef.h> // for size_t
4
5#include "vrpn_Analog.h" // for vrpn_Analog
6#include "vrpn_BaseClass.h" // for vrpn_BaseClass
7#include "vrpn_Button.h" // for vrpn_Button_Filter
8#include "vrpn_Configure.h" // for VRPN_CALLBACK, VRPN_USE_HID
9#include "vrpn_Connection.h" // for vrpn_CONNECTION_LOW_LATENCY, etc
10#include "vrpn_Dial.h" // for vrpn_Dial
11#include "vrpn_HumanInterface.h" // for vrpn_HidAcceptor (ptr only), etc
12#include "vrpn_Shared.h" // for timeval
13#include "vrpn_Types.h" // for vrpn_uint8, vrpn_uint32
14
15#if defined(VRPN_USE_HID)
16
17// Device drivers for the Griffin Technology USB line of products
18// Currently supported: PowerMate Controller
19//
20// Exposes three major VRPN device classes: Button, Analog, Dial (as appropriate).
21// All models expose Buttons for the keys on the device.
22// Button 0 is the programming switch; it is set if the switch is in the "red" position.
23//
24
26public:
27 vrpn_Griffin(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c = 0,
28 vrpn_uint16 vendor = 0, vrpn_uint16 product = 0);
29 virtual ~vrpn_Griffin(void);
30
31 virtual void mainloop(void) = 0;
32
33protected:
34 // Set up message handlers, etc.
35 void init_hid(void);
36 void on_data_received(size_t bytes, vrpn_uint8 *buffer);
37
38 static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p);
39 static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p);
40
41 virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer) = 0;
42 struct timeval _timestamp;
44
45 // No actual types to register, derived classes will be buttons, analogs, and/or dials
46 int register_types(void) { return 0; }
47};
48
50public:
51 vrpn_Griffin_PowerMate(const char *name, vrpn_Connection *c = 0);
52 virtual ~vrpn_Griffin_PowerMate(void) {};
53
54 virtual void mainloop(void);
55
56protected:
57 // Send report iff changed
58 void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
59 // Send report whether or not changed
60 void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
61
62 void decodePacket(size_t bytes, vrpn_uint8 *buffer);
63
64 // Previous dial value, used to determine delta to send when it changes.
65 vrpn_uint8 _lastDial;
66};
67
68// end of VRPN_USE_HID
69#else
72#endif
vrpn_Analog(const char *name, vrpn_Connection *c=NULL)
Definition vrpn_Analog.C:14
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
virtual void report_changes(void)
vrpn_Button_Filter(const char *, vrpn_Connection *c=NULL)
Generic connection class not specific to the transport mechanism.
virtual void report(void)
Definition vrpn_Dial.C:82
vrpn_Dial(const char *name, vrpn_Connection *c=NULL)
Definition vrpn_Dial.C:8
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)
virtual ~vrpn_Griffin_PowerMate(void)
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
virtual void mainloop(void)=0
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)
static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p)
struct timeval _timestamp
int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
virtual ~vrpn_Griffin(void)
void init_hid(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...
vrpn_uint16 vendor() const
Returns USB vendor ID of connected device May not contain valid if an already-open device was provide...
This structure is what is passed to a vrpn_Connection message callback.
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
#define VRPN_API
#define VRPN_CALLBACK
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY