you'll want one of these to get at source devices (gamepad::SourceDevice) and create gamepad objects (gamepad::Gamepad). More...
#include <manager.h>
Public Types | |
enum | eResult { eResult_Success = 0, eResult_SourceInUse = 1, eResult_BadSource = 2, eResult_BadMap = 3, eResult_Invalid = -1 } |
Public Member Functions | |
virtual | ~Manager (void) throw () |
virtual nstream::Folder * | getDataDirectory (void)=0 |
retrieve the data directory used by this gamepad::Manager | |
virtual bool | rediscover (void)=0 |
this can be an expensive call! This will re-poll all devices as needed. | |
virtual int | getSourceDeviceCount (void)=0 |
the number of currently discovered source devices | |
virtual smart_ptr< SourceDevice > | getSourceDevice (IN int index)=0 |
given an index (0 <= index < SourceDeviceCount), returns the specified source device. | |
virtual smart_ptr< SourceDevice > | getSourceDeviceById (IN const char *id)=0 |
returns source device with the specified unique ID. | |
virtual int | getTypeCount (void)=0 |
get the count of known gamepade types. | |
virtual smart_ptr< Type > | getType (IN int index)=0 |
get the specified type. Returns NULL if the input index is invalid. | |
virtual smart_ptr< Type > | getType (IN const char *id)=0 |
get the specified type (specified by its unique ID) | |
virtual void | addType (IN smart_ptr< Type > &type)=0 |
add a type to the set of known gamepad types. | |
virtual int | getMappingCount (void)=0 |
get the count of known mappings. | |
virtual smart_ptr< Map > | getMapping (IN int index)=0 |
get the specified mapping. | |
virtual smart_ptr< Map > | getMapping (IN const char *id)=0 |
get the specified mapping (specified by its unique ID) | |
virtual void | addMapping (IN smart_ptr< Map > &map)=0 |
add a mapping to the set of known mappings | |
virtual eResult | createGamepad (IN smart_ptr< SourceDevice > &device, IN smart_ptr< Map > &map, OUT smart_ptr< Gamepad > &gamepad)=0 |
once you have a source device and a mapping, you can create a logical gamepad object. | |
virtual int | getGamepadCount (void)=0 |
get the count of known good gamepad devices | |
virtual smart_ptr< Gamepad > | getGamepad (IN int index)=0 |
get the specified gamepad device | |
virtual smart_ptr< Gamepad > | getGamepad (IN const char *id)=0 |
get the specified gamepad by its ID | |
virtual bool | deleteGamepad (IN const char *gamepadId)=0 |
delete (un-configure) the specified gamepad. | |
virtual void | update (void)=0 |
this refreshes all state for devices. | |
Static Public Member Functions | |
static smart_ptr< Manager > | create (IN smart_ptr< nstream::Folder > &dataDirectory) |
this is the static method used to create gamepad::Manager objects. |
you'll want one of these to get at source devices (gamepad::SourceDevice) and create gamepad objects (gamepad::Gamepad).
Here is how you use a gamepad::Manager object:
WARNING: this class is not threadsafe. You'll need to synchronize access at a higher layer if necessary.
Definition at line 64 of file manager.h.
gamepad::Manager::~Manager | ( | void | ) | throw () [virtual] |
Definition at line 40 of file manager.cpp.
virtual nstream::Folder* gamepad::Manager::getDataDirectory | ( | void | ) | [pure virtual] |
retrieve the data directory used by this gamepad::Manager
virtual bool gamepad::Manager::rediscover | ( | void | ) | [pure virtual] |
this can be an expensive call! This will re-poll all devices as needed.
Returns true if anything changed (devices added/removed)
virtual int gamepad::Manager::getSourceDeviceCount | ( | void | ) | [pure virtual] |
the number of currently discovered source devices
virtual smart_ptr<SourceDevice> gamepad::Manager::getSourceDevice | ( | IN int | index | ) | [pure virtual] |
given an index (0 <= index < SourceDeviceCount), returns the specified source device.
Will return NULL on bad index, or if a source device no longer exists.
virtual smart_ptr<SourceDevice> gamepad::Manager::getSourceDeviceById | ( | IN const char * | id | ) | [pure virtual] |
returns source device with the specified unique ID.
Can return null for a variety of reasons (bad ID, source device was just unplugged, etc.)
virtual int gamepad::Manager::getTypeCount | ( | void | ) | [pure virtual] |
get the count of known gamepade types.
To start with, this consists of built-in types only, but the client can add more.
virtual smart_ptr<Type> gamepad::Manager::getType | ( | IN int | index | ) | [pure virtual] |
get the specified type. Returns NULL if the input index is invalid.
virtual smart_ptr<Type> gamepad::Manager::getType | ( | IN const char * | id | ) | [pure virtual] |
get the specified type (specified by its unique ID)
virtual void gamepad::Manager::addType | ( | IN smart_ptr< Type > & | type | ) | [pure virtual] |
add a type to the set of known gamepad types.
virtual int gamepad::Manager::getMappingCount | ( | void | ) | [pure virtual] |
get the count of known mappings.
To start with, this consists of built-in mappings only, but the client can add more.
virtual smart_ptr<Map> gamepad::Manager::getMapping | ( | IN int | index | ) | [pure virtual] |
get the specified mapping.
Returns NULL if the input index is invalid.
virtual smart_ptr<Map> gamepad::Manager::getMapping | ( | IN const char * | id | ) | [pure virtual] |
get the specified mapping (specified by its unique ID)
virtual void gamepad::Manager::addMapping | ( | IN smart_ptr< Map > & | map | ) | [pure virtual] |
add a mapping to the set of known mappings
virtual eResult gamepad::Manager::createGamepad | ( | IN smart_ptr< SourceDevice > & | device, | |
IN smart_ptr< Map > & | map, | |||
OUT smart_ptr< Gamepad > & | gamepad | |||
) | [pure virtual] |
once you have a source device and a mapping, you can create a logical gamepad object.
virtual int gamepad::Manager::getGamepadCount | ( | void | ) | [pure virtual] |
get the count of known good gamepad devices
virtual smart_ptr<Gamepad> gamepad::Manager::getGamepad | ( | IN int | index | ) | [pure virtual] |
get the specified gamepad device
virtual smart_ptr<Gamepad> gamepad::Manager::getGamepad | ( | IN const char * | id | ) | [pure virtual] |
get the specified gamepad by its ID
virtual bool gamepad::Manager::deleteGamepad | ( | IN const char * | gamepadId | ) | [pure virtual] |
delete (un-configure) the specified gamepad.
Returns false if the gamepad is not recognized.
virtual void gamepad::Manager::update | ( | void | ) | [pure virtual] |
this refreshes all state for devices.
You can call this once on the manager, and then all gamepad objects are automatically updated for you. This routine just iterates through all known source devices and calls poll() on them. If you need more control over updates, you can avoid calling this and call poll() on individual source devices as needed.
smart_ptr< Manager > gamepad::Manager::create | ( | IN smart_ptr< nstream::Folder > & | dataDirectory | ) | [static] |
this is the static method used to create gamepad::Manager objects.
The data directory should contain all gamepad type files, as well as localized text files. See the data directory in this svn repository for an example (and reference sample). For now only a single data directory per Manager is supported.
Definition at line 1122 of file manager.cpp.