179 n_assert2(
creatorThreadId == Threading::Thread::GetMyThreadId(),
"IsConnected can't be called from any thread but the creator thread!");
236 n_assert2(
creatorThreadId == Threading::Thread::GetMyThreadId(),
"ButtonPressed can't be called from any thread but the creator thread!");
246 n_assert2(
creatorThreadId == Threading::Thread::GetMyThreadId(),
"ButtonDown can't be called from any thread but the creator thread!");
256 n_assert2(
creatorThreadId == Threading::Thread::GetMyThreadId(),
"ButtonUp can't be called from any thread but the creator thread!");
266 n_assert2(
creatorThreadId == Threading::Thread::GetMyThreadId(),
"GetAxisValue can't be called from any thread but the creator thread!");
An input handler which represents one of at most 4 game pads.
Definition gamepadbase.h:24
bool ButtonDown(Button btn) const
return true if button was down at least once in current frame
Definition gamepadbase.h:244
bool HasTransform() const
check if device has 3d location sensor
Definition gamepadbase.h:187
Util::FixedArray< float > axisValues
Definition gamepadbase.h:158
static void SetupDicts()
Definition gamepadbase.cc:191
static Util::Dictionary< Util::String, Button > buttonDict
Definition gamepadbase.h:168
__DeclareClass(GamePadBase)
static Axis AxisFromString(const Util::String &str)
convert string to axis code. InvalidAxis when the string is not one of the axes
Definition gamepadbase.cc:176
Button
gamepad buttons
Definition gamepadbase.h:29
@ HomeButton
Definition gamepadbase.h:47
@ L3Button
Definition gamepadbase.h:69
@ DPadUpButton
Definition gamepadbase.h:30
@ L1Button
Definition gamepadbase.h:67
@ BButton
Definition gamepadbase.h:42
@ XButton
Definition gamepadbase.h:43
@ OneButton
Definition gamepadbase.h:50
@ MinusButton
Definition gamepadbase.h:49
@ ZButton
Definition gamepadbase.h:52
@ StartButton
Definition gamepadbase.h:34
@ RightShoulderButton
Definition gamepadbase.h:39
@ InvalidButton
Definition gamepadbase.h:59
@ SquareButton
Definition gamepadbase.h:65
@ NumButtons
Definition gamepadbase.h:58
@ DPadLeftButton
Definition gamepadbase.h:32
@ CircleButton
Definition gamepadbase.h:64
@ AButton
Definition gamepadbase.h:41
@ R3Button
Definition gamepadbase.h:70
@ LeftThumbButton
Definition gamepadbase.h:36
@ CrossButton
Definition gamepadbase.h:63
@ TriangleButton
Definition gamepadbase.h:66
@ TwoButton
Definition gamepadbase.h:51
@ CButton
Definition gamepadbase.h:53
@ DPadRightButton
Definition gamepadbase.h:33
@ DPadDownButton
Definition gamepadbase.h:31
@ YButton
Definition gamepadbase.h:44
@ LeftShoulderButton
Definition gamepadbase.h:38
@ BackButton
Definition gamepadbase.h:35
@ RightThumbButton
Definition gamepadbase.h:37
@ R1Button
Definition gamepadbase.h:68
@ PlusButton
Definition gamepadbase.h:48
@ SelectButton
Definition gamepadbase.h:56
Util::Array< Input::InputEvent > GetStateAsInputEvents() const
get current state as an array of input events (override in subclass!)
Definition gamepadbase.cc:231
Math::mat4 transform
Definition gamepadbase.h:165
static Button ButtonFromString(const Util::String &str)
convert string to button code. InvalidButton when the string is not one of the buttons
Definition gamepadbase.cc:161
float highFreqVibrator
Definition gamepadbase.h:162
static Util::Dictionary< Util::String, Axis > axisDict
Definition gamepadbase.h:169
void SetHighFrequencyVibrator(float f)
set high-frequency vibration effect (0.0f .. 1.0f)
Definition gamepadbase.h:298
bool IsConnected() const
return true if this game pad is currently connected
Definition gamepadbase.h:177
bool isConnected
Definition gamepadbase.h:156
float GetAxisValue(Axis axis) const
get current axis value
Definition gamepadbase.h:264
void SetIndex(IndexT i)
set index -> TODO make threadsafe
Definition gamepadbase.h:206
const Math::mat4 & GetTransform() const
get current position (if supported by device, identity otherwise)
Definition gamepadbase.h:197
float GetLowFrequencyVibrator() const
get low-frequency vibration
Definition gamepadbase.h:286
bool ButtonUp(Button btn) const
return true if button was up at least once in current frame
Definition gamepadbase.h:254
float lowFreqVibrator
Definition gamepadbase.h:161
static SizeT GetMaxNumControllers()
get maximum number of controllers
Definition gamepadbase.h:225
Util::FixedArray< ButtonState > buttonStates
Definition gamepadbase.h:157
IndexT GetIndex() const
get the index of this game pad
Definition gamepadbase.h:216
Axis
gamepad axis
Definition gamepadbase.h:75
@ NumAxes
Definition gamepadbase.h:84
@ RightThumbYAxis
Definition gamepadbase.h:82
@ LeftTriggerAxis
Definition gamepadbase.h:77
@ LeftThumbXAxis
Definition gamepadbase.h:79
@ InvalidAxis
Definition gamepadbase.h:85
@ LeftThumbYAxis
Definition gamepadbase.h:80
@ RightThumbXAxis
Definition gamepadbase.h:81
@ RightTriggerAxis
Definition gamepadbase.h:78
Threading::ThreadId creatorThreadId
Definition gamepadbase.h:164
bool hasTransform
Definition gamepadbase.h:160
static Util::String ButtonAsString(Button btn)
convert button code to string
Definition gamepadbase.cc:105
virtual void OnAttach()
called when the handler is attached to the input server
Definition gamepadbase.cc:48
virtual void OnBeginFrame()
called on InputServer::BeginFrame()
Definition gamepadbase.cc:62
bool vibratorsDirty
Definition gamepadbase.h:159
IndexT index
Definition gamepadbase.h:155
static Util::String AxisAsString(Axis a)
convert axis to string
Definition gamepadbase.cc:141
float GetHighFrequencyVibrator() const
get high-frequency vibration
Definition gamepadbase.h:310
GamePadBase()
constructor
Definition gamepadbase.cc:22
void SetLowFrequencyVibrator(float f)
set low-frequency vibration effect (0.0f .. 1.0f)
Definition gamepadbase.h:274
virtual void OnReset()
reset the input handler
Definition gamepadbase.cc:77
bool ButtonPressed(Button btn) const
return true if a button is currently pressed
Definition gamepadbase.h:234
Threading::CriticalSection critSect
Definition gamepadbase.h:163
Nebula's dynamic array class.
Definition array.h:61
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:35
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
Nebula's universal string class.
Definition string.h:50
#define n_assert2(exp, msg)
Definition debug.h:59
#define n_assert(exp)
Definition debug.h:58
#define MAX_GAMEPADS
Definition gamepadbase.h:18
Definition gamecontentserverbase.cc:10
__forceinline float clamp(float val, float minVal, float maxVal)
Float clamping.
Definition scalar.h:506
pthread_t ThreadId
Definition linuxthreadid.h:15
A 4x4 single point precision float matrix.
Definition mat4.h:55
int SizeT
Definition types.h:50
int IndexT
Definition types.h:49