PixelLightAPI  .
Public Member Functions | Protected Member Functions | Protected Attributes
PLInput::Controller Class Reference

Input controller. More...

#include <Controller.h>

Inheritance diagram for PLInput::Controller:
Inheritance graph
[legend]

List of all members.

Public Member Functions

PLINPUT_API Controller (EControllerType nType, const PLCore::String &sName, const PLCore::String &sDescription)
 Constructor.
virtual PLINPUT_API ~Controller ()
 Destructor.
PLINPUT_API EControllerType GetType () const
 Get controller type.
PLINPUT_API PLCore::String GetName () const
 Get controller name.
PLINPUT_API PLCore::String GetDescription () const
 Get controller description.
PLINPUT_API bool GetActive () const
 Check if controller is active.
PLINPUT_API void SetActive (bool bActive)
 Activate or deactivate controller.
PLINPUT_API bool HasChanged () const
 Check if the controller's state has changed (for polling)
PLINPUT_API const PLCore::List
< Control * > & 
GetControls () const
 Get all controls of the controller.
PLINPUT_API const PLCore::List
< Button * > & 
GetButtons () const
 Get all buttons.
PLINPUT_API const PLCore::List
< Axis * > & 
GetAxes () const
 Get all axes.
PLINPUT_API ControlGetControl (const PLCore::String &sName) const
 Get control with a specific name.
PLINPUT_API char GetChar ()
 Get character of last button that was hit.
PLINPUT_API const PLCore::List
< Connection * > & 
GetConnections ()
 Get connections.
PLINPUT_API void Connect (const PLCore::String &sControl, Control *pControl, float fScale=1.0f)
 Connect to another controller.
PLINPUT_API void ConnectAll (Controller *pController, const PLCore::String &sPrefixOut, const PLCore::String &sPrefixIn)
 Connect to another controller.
PLINPUT_API void Disconnect (Connection *pConnection)
 Disconnect connection.
virtual PLINPUT_API void Update ()
 Update device once per frame.
virtual PLINPUT_API void UpdateOutputControl (Control *pControl)
 Update output controls (LEDs, effects etc.)

Protected Member Functions

PLINPUT_API void AddControl (Control *pControl)
 Add control.
PLINPUT_API void InformControl (Control *pControl)
 Inform controller that a control has changed it's state.
PLINPUT_API void InitControlList (EControlType nType) const
 Init control list.
PLINPUT_API void AddConnection (Connection *pConnection)
 Add connection.
PLINPUT_API void RemoveConnection (Connection *pConnection)
 Remove connection.

Protected Attributes

EControllerType m_nType
PLCore::String m_sName
PLCore::String m_sDescription
bool m_bConfirmed
bool m_bActive
bool m_bChanged
PLCore::List< Control * > m_lstControls
PLCore::HashMap
< PLCore::String, Control * > 
m_mapControls
PLCore::List< Button * > m_lstButtons
PLCore::List< Axis * > m_lstAxes
char m_nChar
PLCore::List< Connection * > m_lstConnections

Detailed Description

Input controller.

Remarks:
A controller represents an input device, which can either be a real device like e.g. a mouse or joystick, or a virtual device that is used to map real input devices to virtual axes and keys. A controller consists of a list of controls, e.g. buttons or axes and provides methods to obtain the status.

Constructor & Destructor Documentation

PLINPUT_API PLInput::Controller::Controller ( EControllerType  nType,
const PLCore::String sName,
const PLCore::String sDescription 
)

Constructor.

Parameters:
[in]nTypeController type
[in]sNameController name
[in]sDescriptionController description
virtual PLINPUT_API PLInput::Controller::~Controller ( ) [virtual]

Destructor.


Member Function Documentation

Get controller type.

Returns:
Controller type

Get controller name.

Returns:
Name

Get controller description.

Returns:
Description
PLINPUT_API bool PLInput::Controller::GetActive ( ) const

Check if controller is active.

Returns:
'true' if controller is active, else 'false'
Remarks:
If a controller is active, it sends out signals when the state of it's controls has changed. If a controller is not active, no state changes will occur and all input events from connected devices will be discarded.
PLINPUT_API void PLInput::Controller::SetActive ( bool  bActive)

Activate or deactivate controller.

Parameters:
[in]bActive'true' if controller is active, else 'false'
Remarks:
Virtual controllers can be activated or deactivated, real input devices are always active and can not be deactivated.
PLINPUT_API bool PLInput::Controller::HasChanged ( ) const

Check if the controller's state has changed (for polling)

Returns:
'true', if the state has changed, else 'false'
PLINPUT_API const PLCore::List<Control*>& PLInput::Controller::GetControls ( ) const

Get all controls of the controller.

Returns:
List of controls
PLINPUT_API const PLCore::List<Button*>& PLInput::Controller::GetButtons ( ) const

Get all buttons.

Returns:
List of buttons
PLINPUT_API const PLCore::List<Axis*>& PLInput::Controller::GetAxes ( ) const

Get all axes.

Returns:
List of axes
PLINPUT_API Control* PLInput::Controller::GetControl ( const PLCore::String sName) const

Get control with a specific name.

Parameters:
[in]sNameName of control
Returns:
Control, or a null pointer if no control with that name could be found
PLINPUT_API char PLInput::Controller::GetChar ( )

Get character of last button that was hit.

Returns:
Button character (ASCII), can be '\0'
Remarks:
This function returns the character code of the last button that was hit (not pressed!). The character will then be reset to '\0', so the next call will return '\0', until a new button is first pressed and then released.

Get connections.

Returns:
List of connections (both incoming and outgoing), do not destroy the returned connection instances!
Remarks:
To determine whether a connection is incoming or outgoing, you can check e.g. GetOutputControl()->GetController() == this or something similar.
PLINPUT_API void PLInput::Controller::Connect ( const PLCore::String sControl,
Control pControl,
float  fScale = 1.0f 
)

Connect to another controller.

Parameters:
[in]sControlName of control of this controller (output control)
[in]pControlPointer to control (input control), shouldn't be a null pointer (but a null pointer is caught internally)
[in]fScaleScale factor
PLINPUT_API void PLInput::Controller::ConnectAll ( Controller pController,
const PLCore::String sPrefixOut,
const PLCore::String sPrefixIn 
)

Connect to another controller.

Parameters:
[in]pControllerPointer to controller containing the input controls, shouldn't be a null pointer (but a null pointer is caught internally)
[in]sPrefixOutPrefix for controls of this controller
[in]sPrefixInPrefix for controls of the other controller
Remarks:
This connects all controls of the input controller (pController) to the controls of the output controller (this), if their names are equal, e.g. pController->"Left" will be connected to this->"Left". You can also provide a prefix for either or both sides, e.g.: ConnectAll(pOtherController, "", "Camera") will connect pController->"CameraLeft" to this->"Left".
PLINPUT_API void PLInput::Controller::Disconnect ( Connection pConnection)

Disconnect connection.

Parameters:
[in]pConnectionConnection (must be valid!), on successful disconnect, the given "pConnection" instance becomes invalid
virtual PLINPUT_API void PLInput::Controller::Update ( ) [virtual]

Update device once per frame.

Remarks:
This function can be used e.g. to reset any data of a device once per frame. Usually this is not needed, but some devices (e.g. RawInput mice etc.) need to reset their data once per frame.
Note:
  • The default implementation is empty

Reimplemented in PLInput::Keyboard, PLInput::Joystick, PLInput::SensorManager, PLInput::Mouse, and PLInput::SplitTouchPad.

virtual PLINPUT_API void PLInput::Controller::UpdateOutputControl ( Control pControl) [virtual]

Update output controls (LEDs, effects etc.)

Parameters:
[in]pControlOutput control that has been changed, must be valid!
Remarks:
This function is called whenever an output control such as LED or Effect has been changed. A device should use this function to update the specific control state on the device (or update all output controls at the same time)
Note:
  • The default implementation is empty

Reimplemented in PLInput::WiiMote, and PLInput::Joystick.

PLINPUT_API void PLInput::Controller::AddControl ( Control pControl) [protected]

Add control.

Parameters:
[in]pControlPointer to control, must be valid!
PLINPUT_API void PLInput::Controller::InformControl ( Control pControl) [protected]

Inform controller that a control has changed it's state.

Parameters:
[in]pControlPointer to control, must be valid!
PLINPUT_API void PLInput::Controller::InitControlList ( EControlType  nType) const [protected]

Init control list.

Parameters:
[in]nTypeType of list that is to be filled
PLINPUT_API void PLInput::Controller::AddConnection ( Connection pConnection) [protected]

Add connection.

Parameters:
[in]pConnectionConnection (must be valid!)
PLINPUT_API void PLInput::Controller::RemoveConnection ( Connection pConnection) [protected]

Remove connection.

Parameters:
[in]pConnectionConnection (must be valid!)

Member Data Documentation

Controller type

Controller name

Controller description

Confirmation flag for DetectDevices()

Is the controller active?

bool PLInput::Controller::m_bChanged [mutable, protected]

Has the controller's state changed?

List of all controls

Hash map of name -> control

List of buttons (filled on use)

List of absolute axes (filled on use)

char PLInput::Controller::m_nChar [protected]

Last hit key character

List of connections


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:34
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported