ButtonMap

class ButtonMap

Bases: TypedReferenceCount

This class represents a map containing all of the buttons of a (keyboard) device, though it can also be used as a generic mapping between ButtonHandles. It maps an underlying ‘raw’ button to a ‘virtual’ button, which may optionally be associated with an appropriate platform-specific name for the button.

Inheritance diagram

Inheritance diagram of ButtonMap

ButtonMap(void) = default
ButtonMap(ButtonMap const&) = default
static TypeHandle get_class_type(void)
ButtonHandle get_mapped_button(std::size_t i) const
ButtonHandle get_mapped_button(ButtonHandle raw) const
ButtonHandle get_mapped_button(std::string const &raw_name) const

Returns the nth mapped button, meaning the button that the nth raw button is mapped to.

Returns the button that the given button is mapped to, or ButtonHandle::none() if this map does not specify a mapped button for the given raw button.

Returns the button that the given button is mapped to, or ButtonHandle::none() if this map does not specify a mapped button for the given raw button.

std::string const &get_mapped_button_label(std::size_t i) const
std::string const &get_mapped_button_label(ButtonHandle raw) const
std::string const &get_mapped_button_label(std::string const &raw_name) const

Returns the label associated with the nth mapped button, meaning the button that the nth raw button is mapped to.

If the button map specifies a special name for the button (eg. if the operating system or keyboard device has a localized name describing the key), returns it, or the empty string otherwise.

Note that this is not the same as get_mapped_button().get_name(), which returns the name of the Panda event associated with the button.

If the button map specifies a special name for the button (eg. if the operating system or keyboard device has a localized name describing the key), returns it, or the empty string otherwise.

Note that this is not the same as get_mapped_button().get_name(), which returns the name of the Panda event associated with the button.

std::size_t get_num_buttons(void) const

Returns the number of buttons that this button mapping specifies.

ButtonHandle get_raw_button(std::size_t i) const

Returns the underlying raw button associated with the nth button.

void output(std::ostream &out) const
void write(std::ostream &out, int indent_level = 0) const