Panda3D
|
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse buttons (but see KeyboardButton and MouseButton). More...
#include "buttonHandle.h"
Public Member Functions | |
ButtonHandle () | |
The default constructor must do nothing, because we can't guarantee ordering of static initializers. More... | |
ButtonHandle (int index) | |
Constructs a ButtonHandle with the corresponding index number, which may have been returned by an earlier call to ButtonHandle::get_index(). More... | |
ButtonHandle (const ButtonHandle ©) | |
ButtonHandle (const string &name) | |
Constructs a ButtonHandle with the corresponding name, which is looked up in the ButtonRegistry. More... | |
int | compare_to (const ButtonHandle &other) const |
Sorts ButtonHandles arbitrarily (according to <, >, etc.). More... | |
ButtonHandle | get_alias () const |
Returns the alias (alternate name) associated with the button, if any, or ButtonHandle::none() if the button has no alias. More... | |
char | get_ascii_equivalent () const |
Returns the character code associated with the button, or '\0' if no ASCII code was associated. More... | |
size_t | get_hash () const |
Returns a hash code suitable for phash_map. More... | |
int | get_index () const |
Returns the integer index associated with this ButtonHandle. More... | |
string | get_name () const |
Returns the name of the button. More... | |
bool | has_ascii_equivalent () const |
Returns true if the button was created with an ASCII equivalent code (e.g. More... | |
bool | matches (const ButtonHandle &other) const |
Returns true if this ButtonHandle is the same as the other one, or if the other one is an alias for this one. More... | |
operator bool () const | |
ButtonHandle::none() evaluates to false, everything else evaluates to true. More... | |
bool | operator!= (const ButtonHandle &other) const |
bool | operator< (const ButtonHandle &other) const |
bool | operator<= (const ButtonHandle &other) const |
bool | operator== (const ButtonHandle &other) const |
bool | operator> (const ButtonHandle &other) const |
bool | operator>= (const ButtonHandle &other) const |
void | output (ostream &out) const |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static ButtonHandle | none () |
Returns a special zero-valued ButtonHandle that is used to indicate no button. More... | |
Friends | |
class | ButtonRegistry |
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse buttons (but see KeyboardButton and MouseButton).
Definition at line 28 of file buttonHandle.h.
|
inline |
The default constructor must do nothing, because we can't guarantee ordering of static initializers.
If the constructor tried to initialize its value, it might happen after the value had already been set previously by another static initializer!
Definition at line 26 of file buttonHandle.I.
Referenced by ButtonHandle().
|
inline |
Constructs a ButtonHandle with the corresponding index number, which may have been returned by an earlier call to ButtonHandle::get_index().
Definition at line 37 of file buttonHandle.I.
References ButtonHandle(), and compare_to().
ButtonHandle::ButtonHandle | ( | const string & | name | ) |
Constructs a ButtonHandle with the corresponding name, which is looked up in the ButtonRegistry.
This exists for the purpose of being able to automatically coerce a string into a ButtonHandle; for most purposes, you should use either the static KeyboardButton/MouseButton getters or ButtonRegistry::register_button().
Definition at line 35 of file buttonHandle.cxx.
References ButtonRegistry::get_button(), get_name(), and ButtonRegistry::ptr().
|
inline |
Sorts ButtonHandles arbitrarily (according to <, >, etc.).
Returns a number less than 0 if this type sorts before the other one, greater than zero if it sorts after, 0 if they are equivalent.
Definition at line 118 of file buttonHandle.I.
References get_hash().
Referenced by ButtonHandle().
ButtonHandle ButtonHandle::get_alias | ( | ) | const |
Returns the alias (alternate name) associated with the button, if any, or ButtonHandle::none() if the button has no alias.
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.
Definition at line 67 of file buttonHandle.cxx.
References ButtonRegistry::get_alias(), none(), and ButtonRegistry::ptr().
Referenced by get_name(), and matches().
|
inline |
Returns the character code associated with the button, or '\0' if no ASCII code was associated.
Definition at line 151 of file buttonHandle.I.
References has_ascii_equivalent(), and matches().
Referenced by has_ascii_equivalent(), eglGraphicsWindow::set_properties_now(), and x11GraphicsWindow::set_properties_now().
|
inline |
Returns a hash code suitable for phash_map.
Definition at line 128 of file buttonHandle.I.
References has_ascii_equivalent().
Referenced by compare_to().
|
inline |
Returns the integer index associated with this ButtonHandle.
Each different ButtonHandle will have a different index. However, you probably shouldn't be using this method; you should just treat the ButtonHandles as opaque classes. This is provided for the convenience of non-C++ scripting languages to build a hashtable of ButtonHandles.
Definition at line 184 of file buttonHandle.I.
References get_name(), and none().
Referenced by ButtonMap::get_mapped_button(), ButtonMap::get_mapped_button_label(), RocketInputHandler::get_rocket_key(), MouseWatcher::is_button_down(), ButtonMap::map_button(), matches(), and MouseWatcher::note_activity().
string ButtonHandle::get_name | ( | ) | const |
Returns the name of the button.
Definition at line 45 of file buttonHandle.cxx.
References get_alias(), ButtonRegistry::get_name(), none(), and ButtonRegistry::ptr().
Referenced by ButtonHandle(), PGEntry::get_accept_event(), PGEntry::get_accept_failed_event(), PGButton::get_click_event(), get_index(), PGItem::get_press_event(), PGItem::get_release_event(), PGItem::get_repeat_event(), MouseWatcher::note_activity(), ButtonThrower::write(), and ButtonEvent::write_datagram().
|
inline |
Returns true if the button was created with an ASCII equivalent code (e.g.
for a standard keyboard button).
Definition at line 140 of file buttonHandle.I.
References get_ascii_equivalent().
Referenced by get_ascii_equivalent(), get_hash(), eglGraphicsWindow::set_properties_now(), and x11GraphicsWindow::set_properties_now().
|
inline |
Returns true if this ButtonHandle is the same as the other one, or if the other one is an alias for this one.
(Does not return true if this button is an alias for the other one, however.)
This is a more general comparison than operator ==.
Definition at line 166 of file buttonHandle.I.
References get_alias(), get_index(), and none().
Referenced by ModifierButtons::button_down(), ModifierButtons::button_up(), get_ascii_equivalent(), ModifierButtons::has_button(), and ModifierButtons::is_down().
|
inlinestatic |
Returns a special zero-valued ButtonHandle that is used to indicate no button.
Definition at line 205 of file buttonHandle.I.
Referenced by ModifierButtons::add_button(), MouseButton::button(), ButtonRegistry::find_ascii_button(), ButtonRegistry::find_button(), get_alias(), ButtonRegistry::get_alias(), ModifierButtons::get_button(), ClientButtonDevice::get_button_map(), MouseWatcher::get_inactivity_timeout_event(), get_index(), ButtonMap::get_mapped_button(), ButtonMap::get_mapped_button_label(), get_name(), KeyboardButton::init_keyboard_buttons(), matches(), MouseWatcher::note_activity(), ClientButtonDevice::set_button_state(), eglGraphicsWindow::set_properties_now(), x11GraphicsWindow::set_properties_now(), AndroidGraphicsWindow::set_properties_now(), WinGraphicsWindow::static_window_proc(), and ClientButtonDevice::write_buttons().
|
inline |
ButtonHandle::none() evaluates to false, everything else evaluates to true.
Definition at line 216 of file buttonHandle.I.