1
#ifndef VRPN_XINPUTGAMEPAD_H
2
#define VRPN_XINPUTGAMEPAD_H
4
#include "vrpn_Configure.h"
6
#if defined(_WIN32) && defined(VRPN_USE_DIRECTINPUT) && defined(VRPN_USE_WINDOWS_XINPUT)
8
#include "vrpn_Connection.h"
9
#include "vrpn_Analog.h"
10
#include "vrpn_Button.h"
11
#include "vrpn_Analog_Output.h"
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).
18
class VRPN_API vrpn_XInputGamepad: public vrpn_Analog, public vrpn_Button, public vrpn_Analog_Output {
20
vrpn_XInputGamepad(const char *name, vrpn_Connection *c = NULL, unsigned int controllerIndex = 0);
21
~vrpn_XInputGamepad();
23
virtual void mainloop();
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);
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
38
void update_vibration();
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;
46
unsigned int _controllerIndex;
52
#endif // _WIN32 && VRPN_USE_DIRECTINPUT
53
#endif // VRPN_XINPUTGAMEPAD_H