Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

peon::InputEngine Class Reference

This object keeps an eye on the input received by SDL. More...

#include <InputEngine.h>

Inheritance diagram for peon::InputEngine:

peon::ISingleton< InputEngine > List of all members.

Public Member Functions

 InputEngine ()
 Constructor.
 ~InputEngine ()
 Destructor.
bool loadEngine (IniConfigReader *pConfig)
 This method loads up and configures our input devices.
void unloadEngine ()
 This method just unloads and frees any allocated input devices.
Sint16 getJoyXAxis ()
 This method returns the current X axis of the joystick.
Sint16 getJoyYAxis ()
 This method returns the current Y axis of the joystick.

Static Public Member Functions

static InputEnginegetSingleton (void)
 Override standard Singleton retrieval.
static InputEnginegetSingletonPtr (void)
 Override standard Singleton retrieval.

Protected Attributes

SDL_Joystick * m_pJoystick
 handle to the joystick
bool m_bJoystickConnected
 is there a joystick connected?

Detailed Description

This object keeps an eye on the input received by SDL.

This singleton object is a manager "of sorts" for the input devices available on the system.


Member Function Documentation

Sint16 peon::InputEngine::getJoyXAxis  ) 
 

This method returns the current X axis of the joystick.

Returns:
Sint16 - value of our x axis

Sint16 peon::InputEngine::getJoyYAxis  ) 
 

This method returns the current Y axis of the joystick.

Returns:
Sint16 - value of our y axis

static InputEngine& peon::InputEngine::getSingleton void   )  [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from peon::ISingleton< InputEngine >.

static InputEngine* peon::InputEngine::getSingletonPtr void   )  [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from peon::ISingleton< InputEngine >.

bool peon::InputEngine::loadEngine IniConfigReader pConfig  ) 
 

This method loads up and configures our input devices.

SDL will automagically create our handles to the keyboard and mouse device, so we're really only talking about initializing a handle to the joystick.

I always return true, as I feel the game should not bail just because the joystick was not found/inited properly. Feel free to modify depending upon your game's needs.

Parameters:
pConfig - a valid IniConfigReader instance
Returns:
bool - always true


The documentation for this class was generated from the following file:
Generated on Thu Dec 1 01:55:41 2005 for Peon by  doxygen 1.4.1