Nebula
Loading...
Searching...
No Matches
GLFW::GLFWGamePad Class Reference

#include <glfwgamepad.h>

Detailed Description

One game pad, read through GLFW.

Inherits Base::GamePadBase.

Public Member Functions

 GLFWGamePad ()
 constructor
virtual ~GLFWGamePad ()
 destructor
virtual void Poll ()
 read the pad and put this frame's state on it
virtual Util::Array< Input::InputEvent > GetStateAsInputEvents () const
 the button edges the last poll produced
Public Member Functions inherited from Base::GamePadBase
 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::mat4 & GetTransform () 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::InputEvent > GetStateAsInputEvents () 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::String & GetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Private Member Functions

 __DeclareClass (GLFWGamePad)

Private Attributes

Util::Array< Input::InputEvent > frameEvents
 the edges recorded by the poll, kept so the events can be handed to the handler chain
Util::String warnedGuid
 the joystick this handler has already reported as unmapped, so the same one is not printed every frame

Additional Inherited Members

Public Types inherited from Base::GamePadBase
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...
Static Public Member Functions inherited from Base::GamePadBase
static Util::String ButtonAsString (Button btn)
 convert button code to string
static Util::String AxisAsString (Axis a)
 convert axis to string
static Button ButtonFromString (const Util::String &str)
 convert string to button code. InvalidButton when the string is not one of the buttons
static Axis AxisFromString (const Util::String &str)
 convert string to axis code. InvalidAxis when the string is not one of the axes
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 inherited from Base::GamePadBase
virtual void OnAttach ()
 called when the handler is attached to the input server
virtual void OnBeginFrame ()
 called on InputServer::BeginFrame()
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 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 inherited from Base::GamePadBase
IndexT index
bool isConnected
Util::FixedArray< ButtonState > buttonStates
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

Constructor & Destructor Documentation

◆ GLFWGamePad()

GLFW::GLFWGamePad::GLFWGamePad ( )

constructor

◆ ~GLFWGamePad()

GLFW::GLFWGamePad::~GLFWGamePad ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

GLFW::GLFWGamePad::__DeclareClass ( GLFWGamePad )
private

◆ GetStateAsInputEvents()

Util::Array< Input::InputEvent > GLFW::GLFWGamePad::GetStateAsInputEvents ( ) const
virtual

the button edges the last poll produced

The edges this frame's poll produced.

The input server puts these into the handler chain, so a game pad button is visible to a handler that works on events rather than on a polled state.

◆ Poll()

void GLFW::GLFWGamePad::Poll ( )
virtual

read the pad and put this frame's state on it

Read the pad as it stands after the event pump.

GLFW only updates its joystick state during the pump, so a poll before it gives the frame that was read last time.

An axis keeps the value GLFW reports, with its Y positive when the thumb points down. That is not a game convention. The scale on a binding is what turns it into one. A trigger is the one axis that is not kept as GLFW reports it, because it reports -1 at rest and 1 fully pressed, and Base::GamePadBase documents a trigger as 0 to 1.

Reimplemented from Input::InputHandler.

Member Data Documentation

◆ frameEvents

Util::Array<Input::InputEvent> GLFW::GLFWGamePad::frameEvents
private

the edges recorded by the poll, kept so the events can be handed to the handler chain

◆ warnedGuid

Util::String GLFW::GLFWGamePad::warnedGuid
private

the joystick this handler has already reported as unmapped, so the same one is not printed every frame


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