Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::Input::Controller Class Reference

This class represents a controller input device, such as a gamepad or joystick. More...

#include <controller.h>

+ Inheritance diagram for Mezzanine::Input::Controller:
+ Collaboration diagram for Mezzanine::Input::Controller:

Public Member Functions

 Controller (void *InternalControl, int Count)
 Class constructor. More...
 
virtual ~Controller ()
 Class destructor.
 
Int16 GetAxis (const UInt16 Axis) const
 This Gets the value of the given joystick axis. More...
 
Int16 GetAxis (const Input::InputCode &Axis) const
 This Gets the value of the given joystick axis. More...
 
virtual const Input::ButtonStateGetButtonState (const UInt16 Button) const
 Gets the state of the requested button. More...
 
virtual const Input::ButtonStateGetButtonState (const Input::InputCode &Button) const
 Gets the state of the requested button. More...
 
UInt16 GetDeviceIndex () const
 Gets the device index of this controller. More...
 
const StringGetDeviceName () const
 Gets the name of this device. More...
 
const Input::HatStateGetHatState (const UInt16 Hat) const
 Gets the current state of the requested hat. More...
 
const Input::HatStateGetHatState (const Input::InputCode &Hat) const
 Gets the current state of the requested hat. More...
 
UInt16 GetNumAxes () const
 Gets the number of Axes on this device. More...
 
UInt16 GetNumHats () const
 Gets the number of Hats on this device. More...
 
UInt16 GetNumTrackballs () const
 Gets the number of Trackballs on this device. More...
 
Vector2 GetTrackballDelta (const UInt16 Trackball) const
 Gets the delta movement on the requested trackball. More...
 
Real GetTrackballDelta (const Input::InputCode &Trackball) const
 Gets the delta movement on the requested trackball. More...
 
Real GetTrackballDeltaX (const UInt16 Trackball) const
 Gets the delta movement on the X axis on the requested trackball. More...
 
Real GetTrackballDeltaY (const UInt16 Trackball) const
 Gets the delta movement on the Y axis on the requested trackball. More...
 
Boole IsHatPushedInDirection (const UInt16 Hat, const Input::HatState &WhichWay) const
 Gets whether a specific hat is pressed in a specific direction. More...
 
- Public Member Functions inherited from Mezzanine::Input::ButtonDevice
 ButtonDevice ()
 Class constructor.
 
virtual ~ButtonDevice ()
 Class destructor.
 
void _Update (const MetaCodeContainer &DeltaCodes, MetaCodeContainer &GeneratedCodes)
 Updates this device with the newest data. More...
 
Boole CheckButtonState (const UInt16 Button, const Input::ButtonState &State) const
 Checks to see if a button on this device is a specific state. More...
 
Boole CheckButtonState (const Input::InputCode &Button, const Input::ButtonState &State) const
 Checks to see if a button on this device is a specific state. More...
 
UInt16 GetNumButtons () const
 Gets the number of buttons on this device. More...
 
Boole IsButtonLifting (const UInt16 Button) const
 Gets whether or not a device button was lifted this frame. More...
 
Boole IsButtonLifting (const Input::InputCode &Button) const
 Gets whether or not a device button was lifted this frame. More...
 
Boole IsButtonPressed (const UInt16 Button) const
 Gets whether or not a device button is pressed down. More...
 
Boole IsButtonPressed (const Input::InputCode &Button) const
 Gets whether or not a device button is pressed down. More...
 
Boole IsButtonPressing (const UInt16 Button) const
 Gets whether or not a device button was pressed this frame. More...
 
Boole IsButtonPressing (const Input::InputCode &Button) const
 Gets whether or not a device button was pressed this frame. More...
 
Boole IsButtonTransitioning (const UInt16 Button) const
 Gets whether or not a device button was lifted or pressed this frame. More...
 
Boole IsButtonTransitioning (const Input::ButtonState &Button) const
 Gets whether or not a device button was lifted or pressed this frame. More...
 
- Public Member Functions inherited from Mezzanine::Input::Device
 Device ()
 Class constructor.
 
virtual ~Device ()
 Class destructor.
 
void AddInputSequence (const MetaCodeContainer &Codes, const Int32 &SequenceID)
 Adds a custom sequence of inputs that this system will look for and generate MetaCode's for when they occur.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown. An exception can also be thrown if the ID provided is the max value of an Int32.
More...
 
Int32 GetIDofInputSequence (const MetaCodeContainer &Codes)
 Gets the ID of the provided sequence of MetaCode's.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.
More...
 
Boole InputSequenceExists (const MetaCodeContainer &Codes)
 Checks to see if the provided sequence of MetaCode's is already being checked for.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.
More...
 
void RemoveAllInputSequences ()
 Removes all stored input sequences. More...
 
void RemoveInputSequence (const MetaCodeContainer &Codes)
 Removes the specified custom sequence of MetaCode's.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.
More...
 

Protected Member Functions

virtual void AddPressedButtons (MetaCodeContainer &GeneratedCodes) const
 
void UpdateImpl (const MetaCodeContainer &DeltaCodes, MetaCodeContainer &GeneratedCodes)
 Internal implementation of the device update. More...
 
virtual void VerifySequenceImpl (const MetaCodeContainer &Sequence) const
 
- Protected Member Functions inherited from Mezzanine::Input::ButtonDevice
void UpdateButtonTransitions ()
 Updates transitioning buttons. More...
 

Protected Attributes

std::vector< Int16Axes
 Container storing the states for each axis on the controller. More...
 
String DeviceName
 The name of the controller device. More...
 
std::vector< Input::HatStateHats
 Container storing the states for each hat on the controller. More...
 
UInt16 Index
 The index of the controller device. More...
 
std::vector< Vector2Trackballs
 Container storing the states for each trackball on the controller. More...
 
- Protected Attributes inherited from Mezzanine::Input::ButtonDevice
std::vector< Input::ButtonStateButtons
 A container of states for each button on the input device. More...
 
std::vector< WholeTransitioningIndexes
 A container of indexes being tracked due to state transitions. More...
 
- Protected Attributes inherited from Mezzanine::Input::Device
SequenceContainer Sequences
 A container for storing and detecting input sequences for an input device. More...
 

Detailed Description

This class represents a controller input device, such as a gamepad or joystick.

Definition at line 54 of file controller.h.

Constructor & Destructor Documentation

Mezzanine::Input::Controller::Controller ( void *  InternalControl,
int  Count 
)

Class constructor.

Parameters
InternalControlA pointer to the internal struct of this controller.
Remarks
A void pointer is necessary because SDL forward declares it's own struct already and this won't compile with two forward declares.

Definition at line 53 of file controller.cpp.

Member Function Documentation

void Mezzanine::Input::Controller::AddPressedButtons ( MetaCodeContainer GeneratedCodes) const
protectedvirtual

Implements Mezzanine::Input::ButtonDevice.

Definition at line 112 of file controller.cpp.

Int16 Mezzanine::Input::Controller::GetAxis ( const UInt16  Axis) const

This Gets the value of the given joystick axis.

Parameters
AxisThe axis that you want. This value is expected to be 1-20.
Returns
An integer with the Value of the joystick axis.

Definition at line 142 of file controller.cpp.

Int16 Mezzanine::Input::Controller::GetAxis ( const Input::InputCode Axis) const

This Gets the value of the given joystick axis.

Parameters
AxisAn InputCode representing the axis that you want.
Returns
An integer with the Value of the joystick axis.

Definition at line 157 of file controller.cpp.

const Input::ButtonState & Mezzanine::Input::Controller::GetButtonState ( const UInt16  Button) const
virtual

Gets the state of the requested button.

Remarks
This function accepts a button number, and as such expects a number from 1 to 20.
Returns
Returns the actual state of the requested button.

Implements Mezzanine::Input::ButtonDevice.

Definition at line 175 of file controller.cpp.

const Input::ButtonState & Mezzanine::Input::Controller::GetButtonState ( const Input::InputCode Button) const
virtual

Gets the state of the requested button.

Returns
Returns the actual state of the requested button.

Implements Mezzanine::Input::ButtonDevice.

Definition at line 178 of file controller.cpp.

UInt16 Mezzanine::Input::Controller::GetDeviceIndex ( ) const
virtual

Gets the device index of this controller.

Returns
Returns a UInt16 representing the device index for this controller.

Implements Mezzanine::Input::Device.

Definition at line 124 of file controller.cpp.

const String & Mezzanine::Input::Controller::GetDeviceName ( ) const

Gets the name of this device.

Returns
Returns a const string reference containing the name of this device.

Definition at line 127 of file controller.cpp.

const Input::HatState & Mezzanine::Input::Controller::GetHatState ( const UInt16  Hat) const

Gets the current state of the requested hat.

Parameters
HatThe hat to query. This value is expected to be 1-6.
Returns
Returns a HatState representing the current state of the specified hat.

Definition at line 154 of file controller.cpp.

const Input::HatState & Mezzanine::Input::Controller::GetHatState ( const Input::InputCode Hat) const

Gets the current state of the requested hat.

Parameters
HatAn InputCode representing the hat to query.
Returns
Returns a HatState representing the current state of the specified hat.

Definition at line 181 of file controller.cpp.

UInt16 Mezzanine::Input::Controller::GetNumAxes ( ) const

Gets the number of Axes on this device.

Returns
Returns a UInt16 representing the number of Axes present on this controller.

Definition at line 130 of file controller.cpp.

UInt16 Mezzanine::Input::Controller::GetNumHats ( ) const

Gets the number of Hats on this device.

Returns
Returns a UInt16 representing the number of Hats present on this controller.

Definition at line 136 of file controller.cpp.

UInt16 Mezzanine::Input::Controller::GetNumTrackballs ( ) const

Gets the number of Trackballs on this device.

Returns
Returns a UInt16 representing the number of Trackballs present on this controller.

Definition at line 133 of file controller.cpp.

Vector2 Mezzanine::Input::Controller::GetTrackballDelta ( const UInt16  Trackball) const

Gets the delta movement on the requested trackball.

Parameters
TrackballThe trackball to query. This value is expected to be at least 1.
Returns
Returns a vector2 representing the delta movement for the specified trackball.

Definition at line 145 of file controller.cpp.

Real Mezzanine::Input::Controller::GetTrackballDelta ( const Input::InputCode Trackball) const

Gets the delta movement on the requested trackball.

Parameters
TrackballAn InputCode representing the trackball to query.
Returns
Returns a vector2 representing the delta movement for the specified trackball.
Exceptions
AInvalidParametersException is thrown if anything other than a controllerball value from the Input enum is passed.

Definition at line 160 of file controller.cpp.

Real Mezzanine::Input::Controller::GetTrackballDeltaX ( const UInt16  Trackball) const

Gets the delta movement on the X axis on the requested trackball.

Parameters
TrackballThe trackball to query. This value is expected to be at least 1.
Returns
Returns a Real representing the delta movement on the X axis for the specified trackball.

Definition at line 148 of file controller.cpp.

Real Mezzanine::Input::Controller::GetTrackballDeltaY ( const UInt16  Trackball) const

Gets the delta movement on the Y axis on the requested trackball.

Parameters
TrackballThe trackball to query. This value is expected to be at least 1.
Returns
Returns a Real representing the delta movement on the Y axis for the specified trackball.

Definition at line 151 of file controller.cpp.

Boole Mezzanine::Input::Controller::IsHatPushedInDirection ( const UInt16  Hat,
const Input::HatState WhichWay 
) const

Gets whether a specific hat is pressed in a specific direction.

Parameters
WhichWayThe hat direction to check for. This value is expected to be 1-6.
Returns
Returns true if the specified hat is pressed in the requested direction.

Definition at line 139 of file controller.cpp.

void Mezzanine::Input::Controller::UpdateImpl ( const MetaCodeContainer DeltaCodes,
MetaCodeContainer GeneratedCodes 
)
protectedvirtual

Internal implementation of the device update.

Implements Mezzanine::Input::ButtonDevice.

Definition at line 69 of file controller.cpp.

void Mezzanine::Input::Controller::VerifySequenceImpl ( const MetaCodeContainer Sequence) const
protectedvirtual

Implements Mezzanine::Input::ButtonDevice.

Definition at line 103 of file controller.cpp.

Member Data Documentation

std::vector<Int16> Mezzanine::Input::Controller::Axes
protected

Container storing the states for each axis on the controller.

Definition at line 59 of file controller.h.

String Mezzanine::Input::Controller::DeviceName
protected

The name of the controller device.

Definition at line 68 of file controller.h.

std::vector<Input::HatState> Mezzanine::Input::Controller::Hats
protected

Container storing the states for each hat on the controller.

Definition at line 65 of file controller.h.

UInt16 Mezzanine::Input::Controller::Index
protected

The index of the controller device.

Definition at line 71 of file controller.h.

std::vector<Vector2> Mezzanine::Input::Controller::Trackballs
protected

Container storing the states for each trackball on the controller.

Definition at line 62 of file controller.h.


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