Gainput  v1.0.0
GainputInputDevicePad.h
1 
2 #ifndef GAINPUTINPUTDEVICEPAD_H_
3 #define GAINPUTINPUTDEVICEPAD_H_
4 
5 namespace gainput
6 {
7 
9 enum { MaxPadCount = 10 };
10 
13 {
14  PadButtonLeftStickX,
15  PadButtonLeftStickY,
16  PadButtonRightStickX,
17  PadButtonRightStickY,
18  PadButtonAxis4, // L2/Left trigger
19  PadButtonAxis5, // R2/Right trigger
20  PadButtonAxis6,
21  PadButtonAxis7,
22  PadButtonAxis8,
23  PadButtonAxis9,
24  PadButtonAxis10,
25  PadButtonAxis11,
26  PadButtonAxis12,
27  PadButtonAxis13,
28  PadButtonAxis14,
29  PadButtonAxis15,
30  PadButtonAxis16,
31  PadButtonAxis17,
32  PadButtonAxis18,
33  PadButtonAxis19,
34  PadButtonAxis20,
35  PadButtonAxis21,
36  PadButtonAxis22,
37  PadButtonAxis23,
38  PadButtonAxis24,
39  PadButtonAxis25,
40  PadButtonAxis26,
41  PadButtonAxis27,
42  PadButtonAxis28,
43  PadButtonAxis29,
44  PadButtonAxis30,
45  PadButtonAxis31,
46  PadButtonAccelerationX,
47  PadButtonAccelerationY,
48  PadButtonAccelerationZ,
49  PadButtonGravityX,
50  PadButtonGravityY,
51  PadButtonGravityZ,
52  PadButtonGyroscopeX,
53  PadButtonGyroscopeY,
54  PadButtonGyroscopeZ,
55  PadButtonMagneticFieldX,
56  PadButtonMagneticFieldY,
57  PadButtonMagneticFieldZ,
58  PadButtonStart,
59  PadButtonAxisCount_ = PadButtonStart,
60  PadButtonSelect,
61  PadButtonLeft,
62  PadButtonRight,
63  PadButtonUp,
64  PadButtonDown,
65  PadButtonA, // Cross
66  PadButtonB, // Circle
67  PadButtonX, // Square
68  PadButtonY, // Triangle
69  PadButtonL1,
70  PadButtonR1,
71  PadButtonL2,
72  PadButtonR2,
73  PadButtonL3, // Left thumb
74  PadButtonR3, // Right thumb
75  PadButtonHome, // PS button
76  PadButton17,
77  PadButton18,
78  PadButton19,
79  PadButton20,
80  PadButton21,
81  PadButton22,
82  PadButton23,
83  PadButton24,
84  PadButton25,
85  PadButton26,
86  PadButton27,
87  PadButton28,
88  PadButton29,
89  PadButton30,
90  PadButton31,
91  PadButtonMax_,
92  PadButtonCount_ = PadButtonMax_ - PadButtonAxisCount_
93 };
94 
95 class InputDevicePadImpl;
96 
98 
107 class GAINPUT_LIBEXPORT InputDevicePad : public InputDevice
108 {
109 public:
111  static const char* PadDeviceIds[MaxPadCount];
112  // TODO SetPadDeviceId(padIndex, const char* id);
113 
115 
121  InputDevicePad(InputManager& manager, DeviceId device, unsigned index, DeviceVariant variant);
123  ~InputDevicePad();
124 
126  DeviceType GetType() const { return DT_PAD; }
127  DeviceVariant GetVariant() const;
128  const char* GetTypeName() const { return "pad"; }
129  bool IsValidButtonId(DeviceButtonId deviceButton) const;
130 
131  size_t GetAnyButtonDown(DeviceButtonSpec* outButtons, size_t maxButtonCount) const;
132 
133  size_t GetButtonName(DeviceButtonId deviceButton, char* buffer, size_t bufferLength) const;
134  ButtonType GetButtonType(DeviceButtonId deviceButton) const;
135  DeviceButtonId GetButtonByName(const char* name) const;
136 
137  InputState* GetNextInputState();
138 
140 
145  bool Vibrate(float leftMotor, float rightMotor);
146 
148  InputDevicePadImpl* GetPimpl() { return impl_; }
149 
150 protected:
151  void InternalUpdate(InputDeltaState* delta);
152 
153  DeviceState InternalGetState() const;
154 
155 private:
156  InputDevicePadImpl* impl_;
157 
158 };
159 
160 }
161 
162 #endif
163 
const char * GetTypeName() const
Returns the device type's name.
Definition: GainputInputDevicePad.h:128
Manages all input devices and some other helpful stuff.
Definition: GainputInputManager.h:24
ButtonType
Type of an input device button.
Definition: GainputInputDevice.h:10
PadButton
All valid device buttons for InputDevicePad.
Definition: GainputInputDevicePad.h:12
Stores a list of input state changes.
Definition: GainputInputDeltaState.h:9
Describes a device button on a specific device.
Definition: gainput.h:112
unsigned int DeviceId
ID of an input device.
Definition: gainput.h:107
DeviceState
State of an input device.
Definition: GainputInputDevice.h:59
DeviceVariant
Variant of an input device type.
Definition: GainputInputDevice.h:51
A pad input device.
Definition: GainputInputDevicePad.h:107
DeviceType
Type of an input device.
Definition: GainputInputDevice.h:37
Interface for anything that provides device inputs.
Definition: GainputInputDevice.h:33
InputDevicePadImpl * GetPimpl()
Returns the platform-specific implementation of this device.
Definition: GainputInputDevicePad.h:148
unsigned int DeviceButtonId
ID of a specific button unique to an input device.
Definition: gainput.h:109
State of an input device.
Definition: GainputInputState.h:9
DeviceType GetType() const
Returns DT_PAD.
Definition: GainputInputDevicePad.h:126
Contains all Gainput related classes, types, and functions.
Definition: gainput.h:103