16 #include "clientButtonDevice.h" 28 ClientButtonDevice(
ClientBase *client,
const string &device_name):
46 ensure_button_index(index);
47 nassertv(index >= 0 && index < (
int)_buttons.size());
48 _buttons[index]._state = down ? S_down : S_up;
52 _button_events->add_event(
ButtonEvent(handle, down ? ButtonEvent::T_down : ButtonEvent::T_up));
64 void ClientButtonDevice::
65 ensure_button_index(
int index) {
68 _buttons.reserve(index + 1);
69 while ((
int)_buttons.size() <= index) {
70 _buttons.push_back(ButtonState());
79 void ClientButtonDevice::
80 output(ostream &out)
const {
91 void ClientButtonDevice::
92 write(ostream &out,
int indent_level)
const {
93 indent(out, indent_level) << get_type() <<
" " <<
get_device_name() <<
":\n";
105 bool any_buttons =
false;
106 Buttons::const_iterator bi;
107 for (bi = _buttons.begin(); bi != _buttons.end(); ++bi) {
108 const ButtonState &state = (*bi);
109 if (state._state != S_unknown) {
114 out << (int)(bi - _buttons.begin()) <<
"=";
115 if (state._state == S_up) {
124 out <<
"no known buttons";
136 bool any_buttons =
false;
137 Buttons::const_iterator bi;
138 for (bi = _buttons.begin(); bi != _buttons.end(); ++bi) {
139 const ButtonState &state = (*bi);
140 if (state._state != S_unknown) {
143 indent(out, indent_level)
144 << (int)(bi - _buttons.begin()) <<
". ";
147 out <<
"(" << state._handle <<
") ";
150 if (state._state == S_up) {
160 indent(out, indent_level)
161 <<
"(no known buttons)\n";
const string & get_device_name() const
Returns the device name reported to the ClientBase.
An abstract base class for a family of client device interfaces–including trackers, buttons, dials, and other analog inputs.
TypeHandle is the identifier used to differentiate C++ class types.
Any of a number of different devices that might be attached to a ClientBase, including trackers...