Classes | Functions

Gamepad Library
[Gamepad Library APIs]

Collaboration diagram for Gamepad Library:

Classes

class  gamepad::Gamepad
 an instance of a physical gamepad. More...
class  gamepad::Manager
 you'll want one of these to get at source devices (gamepad::SourceDevice) and create gamepad objects (gamepad::Gamepad). More...

Functions

virtual Type * gamepad::Gamepad::getType (void) const =0 throw ()
 what type of gamepad is this? This object (gamepad::Type) will tell you how many buttons, how many joysticks, etc.
virtual const char * gamepad::Gamepad::getId (void)=0 throw ()
 get the ID (right now this is "source device:mapping" IDs)
virtual const char * gamepad::Gamepad::getSourceDeviceId (void)=0 throw ()
 which source device is this?
virtual const char * gamepad::Gamepad::getMappingId (void)=0 throw ()
 which mapping is this gamepad using?
virtual eDeviceState gamepad::Gamepad::getState (void)=0 throw ()
 is the gamepad currently connected (sending events)?
virtual buttons_t gamepad::Gamepad::getButtons (void)=0 throw ()
 if button with index X is pressed then bit X will be set
virtual eButton gamepad::Gamepad::getButton (IN int idx)=0 throw ()
 retrieve the value of a particular button
virtual void gamepad::Gamepad::getJoystick (IN int idx, OUT joystick_t &joy)=0 throw ()
 retrieve the value of a particular joystick
virtual void gamepad::Gamepad::getPot (IN int idx, OUT pot_value_t &pv)=0 throw ()
 retrieve the value of a particular potentiometer
virtual eDpad gamepad::Gamepad::getDpad (IN int idx)=0 throw ()
 retrieve the value of a particular dpad
static void gamepad::getButtonsChanged (IN buttons_t prev_buttons, IN buttons_t curr_buttons, OUT buttons_t &pressed, OUT buttons_t &released) throw ()
 given previous + current button state, say what was pressed and released
smart_ptr< i18n::Manager > gamepad::getConfigLocaleMgr (IN const char *primaryLocale, IN const char *defaultLocale, IN nstream::Folder *dataDirectory)
 return the localization manager for gamepad configuration
smart_ptr< i18n::Manager > gamepad::getTypeLocaleMgr (IN const Type *type, IN const char *primaryLocale, IN const char *defaultLocale, IN nstream::Folder *dataDirectory)
 return the localization manager for the specified gamepad::Type



enum  gamepad::eDpad {
  gamepad::eDpad_Centered = 0,
  gamepad::eDpad_Left = 1,
  gamepad::eDpad_Right = 2,
  gamepad::eDpad_Up = 4,
  gamepad::eDpad_Down = 8,
  gamepad::eDpad_UpLeft = eDpad_Up | eDpad_Left,
  gamepad::eDpad_UpRight = eDpad_Up | eDpad_Right,
  gamepad::eDpad_DownLeft = eDpad_Down | eDpad_Left,
  gamepad::eDpad_DownRight = eDpad_Down | eDpad_Right,
  gamepad::eDpad_Invalid = 16
}
 

the current position of a dpad.

More...
smart_ptr< Map > gamepad::readMap (IN const Datahash *hash)
 read mapping from a datahash (often a text file)
smart_ptr< Datahash > gamepad::writeMap (IN const Map *map)
 write mapping to a datahash (you can then use Datahash utility methods to write to a stream etc)
typedef uint32_t gamepad::buttons_t
 all button values OR'd together



enum  gamepad::eInputType {
  gamepad::eInput_Button = 0x01,
  gamepad::eInput_Joystick = 0x02,
  gamepad::eInput_Pot = 0x04,
  gamepad::eInput_Dpad = 0x08,
  gamepad::eInput_Invalid = 0x00
}
smart_ptr< Type > gamepad::readType (IN nstream::Stream *stream)
 read a gamepad type object from the given datahash
void gamepad::addGamepadTypesInFolderToMap (IO nstream::Folder *folder, IO gamepad_type_map_t &map)
 load all gamepad objects in the specified folder, and add them to the provided map (keyed by name, see gamepad::Type::getName() ).
typedef std::map< std::string,
smart_ptr< Type > > 
gamepad::gamepad_type_map_t
 maps from name --> gamepad type object

Typedef Documentation

typedef uint32_t gamepad::buttons_t

all button values OR'd together

Definition at line 93 of file gamepad-map.h.

typedef std::map<std::string, smart_ptr<Type> > gamepad::gamepad_type_map_t

maps from name --> gamepad type object

Definition at line 118 of file gamepad-type.h.


Enumeration Type Documentation

the current position of a dpad.

A dpad is a "Directional Pad", see http://en.wikipedia.org/wiki/D-pad

Enumerator:
eDpad_Centered 

dpad is not pressed or tilted at all

eDpad_Left 

pushed left

eDpad_Right 

pushed right

eDpad_Up 

pushed up

eDpad_Down 

pushed straight down

eDpad_UpLeft 
eDpad_UpRight 
eDpad_DownLeft 
eDpad_DownRight 
eDpad_Invalid 

Definition at line 54 of file gamepad-map.h.

A type of input object (button, joystick, potentiometer, directional pad...)

Enumerator:
eInput_Button 

simple on/off button or switch

eInput_Joystick 

2-axis joystick

eInput_Pot 

potentiometer (1-dimensional variable)

eInput_Dpad 

directional pad

eInput_Invalid 

Definition at line 50 of file gamepad-type.h.


Function Documentation

virtual Type* gamepad::Gamepad::getType ( void   )  const throw () [pure virtual, inherited]

what type of gamepad is this? This object (gamepad::Type) will tell you how many buttons, how many joysticks, etc.

virtual const char* gamepad::Gamepad::getId ( void   )  throw () [pure virtual, inherited]

get the ID (right now this is "source device:mapping" IDs)

virtual const char* gamepad::Gamepad::getSourceDeviceId ( void   )  throw () [pure virtual, inherited]

which source device is this?

virtual const char* gamepad::Gamepad::getMappingId ( void   )  throw () [pure virtual, inherited]

which mapping is this gamepad using?

virtual eDeviceState gamepad::Gamepad::getState ( void   )  throw () [pure virtual, inherited]

is the gamepad currently connected (sending events)?

virtual buttons_t gamepad::Gamepad::getButtons ( void   )  throw () [pure virtual, inherited]

if button with index X is pressed then bit X will be set

virtual eButton gamepad::Gamepad::getButton ( IN int  idx  )  throw () [pure virtual, inherited]

retrieve the value of a particular button

virtual void gamepad::Gamepad::getJoystick ( IN int  idx,
OUT joystick_t joy 
) throw () [pure virtual, inherited]

retrieve the value of a particular joystick

virtual void gamepad::Gamepad::getPot ( IN int  idx,
OUT pot_value_t pv 
) throw () [pure virtual, inherited]

retrieve the value of a particular potentiometer

virtual eDpad gamepad::Gamepad::getDpad ( IN int  idx  )  throw () [pure virtual, inherited]

retrieve the value of a particular dpad

static void gamepad::getButtonsChanged ( IN buttons_t  prev_buttons,
IN buttons_t  curr_buttons,
OUT buttons_t &  pressed,
OUT buttons_t &  released 
) throw () [inline, static]

given previous + current button state, say what was pressed and released

Definition at line 105 of file lib/gamepad/gamepad.h.

smart_ptr< i18n::Manager > gamepad::getConfigLocaleMgr ( IN const char *  locale,
IN const char *  defaultLocale,
IN nstream::Folder *  dataDirectory 
)

return the localization manager for gamepad configuration

smart_ptr< i18n::Manager > gamepad::getTypeLocaleMgr ( IN const Type *  type,
IN const char *  locale,
IN const char *  defaultLocale,
IN nstream::Folder *  dataDirectory 
)

return the localization manager for the specified gamepad::Type

smart_ptr< Map > gamepad::readMap ( IN const Datahash *  hash  ) 

read mapping from a datahash (often a text file)

smart_ptr<Datahash> gamepad::writeMap ( IN const Map *  map  ) 

write mapping to a datahash (you can then use Datahash utility methods to write to a stream etc)

smart_ptr< Type > gamepad::readType ( IN nstream::Stream *  stream  ) 

read a gamepad type object from the given datahash

void gamepad::addGamepadTypesInFolderToMap ( IO nstream::Folder *  folder,
IO gamepad_type_map_t &  map 
)

load all gamepad objects in the specified folder, and add them to the provided map (keyed by name, see gamepad::Type::getName() ).

This method is NOT recursive (it does not parse subfolders if any).