vrpn  07.33
Virtual Reality Peripheral Network
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 
27 public:
28  vrpn_DreamCheeky(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c = 0);
29  virtual ~vrpn_DreamCheeky();
30 
31  virtual void mainloop() = 0;
32 
33 protected:
34  // Set up message handlers, etc.
35  void on_data_received(size_t bytes, vrpn_uint8 *buffer);
36 
37  virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer) = 0;
38  struct timeval _timestamp;
40 
41  // No actual types to register, derived classes will be buttons, analogs, and/or dials
42  int register_types(void) { return 0; }
43 };
44 
46 public:
47  // The sensors "bounce" a lot when the buttons are pressed and released,
48  // causing spurious readings of press/release. Debouncing looks at ensembles
49  // of events to make sure that the buttons have settled before reporting
50  // events.
51  vrpn_DreamCheeky_Drum_Kit(const char *name, vrpn_Connection *c = 0, bool debounce = true);
53 
54  virtual void mainloop();
55 
56 protected:
57  // Do we try to debounce the buttons?
58  bool d_debounce;
59 
60  // Send report iff changed
61  void report_changes (void);
62  // Send report whether or not changed
63  void report (void);
64 
65  void decodePacket(size_t bytes, vrpn_uint8 *buffer);
66 };
67 
68 #else
70 #endif
71 
72 
int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer)=0
Derived class reimplements this callback.
Generic connection class not specific to the transport mechanism.
#define VRPN_API
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
virtual void report_changes(void)
Definition: vrpn_Button.C:382
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
vrpn_HidAcceptor * _filter
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
All button servers should derive from this class, which provides the ability to turn any of the butto...
Definition: vrpn_Button.h:65