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

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. More...

#include "buttonMap.h"

Inheritance diagram for ButtonMap:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

Public Member Functions

virtual TypeHandle force_init_type ()
 
ButtonHandle get_mapped_button (int i) const
 Returns the nth mapped button, meaning the button that the nth raw button is mapped to. More...
 
ButtonHandle get_mapped_button (ButtonHandle raw) const
 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. More...
 
ButtonHandle get_mapped_button (const string &raw_name) const
 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. More...
 
const string & get_mapped_button_label (int i) const
 Returns the label associated with the nth mapped button, meaning the button that the nth raw button is mapped to. More...
 
const string & get_mapped_button_label (ButtonHandle raw) const
 If the button map specifies a special name for the button (eg. More...
 
const string & get_mapped_button_label (const string &raw_name) const
 If the button map specifies a special name for the button (eg. More...
 
int get_num_buttons () const
 Returns the number of buttons that this button mapping specifies. More...
 
ButtonHandle get_raw_button (int i) const
 Returns the underlying raw button associated with the nth button. More...
 
virtual TypeHandle get_type () const
 
void map_button (ButtonHandle raw_button, ButtonHandle button, const string &label="")
 Registers a new button mapping. More...
 
void output (ostream &out) const
 
void write (ostream &out, int indent_level=0) const
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
void operator= (const TypedObject &copy)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 Returns the current reference count. More...
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
void weak_ref (WeakPointerToVoid *ptv)
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref (WeakPointerToVoid *ptv)
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Detailed Description

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.

Definition at line 33 of file buttonMap.h.

Member Function Documentation

◆ get_mapped_button() [1/3]

ButtonHandle ButtonMap::get_mapped_button ( int  i) const
inline

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

Definition at line 45 of file buttonMap.I.

References get_mapped_button_label().

Referenced by get_mapped_button(), get_mapped_button_label(), and get_raw_button().

◆ get_mapped_button() [2/3]

ButtonHandle ButtonMap::get_mapped_button ( ButtonHandle  raw) const
inline

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.

Definition at line 69 of file buttonMap.I.

References ButtonHandle::get_index(), get_mapped_button(), and ButtonHandle::none().

◆ get_mapped_button() [3/3]

ButtonHandle ButtonMap::get_mapped_button ( const string &  raw_name) const
inline

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.

Definition at line 87 of file buttonMap.I.

References ButtonRegistry::find_button(), get_mapped_button(), get_mapped_button_label(), ButtonHandle::none(), and ButtonRegistry::ptr().

◆ get_mapped_button_label() [1/3]

const string & ButtonMap::get_mapped_button_label ( int  i) const
inline

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

Definition at line 57 of file buttonMap.I.

References get_mapped_button().

Referenced by get_mapped_button(), and get_mapped_button_label().

◆ get_mapped_button_label() [2/3]

const string & ButtonMap::get_mapped_button_label ( ButtonHandle  raw) const
inline

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.

Definition at line 109 of file buttonMap.I.

References ButtonHandle::get_index(), and get_mapped_button_label().

◆ get_mapped_button_label() [3/3]

const string & ButtonMap::get_mapped_button_label ( const string &  raw_name) const
inline

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.

Definition at line 133 of file buttonMap.I.

References ButtonRegistry::find_button(), get_mapped_button_label(), ButtonHandle::none(), and ButtonRegistry::ptr().

◆ get_num_buttons()

int ButtonMap::get_num_buttons ( ) const
inline

Returns the number of buttons that this button mapping specifies.

Definition at line 23 of file buttonMap.I.

References get_raw_button().

Referenced by map_button().

◆ get_raw_button()

ButtonHandle ButtonMap::get_raw_button ( int  i) const
inline

Returns the underlying raw button associated with the nth button.

Definition at line 34 of file buttonMap.I.

References get_mapped_button().

Referenced by get_num_buttons().

◆ map_button()

void ButtonMap::map_button ( ButtonHandle  raw_button,
ButtonHandle  button,
const string &  label = "" 
)

Registers a new button mapping.

Definition at line 26 of file buttonMap.cxx.

References ButtonHandle::get_index(), and get_num_buttons().

Referenced by x11GraphicsWindow::set_properties_now(), and WinGraphicsWindow::static_window_proc().


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