zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Zeni::Controllers Class Reference

The Controllers Singleton. More...

#include <Controllers.h>

Inherits Zeni::Singleton< Controllers >.

Public Member Functions

void detect_removed ()
 Fix to broken SDL device removal detection. More...
 
void device_added (const Sint32 &index)
 Register a new device. More...
 
void device_removed (const Sint32 &id)
 Remove a device. More...
 
void enable (const bool &enable_)
 Temporarily turn controller input on/off. More...
 
Sint32 get_controller_index (const Sint32 &id) const
 Get the index of a given controller from the true SDL_JoystickInstanceID. More...
 
const char * get_controller_name (const Sint32 &index) const
 Get the name of a given controller. More...
 
size_t get_num_controllers () const
 Get the number of controllers attached to the system. More...
 
bool is_controller_connected (const Sint32 &index) const
 Check to see if the controller is currently connected. More...
 
void reinit ()
 Reload all joysticks, flushing all SDL events and possibly changing 'which' values for controllers. More...
 
void reset_vibration_all ()
 Set vibration for all controllers to <0,0> More...
 
void set_vibration (const size_t &index, const float &left, const float &right)
 Set vibration for controller [0,...] to <[0,1],[0,1]> More...
 
- Public Member Functions inherited from Zeni::Singleton< Controllers >
void fax_post_reinit (Event::Handler *const &handler)
 
void fax_pre_uninit (Event::Handler *const &handler)
 
void give_post_reinit (Event::Handler *const &handler)
 
void give_pre_uninit (Event::Handler *const &handler)
 
void lend_post_reinit (Event::Handler *const &handler)
 
void lend_pre_uninit (Event::Handler *const &handler)
 

Friends

class Singleton< Controllers >
 

Additional Inherited Members

- Static Public Member Functions inherited from Zeni::Singleton< Controllers >
static void completely_destroy ()
 
static void destroy ()
 
static Controllersget ()
 
static bool is_initialized ()
 
static void remove_post_reinit (Event::Handler *const &handler)
 
static void remove_pre_uninit (Event::Handler *const &handler)
 
- Protected Member Functions inherited from Zeni::Singleton< Controllers >
 Singleton ()
 
virtual ~Singleton ()
 

Detailed Description

The Controllers Singleton.

The Controllers singleton is responsible for managing joysticks.

Author
bazald

Contact: bazal.nosp@m.d@ze.nosp@m.nipex.nosp@m..com

Definition at line 50 of file Controllers.h.

Member Function Documentation

void Zeni::Controllers::detect_removed ( )

Fix to broken SDL device removal detection.

Definition at line 166 of file Controllers.cpp.

References device_removed(), SDL_FALSE, and SDL_JoystickGetAttached().

Referenced by Zeni::Game::run().

void Zeni::Controllers::device_removed ( const Sint32 id)

Remove a device.

Definition at line 156 of file Controllers.cpp.

Referenced by detect_removed().

void Zeni::Controllers::enable ( const bool &  enable_)

Temporarily turn controller input on/off.

Definition at line 92 of file Controllers.cpp.

References SDL_DISABLE, SDL_ENABLE, and SDL_GameControllerEventState().

Referenced by Zeni::Gamestate_Base::on_active().

Sint32 Zeni::Controllers::get_controller_index ( const Sint32 id) const

Get the index of a given controller from the true SDL_JoystickInstanceID.

Definition at line 67 of file Controllers.cpp.

References i.

Referenced by Zeni::Game::on_event().

const char * Zeni::Controllers::get_controller_name ( const Sint32 index) const

Get the name of a given controller.

Definition at line 76 of file Controllers.cpp.

References assert, and SDL_JoystickName().

size_t Zeni::Controllers::get_num_controllers ( ) const

Get the number of controllers attached to the system.

Definition at line 63 of file Controllers.cpp.

bool Zeni::Controllers::is_controller_connected ( const Sint32 index) const

Check to see if the controller is currently connected.

Definition at line 81 of file Controllers.cpp.

References SDL_GameControllerGetAttached(), and SDL_TRUE.

void Zeni::Controllers::reinit ( )
virtual

Reload all joysticks, flushing all SDL events and possibly changing 'which' values for controllers.

Reimplemented from Zeni::Singleton< Controllers >.

Definition at line 87 of file Controllers.cpp.

void Zeni::Controllers::reset_vibration_all ( )

Set vibration for all controllers to <0,0>

Definition at line 204 of file Controllers.cpp.

References i, and set_vibration().

Referenced by Zeni::Popup_State::on_push(), and Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::on_uncover().

void Zeni::Controllers::set_vibration ( const size_t index,
const float &  left,
const float &  right 
)

Set vibration for controller [0,...] to <[0,1],[0,1]>

Definition at line 193 of file Controllers.cpp.

References SDL_ClearError(), and SDL_HapticUpdateEffect().

Referenced by reset_vibration_all().

Friends And Related Function Documentation

friend class Singleton< Controllers >
friend

Definition at line 51 of file Controllers.h.


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