vrpn
07.35
Virtual Reality Peripheral Network
Toggle main menu visibility
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
26
class
VRPN_API
vrpn_DreamCheeky
:
public
vrpn_BaseClass
,
protected
vrpn_HidInterface
{
27
public
:
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
34
protected
:
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
;
40
vrpn_HidAcceptor
*
_filter
;
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
46
class
VRPN_API
vrpn_DreamCheeky_Drum_Kit
:
protected
vrpn_DreamCheeky
,
public
vrpn_Button_Filter
{
47
public
:
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
);
53
virtual
~vrpn_DreamCheeky_Drum_Kit
() {};
54
55
virtual
void
mainloop
();
56
57
protected
:
58
// Do we try to debounce the buttons?
59
bool
d_debounce
;
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
70
class
vrpn_DreamCheeky_Drum_Kit
;
71
#endif
72
73
vrpn_BaseClass::mainloop
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_BaseClass::vrpn_BaseClass
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
Definition
vrpn_BaseClass.C:310
vrpn_Button_Filter::vrpn_Button_Filter
vrpn_Button_Filter(const char *, vrpn_Connection *c=NULL)
Definition
vrpn_Button.C:129
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition
vrpn_Connection.h:561
vrpn_DreamCheeky_Drum_Kit
Definition
vrpn_DreamCheeky.h:46
vrpn_DreamCheeky_Drum_Kit::decodePacket
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Definition
vrpn_DreamCheeky.C:76
vrpn_DreamCheeky_Drum_Kit::d_debounce
bool d_debounce
Definition
vrpn_DreamCheeky.h:59
vrpn_DreamCheeky_Drum_Kit::report_changes
void report_changes(void)
Definition
vrpn_DreamCheeky.C:70
vrpn_DreamCheeky_Drum_Kit::~vrpn_DreamCheeky_Drum_Kit
virtual ~vrpn_DreamCheeky_Drum_Kit()
Definition
vrpn_DreamCheeky.h:53
vrpn_DreamCheeky_Drum_Kit::vrpn_DreamCheeky_Drum_Kit
vrpn_DreamCheeky_Drum_Kit(const char *name, vrpn_Connection *c=0, bool debounce=true)
Definition
vrpn_DreamCheeky.C:41
vrpn_DreamCheeky_Drum_Kit::report
void report(void)
Definition
vrpn_DreamCheeky.C:64
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:43
vrpn_DreamCheeky::_timestamp
struct timeval _timestamp
Definition
vrpn_DreamCheeky.h:39
vrpn_DreamCheeky::_filter
vrpn_HidAcceptor * _filter
Definition
vrpn_DreamCheeky.h:40
vrpn_DreamCheeky::mainloop
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_DreamCheeky::decodePacket
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
vrpn_DreamCheeky::vrpn_DreamCheeky
vrpn_DreamCheeky(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c=0, vrpn_uint16 vendor=0, vrpn_uint16 product=0)
Definition
vrpn_DreamCheeky.C:17
vrpn_HidAcceptor
Definition
vrpn_HumanInterface.h:56
vrpn_HidInterface::product
vrpn_uint16 product() const
Returns USB product ID of connected device May not contain valid if an already-open device was provid...
Definition
vrpn_HumanInterface.C:17
vrpn_HidInterface::vrpn_HidInterface
vrpn_HidInterface(vrpn_HidAcceptor *acceptor, vrpn_uint16 vendor=0, vrpn_uint16 product=0, hid_device *device=NULL)
Constructor If we already have a HID device from some other source, it can be passed and we'll take o...
Definition
vrpn_HumanInterface.C:50
vrpn_HidInterface::on_data_received
virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer)=0
Derived class reimplements this callback.
vrpn_HidInterface::vendor
vrpn_uint16 vendor() const
Returns USB vendor ID of connected device May not contain valid if an already-open device was provide...
Definition
vrpn_HumanInterface.C:14
vrpn_BaseClass.h
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
vrpn_Button.h
vrpn_Configure.h
VRPN_API
#define VRPN_API
Definition
vrpn_Configure.h:648
vrpn_HumanInterface.h
vrpn_Shared.h
vrpn_Types.h
vrpn_DreamCheeky.h
Generated by
1.17.0