PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
JoystickController Class Reference

A Joystick controller which reads key states from a joystick device. More...

#include <controller_joystick.h>

Inheritance diagram for JoystickController:
Controller

Public Member Functions

 JoystickController ()
 Constructor.
 
 ~JoystickController ()
 Destructir.
 
void setJoystickDevice (SDL_Joystick *jctrl)
 Sets joystick device descriptor which will be used by this controller. More...
 
SDL_Joystick * getJoystickDevice () const
 Returns current joystick device descriptor. More...
 
void updateKey (bool &key, KM_Key &mkey)
 Takes a state of specified joystick key. More...
 
void update ()
 Read states of all control keys of a joystick device.
 
- Public Member Functions inherited from Controller
 Controller ()
 Constructor.
 
virtual ~Controller ()
 Desctructor.
 
virtual void setKeyMap (KeyMap map)
 Accepts control keys map which will associates physical keys of control device and command code. More...
 
void resetControls ()
 Sends "unpressed" control key states map to every registered controllable object.
 
void sendControls ()
 Sends current control key states map to every registered controllable object.
 
void registerInControl (ControllableObject *obj)
 Register controllable object to this controller. More...
 
void removeFromControl (ControllableObject *obj)
 Remove controllable object from this controller. More...
 

Static Public Member Functions

static bool bindJoystickKey (SDL_Joystick *joy, KM_Key &k)
 Detects a pressed key type and it's from a given joystick device and writes info into a given key description structure. More...
 
- Static Public Member Functions inherited from Controller
static controller_keys noKeys ()
 Initializes a control key states map with unpressed key states. More...
 

Additional Inherited Members

- Public Types inherited from Controller
enum  commands {
  key_start =0, key_left, key_right, key_up,
  key_down, key_run, key_jump, key_altrun,
  key_altjump, key_drop
}
 Control key command codes.
 
- Public Attributes inherited from Controller
controller_keys keys
 Current state of control keys.
 
- Protected Attributes inherited from Controller
KeyMap kmap
 Current control keys map.
 

Detailed Description

A Joystick controller which reads key states from a joystick device.

Member Function Documentation

bool JoystickController::bindJoystickKey ( SDL_Joystick *  joy,
KM_Key k 
)
static

Detects a pressed key type and it's from a given joystick device and writes info into a given key description structure.

Parameters
joyJosytick device descriptor
kJoystick key description
Returns
true if pressed key was been detected and returned through key description structure, false if no pressed keys
SDL_Joystick * JoystickController::getJoystickDevice ( ) const

Returns current joystick device descriptor.

Returns
Current joystic device descriptor currently associated with this controller. NULL if no joysticks was plugged
void JoystickController::setJoystickDevice ( SDL_Joystick *  jctrl)

Sets joystick device descriptor which will be used by this controller.

Parameters
Joystickdevice descriptor
void JoystickController::updateKey ( bool &  key,
KM_Key mkey 
)

Takes a state of specified joystick key.

Parameters
keyOutput key state which will be copied from actual joystick key state
mkeyJoystick key info

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