VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
PlayerManager Class Reference

Manages a mapping from unique player identifiers to different controllers that connect and disconnect throughout the game. More...

Inheritance diagram for PlayerManager:
QObject ControllerManager::DeviceConnectionListener

Public Types

enum  PlayerAction { LEFT, RIGHT, HORIZONTAL, MAGNETIZE }
 Different actions or expressions of intent a player can make in the game. More...
 

Signals

void playerActivationChanged (int playerId, bool status)
 Emitted when player playerId becomes either activated (i.e. connects a controller) or deactivated (i.e. disconnects their controller). More...
 

Public Member Functions

 PlayerManager (QObject *parent=nullptr)
 Constructs a PlayerManager. More...
 
bool isPlayerAvailable (int player) const
 Returns whether or not player is available (i.e. currently connected with a controller). More...
 
QList< int > getAvailablePlayers () const
 Returns the list of currently available players (i.e. players currently connected with a controller). More...
 
void reset ()
 Resets all the player <-> controller mappings. More...
 
VirtualControllergetPlayerController (int player) const
 Returns the VirtualController for player. More...
 
float getHorizontal (int player) const
 Returns the horizontal movement value [-1.0f, 1.0f] for player. More...
 
bool isMagnetized (int player) const
 Returns whether or not the the player has magnetism activated. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 

Static Public Member Functions

static PlayerManagergetInstance ()
 Returns the global singleton instance of the PlayerManager, creating it if necessary. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Additional Inherited Members

- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Manages a mapping from unique player identifiers to different controllers that connect and disconnect throughout the game.

Additionally, this class abstracts the different controller capabilities away from the game, instead defining and allowing the querying of different player action values.

Note
PlayerManager currently supports the following controller "types": gamepads, touch navigation devices, and keyboards.

Member Enumeration Documentation

Different actions or expressions of intent a player can make in the game.

Note
PlayerActions are not necessarily distinctive amongst themselves, but rather represent the full set of actions a player can express using different types of controllers supported by PlayerManager.
Enumerator
LEFT 

Unidirectional action for movement to the left.

RIGHT 

Unidirectional action for movement to the right.

HORIZONTAL 

Bidirectional action for movement left or right (i.e. horizontal).

MAGNETIZE 

Action for magnetizing.

Constructor & Destructor Documentation

PlayerManager::PlayerManager ( QObject parent = nullptr)
explicit

Constructs a PlayerManager.

Parameters
parentParent object

Member Function Documentation

QList<int> PlayerManager::getAvailablePlayers ( ) const
inline

Returns the list of currently available players (i.e. players currently connected with a controller).

float PlayerManager::getHorizontal ( int  player) const

Returns the horizontal movement value [-1.0f, 1.0f] for player.

static PlayerManager* PlayerManager::getInstance ( )
static

Returns the global singleton instance of the PlayerManager, creating it if necessary.

VirtualController* PlayerManager::getPlayerController ( int  player) const

Returns the VirtualController for player.

bool PlayerManager::isMagnetized ( int  player) const

Returns whether or not the the player has magnetism activated.

bool PlayerManager::isPlayerAvailable ( int  player) const
inline

Returns whether or not player is available (i.e. currently connected with a controller).

void PlayerManager::playerActivationChanged ( int  playerId,
bool  status 
)
signal

Emitted when player playerId becomes either activated (i.e. connects a controller) or deactivated (i.e. disconnects their controller).

Parameters
playerIdId of player who has become activated
statustrue if playerId has connected
void PlayerManager::reset ( )

Resets all the player <-> controller mappings.

Note
This method will also reset all the associated VirtualController states as well.