-
Notifications
You must be signed in to change notification settings - Fork 0
/
vrpn_3DConnexion.h
173 lines (138 loc) · 5.23 KB
/
vrpn_3DConnexion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#ifndef VRPN_3DCONNEXION_H
#define VRPN_3DCONNEXION_H
#include <stddef.h> // for size_t
#include "vrpn_Analog.h" // for vrpn_Analog
#include "vrpn_Button.h" // for vrpn_Button_Filter
#include "vrpn_Configure.h" // for VRPN_API, VRPN_USE_HID
#include "vrpn_Connection.h" // for vrpn_Connection (ptr only), etc
#include "vrpn_HumanInterface.h" // for vrpn_HidAcceptor (ptr only), etc
#include "vrpn_Shared.h" // for timeval
#include "vrpn_Types.h" // for vrpn_uint32, vrpn_uint8
// Device drivers for the 3DConnexion SpaceNavigator and SpaceTraveler
// SpaceExplorer, SpaceMouse, SpaceMousePro, Spaceball5000, SpacePilot
// devices, connecting to them as HID devices (USB).
// Exposes two VRPN device classes: Button and Analog.
// Analogs are mapped to the six channels, each in the range (-1..1).
// This is the base driver for the devices. The Navigator has
// only two buttons and has product ID 50726, the traveler has 8
// buttons and ID 50723. The derived classes just construct with
// the appropriate number of buttons and an acceptor for the proper
// product ID; the baseclass does all the work.
#if defined(VRPN_USE_HID)
class VRPN_API vrpn_3DConnexion: public vrpn_Button_Filter, public vrpn_Analog, protected vrpn_HidInterface {
public:
vrpn_3DConnexion(vrpn_HidAcceptor *filter, unsigned num_buttons,
const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion();
virtual void mainloop();
protected:
// Set up message handlers, etc.
void on_data_received(size_t bytes, vrpn_uint8 *buffer);
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer);
struct timeval _timestamp;
vrpn_HidAcceptor *_filter;
// Send report iff changed
void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
// Send report whether or not changed
void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
// NOTE: class_of_service is only applied to vrpn_Analog
// values, not vrpn_Button or vrpn_Dial
};
#else // not VRPN_USE_HID
class VRPN_API vrpn_3DConnexion: public vrpn_Button_Filter, public vrpn_Analog {
public:
vrpn_3DConnexion(vrpn_HidAcceptor *filter, unsigned num_buttons,
const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion();
virtual void mainloop();
protected:
struct timeval _timestamp;
vrpn_HidAcceptor *_filter;
int fd;
// Send report iff changed
void report_changes(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
// Send report whether or not changed
void report(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
// NOTE: class_of_service is only applied to vrpn_Analog
// values, not vrpn_Button or vrpn_Dial
// There is a non-HID Linux-based driver for this device that has a capability
// not implemented in the HID interface.
#if defined(linux) && !defined(VRPN_USE_HID)
int set_led(int led_state);
#endif
};
#endif // not VRPN_USE_HID
class VRPN_API vrpn_3DConnexion_Navigator: public vrpn_3DConnexion {
public:
vrpn_3DConnexion_Navigator(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_Navigator() {};
protected:
};
class VRPN_API vrpn_3DConnexion_Navigator_for_Notebooks: public vrpn_3DConnexion {
public:
vrpn_3DConnexion_Navigator_for_Notebooks(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_Navigator_for_Notebooks() {};
protected:
};
class VRPN_API vrpn_3DConnexion_Traveler: public vrpn_3DConnexion {
public:
vrpn_3DConnexion_Traveler(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_Traveler() {};
protected:
};
class VRPN_API vrpn_3DConnexion_SpaceMouse: public vrpn_3DConnexion {
public:
vrpn_3DConnexion_SpaceMouse(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_SpaceMouse() {};
protected:
};
/*
The button numbers are labeled as follows (the ones similar to <x> have a graphic on the button and are referred to the text enclosed text in the help):
0=Menu
1=Fit
2=<T>
4=<R>
5=<F>
8=<Roll+>
12=1
13=2
14=3
15=4
22=Esc
23=Alt
24=Shift
25=Ctrl
26=<Rot>
*/
class VRPN_API vrpn_3DConnexion_SpaceMousePro: public vrpn_3DConnexion {
public:
vrpn_3DConnexion_SpaceMousePro(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_SpaceMousePro() {};
protected:
};
class VRPN_API vrpn_3DConnexion_SpaceMouseWireless : public vrpn_3DConnexion {
public:
vrpn_3DConnexion_SpaceMouseWireless(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_SpaceMouseWireless() {};
protected:
};
class VRPN_API vrpn_3DConnexion_SpaceExplorer : public vrpn_3DConnexion {
public:
vrpn_3DConnexion_SpaceExplorer(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_SpaceExplorer() {};
protected:
};
class VRPN_API vrpn_3DConnexion_SpaceBall5000: public vrpn_3DConnexion {
public:
vrpn_3DConnexion_SpaceBall5000(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_SpaceBall5000() {};
protected:
};
class VRPN_API vrpn_3DConnexion_SpacePilot: public vrpn_3DConnexion {
public:
vrpn_3DConnexion_SpacePilot(const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_3DConnexion_SpacePilot() {};
protected:
};
// end of VRPN_3DCONNEXION_H
#endif