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 
vrpn_BaseClass.h
vrpn_Button_Filter::report_changes
virtual void report_changes(void)
Definition: vrpn_Button.C:382
vrpn_Types.h
vrpn_HidInterface
Definition: vrpn_HumanInterface.h:68
vrpn_HidAcceptor
Definition: vrpn_HumanInterface.h:54
vrpn_DreamCheeky_Drum_Kit
Definition: vrpn_DreamCheeky.h:45
vrpn_DreamCheeky_Drum_Kit::d_debounce
bool d_debounce
Definition: vrpn_DreamCheeky.h:58
vrpn_DreamCheeky::decodePacket
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
vrpn_DreamCheeky
Definition: vrpn_DreamCheeky.h:26
vrpn_Shared.h
vrpn_Button.h
vrpn_HumanInterface.h
vrpn_DreamCheeky::mainloop
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_BaseClass::mainloop
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_DreamCheeky_Drum_Kit::~vrpn_DreamCheeky_Drum_Kit
virtual ~vrpn_DreamCheeky_Drum_Kit()
Definition: vrpn_DreamCheeky.h:52
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition: vrpn_Connection.h:510
vrpn_HidInterface::on_data_received
virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer)=0
Derived class reimplements this callback.
vrpn_DreamCheeky::_filter
vrpn_HidAcceptor * _filter
Definition: vrpn_DreamCheeky.h:39
vrpn_DreamCheeky::register_types
int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
Definition: vrpn_DreamCheeky.h:42
vrpn_Configure.h
VRPN_API
#define VRPN_API
Definition: vrpn_Configure.h:646
vrpn_BaseClass
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
Definition: vrpn_BaseClass.h:313
vrpn_Button_Filter
All button servers should derive from this class, which provides the ability to turn any of the butto...
Definition: vrpn_Button.h:65