zenilib
0.5.3.0
|
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 Controllers & | get () |
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 () |
The Controllers Singleton.
The Controllers singleton is responsible for managing joysticks.
Contact: bazal d@ze nipex .com
Definition at line 50 of file Controllers.h.
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().
Register a new device.
Definition at line 102 of file Controllers.cpp.
References SDL_ClearError(), SDL_free(), SDL_GameControllerMapping(), SDL_GameControllerOpen(), SDL_GetError(), SDL_HapticEffectSupported(), SDL_HapticNewEffect(), SDL_HapticOpenFromJoystick(), SDL_HapticRunEffect(), SDL_IsGameController(), SDL_JoystickGetGUID(), SDL_JoystickGetGUIDString(), SDL_JoystickInstanceID(), SDL_JoystickIsHaptic(), SDL_JoystickOpen(), and SDL_TRUE.
Referenced by Zeni::Game::on_event().
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().
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().
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.
Check to see if the controller is currently connected.
Definition at line 81 of file Controllers.cpp.
References SDL_GameControllerGetAttached(), and SDL_TRUE.
|
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().
|
friend |
Definition at line 51 of file Controllers.h.