The ButtonRegistry class maintains all the assigned ButtonHandles in a given system. More...
#include "buttonRegistry.h"
Public Member Functions | |
ButtonHandle | find_ascii_button (char ascii_equivalent) const |
Finds a ButtonHandle in the registry matching the indicated ASCII equivalent character. More... | |
ButtonHandle | find_button (const std::string &name) |
Finds a ButtonHandle in the registry matching the indicated name. More... | |
ButtonHandle | get_alias (ButtonHandle button) const |
Returns the alias for the indicated button, or ButtonHandle::none() if the button has no specified alias. More... | |
ButtonHandle | get_button (const std::string &name) |
Finds a ButtonHandle in the registry matching the indicated name. More... | |
std::string | get_name (ButtonHandle button) const |
Returns the name of the indicated button. More... | |
bool | register_button (ButtonHandle &button_handle, const std::string &name, ButtonHandle alias=ButtonHandle::none(), char ascii_equivalent='\0') |
Registers a new ButtonHandle with the indicated name, and if specified, the indicated ASCII equivalent. More... | |
void | write (std::ostream &out) const |
Static Public Member Functions | |
static ButtonRegistry * | ptr () |
Returns the pointer to the global ButtonRegistry object. More... | |
The ButtonRegistry class maintains all the assigned ButtonHandles in a given system.
There should be only one ButtonRegistry class during the lifetime of the application.
Definition at line 29 of file buttonRegistry.h.
ButtonHandle ButtonRegistry::find_ascii_button | ( | char | ascii_equivalent | ) | const |
Finds a ButtonHandle in the registry matching the indicated ASCII equivalent character.
If there is no such ButtonHandle, returns ButtonHandle::none().
Definition at line 147 of file buttonRegistry.cxx.
Referenced by KeyboardButton::ascii_key().
ButtonHandle ButtonRegistry::find_button | ( | const std::string & | name | ) |
Finds a ButtonHandle in the registry matching the indicated name.
If there is no such ButtonHandle, returns ButtonHandle::none().
Definition at line 130 of file buttonRegistry.cxx.
Referenced by ButtonMap::get_mapped_button(), and ButtonMap::get_mapped_button_label().
|
inline |
Returns the alias for the indicated button, or ButtonHandle::none() if the button has no specified alias.
Definition at line 51 of file buttonRegistry.I.
Referenced by ButtonHandle::matches().
ButtonHandle ButtonRegistry::get_button | ( | const std::string & | name | ) |
Finds a ButtonHandle in the registry matching the indicated name.
If there is no such ButtonHandle, registers a new one and returns it.
Definition at line 112 of file buttonRegistry.cxx.
References register_button().
Referenced by ButtonHandle::ButtonHandle(), and ButtonEvent::read_datagram().
|
inline |
Returns the name of the indicated button.
Definition at line 40 of file buttonRegistry.I.
|
inlinestatic |
Returns the pointer to the global ButtonRegistry object.
Definition at line 29 of file buttonRegistry.I.
Referenced by KeyboardButton::ascii_key(), ButtonHandle::ButtonHandle(), ButtonMap::get_mapped_button(), ButtonMap::get_mapped_button_label(), GamepadButton::init_gamepad_buttons(), KeyboardButton::init_keyboard_buttons(), and ButtonEvent::read_datagram().
bool ButtonRegistry::register_button | ( | ButtonHandle & | button_handle, |
const std::string & | name, | ||
ButtonHandle | alias = ButtonHandle::none() , |
||
char | ascii_equivalent = '\0' |
||
) |
Registers a new ButtonHandle with the indicated name, and if specified, the indicated ASCII equivalent.
Returns true if the button was registered, or false it was already registered; in either case, the new ButtonHandle is loaded into the first parameter.
If the alias is not ButtonHandle::none(), it indicates an alias (alternate name) for the same button. Each button is allowed to have one alias, and multiple different buttons can refer to the same alias. The alias should be the more general name for the button, for instance, shift is an alias for lshift, but not vice-versa.
This defines a new kind of button matching the indicated name. The ButtonHandle can then be passed around to devices as a button in its own right.
Definition at line 44 of file buttonRegistry.cxx.
Referenced by get_button(), GamepadButton::init_gamepad_buttons(), and KeyboardButton::init_keyboard_buttons().