~hitmuri/vjpirate/trunk

« back to all changes in this revision

Viewing changes to os/win/include/vrpn_XInputGamepad.h

  • Committer: Florent Berthaut
  • Date: 2014-07-26 18:53:16 UTC
  • mfrom: (5.1.12 mac)
  • Revision ID: flo@localhost.localdomain-20140726185316-c2ucnwmgm5kij4e2
Merged mac branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef VRPN_XINPUTGAMEPAD_H
 
2
#define VRPN_XINPUTGAMEPAD_H
 
3
 
 
4
#include "vrpn_Configure.h"
 
5
 
 
6
#if defined(_WIN32) && defined(VRPN_USE_DIRECTINPUT) && defined(VRPN_USE_WINDOWS_XINPUT)
 
7
 
 
8
#include "vrpn_Connection.h"
 
9
#include "vrpn_Analog.h"
 
10
#include "vrpn_Button.h"
 
11
#include "vrpn_Analog_Output.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
 
 
18
class VRPN_API vrpn_XInputGamepad: public vrpn_Analog, public vrpn_Button, public vrpn_Analog_Output {
 
19
public:
 
20
        vrpn_XInputGamepad(const char *name, vrpn_Connection *c = NULL, unsigned int controllerIndex = 0);
 
21
        ~vrpn_XInputGamepad();
 
22
 
 
23
        virtual void mainloop();
 
24
 
 
25
protected:
 
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
 
 
45
private:
 
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