vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_XInputGamepad.h
Go to the documentation of this file.
1#ifndef VRPN_XINPUTGAMEPAD_H
2#define VRPN_XINPUTGAMEPAD_H
3
4#include "vrpn_Configure.h" // IWYU pragma: keep
5
6#if defined(_WIN32) && defined(VRPN_USE_WINDOWS_XINPUT)
7
8#include "vrpn_Analog.h"
10#include "vrpn_Button.h"
11#include "vrpn_Connection.h"
12
13// This implements an XInput gamepad (read: Xbox 360 controller), which has
14// analog outputs and button outputs but also enables the user to set a
15// rumble magnitude using an Analog_Output (channel 0 controls the left motor,
16// channel 1 controls the right motor).
17
18class VRPN_API vrpn_XInputGamepad: public vrpn_Analog, public vrpn_Button_Filter, public vrpn_Analog_Output {
19public:
20 vrpn_XInputGamepad(const char *name, vrpn_Connection *c = NULL, unsigned int controllerIndex = 0);
21 ~vrpn_XInputGamepad();
22
23 virtual void mainloop();
24
25protected:
26 // Handle requests to change rumble magnitude
27 static int VRPN_CALLBACK handle_request_message(void *selfPtr, vrpn_HANDLERPARAM data);
28 static int VRPN_CALLBACK handle_request_channels_message(void *selfPtr, vrpn_HANDLERPARAM data);
29 static int VRPN_CALLBACK handle_last_connection_dropped(void *selfPtr, vrpn_HANDLERPARAM data);
30
31 // send report iff changed
32 void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
33 // send report whether or not changed
34 void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
35 // NOTE: class_of_service is only applied to vrpn_Analog
36 // values, not vrpn_Button
37
38 void update_vibration();
39
40 // These functions may be overridden to disable the default filtering
41 virtual vrpn_float64 normalize_axis(SHORT axis, SHORT deadzone) const;
42 virtual vrpn_float64 normalize_trigger(BYTE trigger) const;
43 virtual vrpn_float64 normalize_dpad(WORD buttons) const;
44
45private:
46 unsigned int _controllerIndex;
47 timeval _timestamp;
48
49 WORD _motorSpeed[2];
50};
51
52#endif // _WIN32 && VRPN_USE_DIRECTINPUT
53#endif // VRPN_XINPUTGAMEPAD_H
54
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
Definition vrpn_Analog.C:94
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
Definition vrpn_Analog.C:71
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.
This structure is what is passed to a vrpn_Connection message callback.
#define VRPN_API
#define VRPN_CALLBACK
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY