#include <HIDManager.h>
Public Member Functions | |
HIDManager () | |
~HIDManager () | |
bool | handleEvent (const SDL_Event &event) |
void | handleDelayedEvents () |
void | resetBindings () |
void | loadBindings () |
void | saveBindings () |
void | bind (const Pentagram::istring &control, const Console::ArgvType &argv) |
void | unbind (const Pentagram::istring &control) |
Static Public Member Functions | |
static HIDManager * | get_instance () |
static void | ConCmd_bind (const Console::ArgvType &argv) |
static void | ConCmd_unbind (const Console::ArgvType &argv) |
static void | ConCmd_listbinds (const Console::ArgvType &argv) |
static void | ConCmd_save (const Console::ArgvType &argv) |
Private Member Functions | |
void | listBindings () |
Private Attributes | |
std::vector< Console::ArgvType * > | commands |
Console::ArgvType * | bindings [HID_LAST][HID_EVENT_LAST] |
uint32 | lastDown [HID_LAST] |
uint32 | double_timeout |
Static Private Attributes | |
static HIDManager * | hidmanager = 0 |
Definition at line 28 of file HIDManager.h.
HIDManager::HIDManager | ( | ) |
Definition at line 31 of file HIDManager.cpp.
References con, double_timeout, hidmanager, InitJoystick(), MM_INFO, Console::Print(), and resetBindings().
HIDManager::~HIDManager | ( | ) |
Definition at line 44 of file HIDManager.cpp.
References commands, con, hidmanager, MM_INFO, Console::Print(), and ShutdownJoystick().
void HIDManager::bind | ( | const Pentagram::istring & | control, | |
const Console::ArgvType & | argv | |||
) |
loads a single keybinding
control | a key or button to bind | |
bindingName | name of the HIDBinding |
Definition at line 244 of file HIDManager.cpp.
References bindings, commands, HID_BACKQUOTE, HID_EVENT_DEPRESS, HID_EVENT_LAST, HID_GetEventFromName(), HID_GetKeyFromName(), HID_LAST, pout, and Pentagram::StringToArgv().
Referenced by ConCmd_bind(), loadBindings(), and unbind().
void HIDManager::ConCmd_bind | ( | const Console::ArgvType & | argv | ) | [static] |
"bind" console command
Definition at line 299 of file HIDManager.cpp.
References bind(), get_instance(), hidmanager, and pout.
Referenced by GUIApp::GUIApp(), and GUIApp::~GUIApp().
void HIDManager::ConCmd_listbinds | ( | const Console::ArgvType & | argv | ) | [static] |
"listbinds" console command
Definition at line 336 of file HIDManager.cpp.
References get_instance(), hidmanager, and listBindings().
Referenced by GUIApp::GUIApp(), and GUIApp::~GUIApp().
void HIDManager::ConCmd_save | ( | const Console::ArgvType & | argv | ) | [static] |
"save" console command
Definition at line 342 of file HIDManager.cpp.
References SettingManager::get_instance(), get_instance(), hidmanager, saveBindings(), and SettingManager::write().
Referenced by GUIApp::GUIApp(), and GUIApp::~GUIApp().
void HIDManager::ConCmd_unbind | ( | const Console::ArgvType & | argv | ) | [static] |
"unbind" console command
Definition at line 321 of file HIDManager.cpp.
References get_instance(), hidmanager, pout, and unbind().
Referenced by GUIApp::GUIApp(), and GUIApp::~GUIApp().
static HIDManager* HIDManager::get_instance | ( | ) | [inline, static] |
obtain the singleton instance of the HIDManager
Definition at line 35 of file HIDManager.h.
References hidmanager.
Referenced by ConCmd_bind(), ConCmd_listbinds(), ConCmd_save(), ConCmd_unbind(), ControlEntryGump::init(), BindGump::OnKeyDown(), and BindGump::OnMouseDown().
void HIDManager::handleDelayedEvents | ( | ) |
Definition at line 130 of file HIDManager.cpp.
References bindings, con, double_timeout, Console::ExecuteConsoleCommand(), HID_EVENT_CLICK, HID_LAST, and lastDown.
Referenced by GUIApp::run().
bool HIDManager::handleEvent | ( | const SDL_Event & | event | ) |
execute the Console command associated with the event
event | an SDL_Event used to find an appropriate Console command |
Definition at line 62 of file HIDManager.cpp.
References bindings, con, double_timeout, Console::ExecuteConsoleCommand(), HID_EVENT_DEPRESS, HID_EVENT_DOUBLE, HID_EVENT_LAST, HID_EVENT_RELEASE, HID_LAST, HID_translateSDLJoystickButton(), HID_translateSDLKey(), HID_translateSDLMouseButton(), and lastDown.
Referenced by GUIApp::handleEvent().
void HIDManager::listBindings | ( | ) | [private] |
Definition at line 351 of file HIDManager.cpp.
References Pentagram::ArgvToString(), bindings, HID_EVENT_DEPRESS, HID_EVENT_LAST, HID_GetEventName(), HID_GetKeyName(), HID_LAST, and pout.
Referenced by ConCmd_listbinds(), and loadBindings().
void HIDManager::loadBindings | ( | ) |
loads the keybindings from the configuration
Definition at line 181 of file HIDManager.cpp.
References bind(), con, ConfigFileManager::get_instance(), SettingManager::get_instance(), listBindings(), SettingManager::listDataValues(), ConfigFileManager::listKeyValues(), MM_INFO, Console::Print(), and Pentagram::StringToArgv().
Referenced by GUIApp::startupGame().
void HIDManager::resetBindings | ( | ) |
Reset the keybindings.
Definition at line 149 of file HIDManager.cpp.
References bindings, commands, HID_BACKQUOTE, HID_EVENT_DEPRESS, HID_EVENT_LAST, HID_F5, HID_LAST, and lastDown.
Referenced by HIDManager().
void HIDManager::saveBindings | ( | ) |
saves the keybindings to the configuration
Definition at line 216 of file HIDManager.cpp.
References Pentagram::ArgvToString(), bindings, SettingManager::exists(), SettingManager::get_instance(), HID_EVENT_LAST, HID_GetEventName(), HID_GetKeyName(), HID_LAST, SettingManager::set(), and SettingManager::unset().
Referenced by ConCmd_save().
void HIDManager::unbind | ( | const Pentagram::istring & | control | ) |
removes all controls to a HIDBinding or the binding to one specified key
bindingName | name of a HIDBinding or the name of key |
Definition at line 292 of file HIDManager.cpp.
References bind().
Referenced by ConCmd_unbind(), and BindGump::OnKeyDown().
Console::ArgvType* HIDManager::bindings[HID_LAST][HID_EVENT_LAST] [private] |
Definition at line 78 of file HIDManager.h.
Referenced by bind(), handleDelayedEvents(), handleEvent(), listBindings(), resetBindings(), and saveBindings().
std::vector<Console::ArgvType *> HIDManager::commands [private] |
Definition at line 77 of file HIDManager.h.
Referenced by bind(), resetBindings(), and ~HIDManager().
uint32 HIDManager::double_timeout [private] |
Definition at line 80 of file HIDManager.h.
Referenced by handleDelayedEvents(), handleEvent(), and HIDManager().
HIDManager * HIDManager::hidmanager = 0 [static, private] |
Definition at line 82 of file HIDManager.h.
Referenced by ConCmd_bind(), ConCmd_listbinds(), ConCmd_save(), ConCmd_unbind(), get_instance(), HIDManager(), and ~HIDManager().
uint32 HIDManager::lastDown[HID_LAST] [private] |
Definition at line 79 of file HIDManager.h.
Referenced by handleDelayedEvents(), handleEvent(), and resetBindings().