Nebula
Loading...
Searching...
No Matches
Base::GamePadBase Class Reference

#include <gamepadbase.h>

Detailed Description

An input handler which represents one of at most 4 game pads.

Inherits Input::InputHandler.

Classes

struct  ButtonState
 

Public Types

enum  Button {
  DPadUpButton = 0 , DPadDownButton , DPadLeftButton , DPadRightButton ,
  StartButton , BackButton , LeftThumbButton , RightThumbButton ,
  LeftShoulderButton , RightShoulderButton , AButton , BButton ,
  XButton , YButton , HomeButton , PlusButton ,
  MinusButton , OneButton , TwoButton , ZButton ,
  CButton , SelectButton , NumButtons , InvalidButton ,
  CrossButton = AButton , CircleButton = BButton , SquareButton = XButton , TriangleButton = YButton ,
  L1Button = LeftShoulderButton , R1Button = RightShoulderButton , L3Button = LeftThumbButton , R3Button = RightThumbButton
}
 gamepad buttons More...
 
enum  Axis {
  LeftTriggerAxis = 0 , RightTriggerAxis , LeftThumbXAxis , LeftThumbYAxis ,
  RightThumbXAxis , RightThumbYAxis , NumAxes , InvalidAxis
}
 gamepad axis More...
 

Public Member Functions

 GamePadBase ()
 constructor
 
virtual ~GamePadBase ()
 destructor
 
bool IsConnected () const
 return true if this game pad is currently connected
 
void SetIndex (IndexT i)
 set index -> TODO make threadsafe
 
IndexT GetIndex () const
 get the index of this game pad
 
bool ButtonPressed (Button btn) const
 return true if a button is currently pressed
 
bool ButtonDown (Button btn) const
 return true if button was down at least once in current frame
 
bool ButtonUp (Button btn) const
 return true if button was up at least once in current frame
 
float GetAxisValue (Axis axis) const
 get current axis value
 
bool HasTransform () const
 check if device has 3d location sensor
 
const Math::mat4GetTransform () const
 get current position (if supported by device, identity otherwise)
 
void SetLowFrequencyVibrator (float f)
 set low-frequency vibration effect (0.0f .. 1.0f)
 
float GetLowFrequencyVibrator () const
 get low-frequency vibration
 
void SetHighFrequencyVibrator (float f)
 set high-frequency vibration effect (0.0f .. 1.0f)
 
float GetHighFrequencyVibrator () const
 get high-frequency vibration
 
Util::Array< Input::InputEventGetStateAsInputEvents () const
 get current state as an array of input events (override in subclass!)
 
- Public Member Functions inherited from Input::InputHandler
 InputHandler ()
 constructor
 
virtual ~InputHandler ()
 destructor
 
bool IsAttached () const
 return true if the input handler is currently attached
 
virtual void BeginCapture ()
 capture input to this event handler
 
virtual void EndCapture ()
 end input capturing to this event handler
 
bool IsCapturing () const
 return true if this input handler captures input
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Static Public Member Functions

static Util::String ButtonAsString (Button btn)
 convert button code to string
 
static Util::String AxisAsString (Axis a)
 convert axis to string
 
static SizeT GetMaxNumControllers ()
 get maximum number of controllers
 
- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 

Protected Member Functions

virtual void OnAttach ()
 called when the handler is attached to the input server
 
virtual void OnReset ()
 reset the input handler
 
- Protected Member Functions inherited from Input::InputHandler
virtual void OnRemove ()
 called when the handler is removed from the input server
 
virtual void OnBeginFrame ()
 called on InputServer::BeginFrame()
 
virtual void OnEndFrame ()
 called on InputServer::EndFrame();
 
virtual void OnObtainCapture ()
 called when input handler obtains capture
 
virtual void OnReleaseCapture ()
 called when input handler looses capture
 
virtual bool OnEvent (const InputEvent &inputEvent)
 called when an input event should be processed
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Protected Attributes

IndexT index
 
bool isConnected
 
Util::FixedArray< ButtonStatebuttonStates
 
Util::FixedArray< float > axisValues
 
bool vibratorsDirty
 
bool hasTransform
 
float lowFreqVibrator
 
float highFreqVibrator
 
Threading::CriticalSection critSect
 
Threading::ThreadId creatorThreadId
 
Math::mat4 transform
 
- Protected Attributes inherited from Input::InputHandler
bool isAttached
 
bool isCapturing
 

Private Member Functions

 __DeclareClass (GamePadBase)
 

Member Enumeration Documentation

◆ Axis

gamepad axis

Enumerator
LeftTriggerAxis 
RightTriggerAxis 
LeftThumbXAxis 
LeftThumbYAxis 
RightThumbXAxis 
RightThumbYAxis 
NumAxes 
InvalidAxis 

◆ Button

gamepad buttons

Enumerator
DPadUpButton 
DPadDownButton 
DPadLeftButton 
DPadRightButton 
StartButton 
BackButton 
LeftThumbButton 
RightThumbButton 
LeftShoulderButton 
RightShoulderButton 
AButton 
BButton 
XButton 
YButton 
HomeButton 
PlusButton 
MinusButton 
OneButton 
TwoButton 
ZButton 
CButton 
SelectButton 
NumButtons 
InvalidButton 
CrossButton 
CircleButton 
SquareButton 
TriangleButton 
L1Button 
R1Button 
L3Button 
R3Button 

Constructor & Destructor Documentation

◆ GamePadBase()

Base::GamePadBase::GamePadBase ( )

constructor

◆ ~GamePadBase()

Base::GamePadBase::~GamePadBase ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Base::GamePadBase::__DeclareClass ( GamePadBase )
private

◆ AxisAsString()

String Base::GamePadBase::AxisAsString ( Axis a)
static

convert axis to string

◆ ButtonAsString()

String Base::GamePadBase::ButtonAsString ( Button btn)
static

convert button code to string

◆ ButtonDown()

bool Base::GamePadBase::ButtonDown ( Button btn) const
inline

return true if button was down at least once in current frame

◆ ButtonPressed()

bool Base::GamePadBase::ButtonPressed ( Button btn) const
inline

return true if a button is currently pressed

◆ ButtonUp()

bool Base::GamePadBase::ButtonUp ( Button btn) const
inline

return true if button was up at least once in current frame

◆ GetAxisValue()

float Base::GamePadBase::GetAxisValue ( Axis axis) const
inline

get current axis value

◆ GetHighFrequencyVibrator()

float Base::GamePadBase::GetHighFrequencyVibrator ( ) const
inline

get high-frequency vibration

◆ GetIndex()

IndexT Base::GamePadBase::GetIndex ( ) const
inline

get the index of this game pad

◆ GetLowFrequencyVibrator()

float Base::GamePadBase::GetLowFrequencyVibrator ( ) const
inline

get low-frequency vibration

◆ GetMaxNumControllers()

SizeT Base::GamePadBase::GetMaxNumControllers ( )
inlinestatic

get maximum number of controllers

◆ GetStateAsInputEvents()

Array< InputEvent > Base::GamePadBase::GetStateAsInputEvents ( ) const

get current state as an array of input events (override in subclass!)

This method should return the current state of the game pad as input events.

It is up to a specific subclass to implement this method.

◆ GetTransform()

const Math::mat4 & Base::GamePadBase::GetTransform ( ) const
inline

get current position (if supported by device, identity otherwise)

◆ HasTransform()

bool Base::GamePadBase::HasTransform ( ) const
inline

check if device has 3d location sensor

◆ IsConnected()

bool Base::GamePadBase::IsConnected ( ) const
inline

return true if this game pad is currently connected

◆ OnAttach()

void Base::GamePadBase::OnAttach ( )
protectedvirtual

called when the handler is attached to the input server

Reimplemented from Input::InputHandler.

◆ OnReset()

void Base::GamePadBase::OnReset ( )
protectedvirtual

reset the input handler

Reimplemented from Input::InputHandler.

◆ SetHighFrequencyVibrator()

void Base::GamePadBase::SetHighFrequencyVibrator ( float f)
inline

set high-frequency vibration effect (0.0f .. 1.0f)

◆ SetIndex()

void Base::GamePadBase::SetIndex ( IndexT i)
inline

set index -> TODO make threadsafe

◆ SetLowFrequencyVibrator()

void Base::GamePadBase::SetLowFrequencyVibrator ( float f)
inline

set low-frequency vibration effect (0.0f .. 1.0f)

Member Data Documentation

◆ axisValues

Util::FixedArray<float> Base::GamePadBase::axisValues
protected

◆ buttonStates

Util::FixedArray<ButtonState> Base::GamePadBase::buttonStates
protected

◆ creatorThreadId

Threading::ThreadId Base::GamePadBase::creatorThreadId
protected

◆ critSect

Threading::CriticalSection Base::GamePadBase::critSect
protected

◆ hasTransform

bool Base::GamePadBase::hasTransform
protected

◆ highFreqVibrator

float Base::GamePadBase::highFreqVibrator
protected

◆ index

IndexT Base::GamePadBase::index
protected

◆ isConnected

bool Base::GamePadBase::isConnected
protected

◆ lowFreqVibrator

float Base::GamePadBase::lowFreqVibrator
protected

◆ transform

Math::mat4 Base::GamePadBase::transform
protected

◆ vibratorsDirty

bool Base::GamePadBase::vibratorsDirty
protected

The documentation for this class was generated from the following files: