forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttonMap.cxx
More file actions
61 lines (53 loc) · 1.42 KB
/
buttonMap.cxx
File metadata and controls
61 lines (53 loc) · 1.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
/**
* 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."
*
* @file buttonMap.cxx
* @author rdb
* @date 2014-03-09
*/
#include "buttonMap.h"
#include "indent.h"
TypeHandle ButtonMap::_type_handle;
/**
* Registers a new button mapping.
*/
void ButtonMap::
map_button(ButtonHandle raw_button, ButtonHandle button, const std::string &label) {
int index = raw_button.get_index();
if (_button_map.find(index) != _button_map.end()) {
// A button with this index was already mapped.
return;
}
ButtonNode bnode;
bnode._raw = raw_button;
bnode._mapped = button;
bnode._label = label;
_button_map[index] = bnode;
_buttons.push_back(&_button_map[index]);
}
/**
*
*/
void ButtonMap::
output(std::ostream &out) const {
out << "ButtonMap (" << get_num_buttons() << " buttons)";
}
/**
*
*/
void ButtonMap::
write(std::ostream &out, int indent_level) const {
indent(out, indent_level)
<< "ButtonMap, " << get_num_buttons() << " buttons:\n";
pvector<ButtonNode*>::const_iterator it;
for (it = _buttons.begin(); it != _buttons.end(); ++it) {
const ButtonNode *bn = *it;
indent(out, indent_level + 2)
<< bn->_raw << " -> " << bn->_mapped << " \"" << bn->_label << "\"\n";
}
}