RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Microsoft_Controller_Raw.h
1#pragma once
2
3#include <stddef.h> // for size_t
4
5#include "vrpn_Analog.h" // for vrpn_Analog
6#include "vrpn_BaseClass.h" // for vrpn_BaseClass
7#include "vrpn_Button.h" // for vrpn_Button_Filter
8#include "vrpn_Configure.h" // for VRPN_CALLBACK, VRPN_USE_HID
9#include "vrpn_Connection.h" // for vrpn_CONNECTION_LOW_LATENCY, etc
10#include "vrpn_Dial.h" // for vrpn_Dial
11#include "vrpn_HumanInterface.h" // for vrpn_HidAcceptor (ptr only), etc
12#include "vrpn_Shared.h" // for timeval
13#include "vrpn_Types.h" // for vrpn_uint8, vrpn_uint32
14
15#if defined(VRPN_USE_HID)
16
17// Device drivers for the Microsoft Controller Raw USB line of products
18// Currently supported: Xbox Controller S, Xbox 360 Controller
19//
20// Exposes three major VRPN device classes: Button, Analog, Dial (as appropriate).
21// All models expose Buttons for the keys on the device.
22// Button 0 is the programming switch; it is set if the switch is in the "red" position.
23//
24
26{
27public:
28 vrpn_Microsoft_Controller_Raw(vrpn_HidAcceptor *filter, const char *name,
29 vrpn_Connection *c = 0, vrpn_uint16 vendor = 0, vrpn_uint16 product = 0);
31
32 virtual void mainloop(void) = 0;
33protected:
34 // Set up message handlers, etc.
35 void init_hid(void);
36 void on_data_received(size_t bytes, vrpn_uint8 *buffer);
37
38 static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p);
39 static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p);
40
41 virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer) = 0;
42 struct timeval _timestamp;
43 vrpn_HidAcceptor *_filter;
44
45 // No actual types to register, derived classes will be buttons, analogs, and/or dials
46 int register_types(void) { return (0); }
47};
48
50{
51public:
54
55 virtual void mainloop(void);
56protected:
57 // Send report iff changed
58 void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
59 // Send report whether or not changed
60 void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
61
62 void decodePacket(size_t bytes, vrpn_uint8 *buffer);
63};
64
66{
67public:
68 vrpn_Microsoft_SideWinder(const char *name, vrpn_Connection *c = 0);
69 virtual ~vrpn_Microsoft_SideWinder(void) {};
70
71 virtual void mainloop(void);
72protected:
73 // Send report iff changed
74 void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
75 // Send report whether or not changed
76 void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
77
78 void decodePacket(size_t bytes, vrpn_uint8 *buffer);
79};
80
82{
83public:
86
87 virtual void mainloop(void);
88protected:
89 // Send report iff changed
90 void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
91 // Send report whether or not changed
92 void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
93
94 void decodePacket(size_t bytes, vrpn_uint8 *buffer);
95
96 // Previous dial value, used to determine delta to send when it changes.
97 vrpn_uint8 _lastDial;
98};
99
100// There are aftermarket clones of this controller that have different vendor and
101// product IDs. We make a base class that implements all of the functionality
102// (which is the same) and then declare subclasses that set the vendor and
103// product ID appropriately.
105{
106public:
108 vrpn_uint16 vendor = 0, vrpn_uint16 product = 0);
109
111
112 virtual void mainloop(void);
113
114protected:
115 // Send report iff changed
116 void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
117 // Send report whether or not changed
118 void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
119
120 void decodePacket(size_t bytes, vrpn_uint8 *buffer);
121
122 // Previous dial value, used to determine delta to send when it changes.
123 vrpn_uint8 _lastDial;
124};
125
126// Original Xbox 360
132
133// Xbox 360 wireless controller
139
140// Generic Xbox 360, same as actual Xbox 360, but other IDs
146
147// end of VRPN_USE_HID
148#else
154class VRPN_API vrpn_Microsoft_SideWinder;
155#endif
定义 vrpn_Microsoft_Controller_Raw.h:142
定义 vrpn_Analog.h:28
定义 vrpn_BaseClass.h:310
定义 vrpn_Button.h:66
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Dial.h:21
定义 vrpn_HumanInterface.h:56
定义 vrpn_HumanInterface.h:70
vrpn_uint16 product() const
vrpn_uint16 vendor() const
定义 vrpn_Microsoft_Controller_Raw.h:135
定义 vrpn_Microsoft_Controller_Raw.h:105
定义 vrpn_Microsoft_Controller_Raw.h:128
定义 vrpn_Microsoft_Controller_Raw.h:82
定义 vrpn_Microsoft_Controller_Raw.h:26
virtual void mainloop(void)=0
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback. It is called whenever a read returns some data.
int register_types(void)
定义 vrpn_Microsoft_Controller_Raw.h:46
定义 vrpn_Microsoft_Controller_Raw.h:50
定义 vrpn_Microsoft_Controller_Raw.h:66
virtual void mainloop(void)
This structure is what is passed to a vrpn_Connection message callback.
定义 vrpn_Connection.h:41