File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -250,13 +250,8 @@ is_button_known(size_t index) const {
250
250
*/
251
251
INLINE InputDevice::ButtonState InputDevice::
252
252
get_button (size_t index) const {
253
- if (index < _buttons.size ()) {
254
- return _buttons[index];
255
- } else {
256
- device_cat.error ()
257
- << " Index " << index << " was not found in the axes list\n " ;
258
- return ButtonState ();
259
- }
253
+ nassertr_always (index < _buttons.size (), ButtonState ());
254
+ return _buttons[index];
260
255
}
261
256
262
257
/* *
@@ -270,8 +265,6 @@ find_button(ButtonHandle handle) const {
270
265
return _buttons[i];
271
266
}
272
267
}
273
- device_cat.error ()
274
- << " Handle " << handle.get_name () << " was not found in the axes list\n " ;
275
268
return ButtonState ();
276
269
}
277
270
@@ -321,13 +314,8 @@ get_axis_value(size_t index) const {
321
314
*/
322
315
INLINE InputDevice::AxisState InputDevice::
323
316
get_axis (size_t index) const {
324
- if (index < _axes.size ()) {
325
- return _axes[index];
326
- } else {
327
- device_cat.error ()
328
- << " Index " << index << " was not found in the axes list\n " ;
329
- return AxisState ();
330
- }
317
+ nassertr_always (index < _axes.size (), AxisState ());
318
+ return _axes[index];
331
319
}
332
320
333
321
/* *
@@ -341,8 +329,6 @@ find_axis(InputDevice::Axis axis) const {
341
329
return _axes[i];
342
330
}
343
331
}
344
- device_cat.error ()
345
- << " Axis " << axis << " was not found in the axes list\n " ;
346
332
return AxisState ();
347
333
}
348
334
Original file line number Diff line number Diff line change @@ -142,6 +142,8 @@ class EXPCL_PANDA_DEVICE InputDevice : public TypedReferenceCount {
142
142
ALWAYS_INLINE bool is_pressed () const ;
143
143
144
144
PUBLISHED:
145
+ operator bool () { return _state != S_unknown; }
146
+
145
147
MAKE_PROPERTY (known, is_known);
146
148
MAKE_PROPERTY (pressed, is_pressed);
147
149
@@ -156,6 +158,8 @@ class EXPCL_PANDA_DEVICE InputDevice : public TypedReferenceCount {
156
158
constexpr AxisState () = default;
157
159
158
160
PUBLISHED:
161
+ operator bool () { return known && value != 0.0 ; }
162
+
159
163
Axis axis = Axis::none;
160
164
double value = 0.0 ;
161
165
bool known = false ;
@@ -268,6 +272,8 @@ class EXPCL_PANDA_DEVICE InputDevice : public TypedReferenceCount {
268
272
PT (PointerEventList) get_pointer_events();
269
273
270
274
virtual void output (std::ostream &out) const ;
275
+
276
+ public:
271
277
static std::string format_device_class (DeviceClass dc);
272
278
static std::string format_axis (Axis axis);
273
279
You can’t perform that action at this time.
0 commit comments