forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttonMap.I
More file actions
141 lines (132 loc) · 5.42 KB
/
buttonMap.I
File metadata and controls
141 lines (132 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Filename: buttonMap.I
// Created by: rdb (09Mar14)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: ButtonMap::get_num_buttons
// Access: Published
// Description: Returns the number of buttons that this button
// mapping specifies.
////////////////////////////////////////////////////////////////////
INLINE int ButtonMap::
get_num_buttons() const {
return _buttons.size();
}
////////////////////////////////////////////////////////////////////
// Function: ButtonMap::get_raw_button
// Access: Published
// Description: Returns the underlying raw button associated with
// the nth button.
////////////////////////////////////////////////////////////////////
INLINE ButtonHandle ButtonMap::
get_raw_button(int i) const {
return _buttons[i]->_raw;
}
////////////////////////////////////////////////////////////////////
// Function: ButtonMap::get_mapped_button
// Access: Published
// Description: Returns the nth mapped button, meaning the button
// that the nth raw button is mapped to.
////////////////////////////////////////////////////////////////////
INLINE ButtonHandle ButtonMap::
get_mapped_button(int i) const {
return _buttons[i]->_mapped;
}
////////////////////////////////////////////////////////////////////
// Function: ButtonMap::get_mapped_button_label
// Access: Published
// Description: Returns the label associated with the nth mapped
// button, meaning the button that the nth raw
// button is mapped to.
////////////////////////////////////////////////////////////////////
INLINE const string &ButtonMap::
get_mapped_button_label(int i) const {
return _buttons[i]->_label;
}
////////////////////////////////////////////////////////////////////
// Function: ButtonMap::get_mapped_button
// Access: Published
// Description: 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.
////////////////////////////////////////////////////////////////////
INLINE ButtonHandle ButtonMap::
get_mapped_button(ButtonHandle raw) const {
pmap<int, ButtonNode>::const_iterator it;
it = _button_map.find(raw.get_index());
if (it == _button_map.end()) {
return ButtonHandle::none();
} else {
return it->second._mapped;
}
}
////////////////////////////////////////////////////////////////////
// Function: ButtonMap::get_mapped_button
// Access: Published
// Description: 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.
////////////////////////////////////////////////////////////////////
INLINE ButtonHandle ButtonMap::
get_mapped_button(const string &raw_name) const {
ButtonHandle raw_button = ButtonRegistry::ptr()->find_button(raw_name);
if (raw_button == ButtonHandle::none()) {
return ButtonHandle::none();
} else {
return get_mapped_button(raw_button);
}
}
////////////////////////////////////////////////////////////////////
// Function: ButtoMap::get_mapped_button_label
// Access: Published
// Description: 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.
////////////////////////////////////////////////////////////////////
INLINE const string &ButtonMap::
get_mapped_button_label(ButtonHandle raw) const {
pmap<int, ButtonNode>::const_iterator it;
it = _button_map.find(raw.get_index());
if (it == _button_map.end()) {
static const string empty = "";
return empty;
} else {
return it->second._label;
}
}
////////////////////////////////////////////////////////////////////
// Function: ButtoMap::get_mapped_button_label
// Access: Published
// Description: 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.
////////////////////////////////////////////////////////////////////
INLINE const string &ButtonMap::
get_mapped_button_label(const string &raw_name) const {
ButtonHandle raw_button = ButtonRegistry::ptr()->find_button(raw_name);
if (raw_button == ButtonHandle::none()) {
static const string empty = "";
return empty;
} else {
return get_mapped_button_label(raw_button);
}
}