Panda3D
 All Classes Functions Variables Enumerations
buttonRegistry.I
1 // Filename: buttonRegistry.I
2 // Created by: drose (01Mar00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "pnotify.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: ButtonRegistry::RegistryNode::Constructor
19 // Access: Public
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 INLINE ButtonRegistry::RegistryNode::
23 RegistryNode(ButtonHandle handle, ButtonHandle alias, const string &name) :
24  _handle(handle), _alias(alias), _name(name)
25 {
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: ButtonRegistry::ptr
30 // Access: Published, Static
31 // Description: Returns the pointer to the global ButtonRegistry
32 // object.
33 ////////////////////////////////////////////////////////////////////
35 ptr() {
36  if (_global_pointer == (ButtonRegistry *)NULL) {
37  init_global_pointer();
38  }
39  return _global_pointer;
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: ButtonRegistry::get_name
44 // Access: Public
45 // Description: Returns the name of the indicated button.
46 ////////////////////////////////////////////////////////////////////
47 INLINE string ButtonRegistry::
48 get_name(ButtonHandle button) const {
49  RegistryNode *rnode = look_up(button);
50  nassertr(rnode != (RegistryNode *)NULL, "");
51  return rnode->_name;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: ButtonRegistry::get_alias
56 // Access: Public
57 // Description: Returns the alias for the indicated button, or
58 // ButtonHandle::none() if the button has no specified
59 // alias.
60 ////////////////////////////////////////////////////////////////////
62 get_alias(ButtonHandle button) const {
63  RegistryNode *rnode = look_up(button);
64  nassertr(rnode != (RegistryNode *)NULL, ButtonHandle::none());
65  return rnode->_alias;
66 }
static ButtonHandle none()
Returns a special zero-valued ButtonHandle that is used to indicate no button.
Definition: buttonHandle.I:205
The ButtonRegistry class maintains all the assigned ButtonHandles in a given system.
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
ButtonHandle get_alias(ButtonHandle button) const
Returns the alias for the indicated button, or ButtonHandle::none() if the button has no specified al...
static ButtonRegistry * ptr()
Returns the pointer to the global ButtonRegistry object.
string get_name(ButtonHandle button) const
Returns the name of the indicated button.