-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvrpn_DreamCheeky.h
70 lines (53 loc) · 2.01 KB
/
vrpn_DreamCheeky.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
#ifndef VRPN_DREAMCHEEKY_H
#define VRPN_DREAMCHEEKY_H
#include "vrpn_HumanInterface.h"
#include "vrpn_Button.h"
// Device drivers for the Dream Cheeky USB Roll-Up Drum Kit; done in such a
// way that any other USB devices from this vendow should be easy to add.
// Based on the X-Keys driver.
//
// For the X-Keys Joystick Pro:
// Button 0 is the upper-left triangle
// Button 1 is hte upper-right triangle
// Button 2 is the upper center round pad
// Button 3 is the lower-right round pad
// Button 4 is the lower-center round pad
// Button 5 is the lower-left round pad
#if defined(VRPN_USE_HID)
class vrpn_DreamCheeky: public vrpn_BaseClass, protected vrpn_HidInterface {
public:
vrpn_DreamCheeky(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c = 0);
virtual ~vrpn_DreamCheeky();
virtual void mainloop() = 0;
virtual void reconnect();
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) = 0;
struct timeval _timestamp;
vrpn_HidAcceptor *_filter;
// No actual types to register, derived classes will be buttons, analogs, and/or dials
int register_types(void) { return 0; }
};
class vrpn_DreamCheeky_Drum_Kit: protected vrpn_DreamCheeky, public vrpn_Button {
public:
// The sensors "bounce" a lot when the buttons are pressed and released,
// causing spurious readings of press/release. Debouncing looks at ensembles
// of events to make sure that the buttons have settled before reporting
// events.
vrpn_DreamCheeky_Drum_Kit(const char *name, vrpn_Connection *c = 0, bool debounce = true);
virtual ~vrpn_DreamCheeky_Drum_Kit() {};
virtual void mainloop();
protected:
// Do we try to debounce the buttons?
bool d_debounce;
// Send report iff changed
void report_changes (void);
// Send report whether or not changed
void report (void);
void decodePacket(size_t bytes, vrpn_uint8 *buffer);
};
// End of Windows/Cygwin/Apple
#endif
// end of VRPN_DREAMCHEEKY_H
#endif