57 enum class DeviceClass {
149 ALWAYS_INLINE
bool is_known()
const;
150 ALWAYS_INLINE
bool is_pressed()
const;
153 operator bool() {
return _state != S_unknown; }
155 MAKE_PROPERTY(known, is_known);
156 MAKE_PROPERTY(pressed, is_pressed);
161 State _state = S_unknown;
169 operator bool() {
return known && value != 0.0; }
171 Axis axis = Axis::none;
186 short max_level = -1;
190 InputDevice(
const std::string &name, DeviceClass dev_class);
198 INLINE std::string get_name()
const;
199 INLINE std::string get_manufacturer()
const;
200 INLINE std::string get_serial_number()
const;
201 INLINE
unsigned short get_vendor_id()
const;
202 INLINE
unsigned short get_product_id()
const;
204 INLINE DeviceClass get_device_class()
const;
206 INLINE
bool has_pointer()
const;
207 INLINE
bool has_keyboard()
const;
208 INLINE
bool has_tracker()
const;
209 INLINE
bool has_vibration()
const;
210 INLINE
bool has_battery()
const;
215 INLINE
size_t get_num_buttons()
const;
217 INLINE
bool is_button_pressed(
size_t index)
const;
218 INLINE
bool is_button_known(
size_t index)
const;
221 INLINE
size_t get_num_axes()
const;
222 INLINE
double get_axis_value(
size_t index)
const;
223 INLINE
bool is_axis_known(
size_t index)
const;
224 INLINE
AxisState get_axis(
size_t index)
const;
228 MAKE_PROPERTY(name, get_name);
231 MAKE_PROPERTY(manufacturer, get_manufacturer);
234 MAKE_PROPERTY(serial_number, get_serial_number);
237 MAKE_PROPERTY(vendor_id, get_vendor_id);
240 MAKE_PROPERTY(product_id, get_product_id);
248 MAKE_PROPERTY(device_class, get_device_class);
251 INLINE
bool has_feature(Feature feature)
const;
254 MAKE_PROPERTY2(tracker, has_tracker, get_tracker);
255 MAKE_PROPERTY2(battery, has_battery, get_battery);
258 MAKE_SEQ_PROPERTY(buttons, get_num_buttons, get_button);
259 MAKE_SEQ_PROPERTY(axes, get_num_axes, get_axis);
262 INLINE
void map_button(
size_t index,
ButtonHandle handle);
263 INLINE
void map_axis(
size_t index, Axis axis);
265 INLINE
AxisState find_axis(Axis axis)
const;
268 INLINE
void set_vibration(
double strong,
double weak);
270 INLINE
void enable_pointer_events();
271 INLINE
void disable_pointer_events();
275 bool has_button_event()
const;
277 bool has_pointer_event()
const;
280 virtual void output(std::ostream &out)
const;
283 static std::string format_device_class(DeviceClass dc);
284 static std::string format_axis(Axis axis);
287 INLINE
void enable_feature(Feature feature);
291 int add_axis(Axis axis,
int minimum,
int maximum,
bool centered);
292 int add_axis(Axis axis,
int minimum,
int maximum);
294 int add_pointer(
PointerType type,
int id,
bool primary =
false);
295 void remove_pointer(
int id);
296 void update_pointer(
PointerData data,
double time);
297 void pointer_moved(
int id,
double x,
double y,
double time);
298 void button_changed(
int index,
bool down);
299 void axis_changed(
int index,
int value);
300 void set_axis_value(
int index,
double state);
302 void tracker_changed(
const LPoint3 &pos,
const LOrientation &orient,
double time);
304 virtual void do_set_vibration(
double low,
double high);
305 virtual void do_poll();
308 INLINE
void set_connected(
bool connected);
310 void output_buttons(std::ostream &out)
const;
311 void write_buttons(std::ostream &out,
int indent_level)
const;
312 void write_axes(std::ostream &out,
int indent_level)
const;
320 std::string _serial_number;
321 std::string _manufacturer;
322 DeviceClass _device_class = DeviceClass::unknown;
323 unsigned int _features = 0;
324 int _event_sequence = 0;
325 unsigned short _vendor_id = 0;
326 unsigned short _product_id = 0;
327 bool _is_connected =
false;
328 bool _enable_pointer_events =
false;
332 size_t _num_pointers = 0;
343 BatteryData _battery_data;
350 static void init_type() {
351 TypedReferenceCount::init_type();
353 TypedReferenceCount::get_class_type());
356 return get_class_type();
358 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
364 INLINE std::ostream &operator << (std::ostream &out,
const InputDevice &device) {
369 EXPCL_PANDA_DEVICE std::ostream &operator << (std::ostream &out, InputDevice::DeviceClass dc);
370 EXPCL_PANDA_DEVICE std::ostream &operator << (std::ostream &out, InputDevice::Axis axis);