vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_DreamCheeky.h
Go to the documentation of this file.
1#pragma once
2
3#include <stddef.h> // for size_t
4
5#include "vrpn_BaseClass.h" // for vrpn_BaseClass
6#include "vrpn_Button.h" // for vrpn_Button_Filter
7#include "vrpn_Configure.h" // for VRPN_USE_HID
8#include "vrpn_HumanInterface.h" // for vrpn_HidAcceptor (ptr only), etc
9#include "vrpn_Shared.h" // for timeval
10#include "vrpn_Types.h" // for vrpn_uint8
11
12// Device drivers for the Dream Cheeky USB Roll-Up Drum Kit; done in such a
13// way that any other USB devices from this vendow should be easy to add.
14// Based on the X-Keys driver.
15//
16// For the Dreamcheeky:
17// Button 0 is the upper-left triangle
18// Button 1 is hte upper-right triangle
19// Button 2 is the upper center round pad
20// Button 3 is the lower-right round pad
21// Button 4 is the lower-center round pad
22// Button 5 is the lower-left round pad
23
24#if defined(VRPN_USE_HID)
25
27public:
28 vrpn_DreamCheeky(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c = 0,
29 vrpn_uint16 vendor = 0, vrpn_uint16 product = 0);
30 virtual ~vrpn_DreamCheeky();
31
32 virtual void mainloop() = 0;
33
34protected:
35 // Set up message handlers, etc.
36 void on_data_received(size_t bytes, vrpn_uint8 *buffer);
37
38 virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer) = 0;
39 struct timeval _timestamp;
41
42 // No actual types to register, derived classes will be buttons, analogs, and/or dials
43 int register_types(void) { return 0; }
44};
45
47public:
48 // The sensors "bounce" a lot when the buttons are pressed and released,
49 // causing spurious readings of press/release. Debouncing looks at ensembles
50 // of events to make sure that the buttons have settled before reporting
51 // events.
52 vrpn_DreamCheeky_Drum_Kit(const char *name, vrpn_Connection *c = 0, bool debounce = true);
54
55 virtual void mainloop();
56
57protected:
58 // Do we try to debounce the buttons?
60
61 // Send report iff changed
62 void report_changes (void);
63 // Send report whether or not changed
64 void report (void);
65
66 void decodePacket(size_t bytes, vrpn_uint8 *buffer);
67};
68
69#else
71#endif
72
73
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
All button servers should derive from this class, which provides the ability to turn any of the butto...
Definition vrpn_Button.h:66
Generic connection class not specific to the transport mechanism.
int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
vrpn_HidAcceptor * _filter
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer)=0
Derived class reimplements this callback.
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
#define VRPN_API