Panda3D
Classes | Public Member Functions | Static Public Member Functions | List of all members
ButtonRegistry Class Reference

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 ButtonRegistryptr ()
 Returns the pointer to the global ButtonRegistry object. More...
 

Detailed Description

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.

Member Function Documentation

◆ find_ascii_button()

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().

◆ find_button()

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().

◆ get_alias()

ButtonHandle ButtonRegistry::get_alias ( ButtonHandle  button) const
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().

◆ get_button()

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().

◆ get_name()

std::string ButtonRegistry::get_name ( ButtonHandle  button) const
inline

Returns the name of the indicated button.

Definition at line 40 of file buttonRegistry.I.

◆ ptr()

ButtonRegistry * ButtonRegistry::ptr ( )
inlinestatic

◆ register_button()

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().


The documentation for this class was generated from the following files: