55 enum class DeviceClass {
141 ALWAYS_INLINE
bool is_known()
const;
142 ALWAYS_INLINE
bool is_pressed()
const;
145 operator bool() {
return _state != S_unknown; }
147 MAKE_PROPERTY(known, is_known);
148 MAKE_PROPERTY(pressed, is_pressed);
153 State _state = S_unknown;
161 operator bool() {
return known && value != 0.0; }
163 Axis axis = Axis::none;
178 short max_level = -1;
182 InputDevice(
const std::string &name, DeviceClass dev_class);
190 INLINE std::string get_name()
const;
191 INLINE std::string get_manufacturer()
const;
192 INLINE std::string get_serial_number()
const;
193 INLINE
unsigned short get_vendor_id()
const;
194 INLINE
unsigned short get_product_id()
const;
196 INLINE DeviceClass get_device_class()
const;
198 INLINE
bool has_pointer()
const;
199 INLINE
bool has_keyboard()
const;
200 INLINE
bool has_tracker()
const;
201 INLINE
bool has_vibration()
const;
202 INLINE
bool has_battery()
const;
207 INLINE
size_t get_num_buttons()
const;
209 INLINE
bool is_button_pressed(
size_t index)
const;
210 INLINE
bool is_button_known(
size_t index)
const;
213 INLINE
size_t get_num_axes()
const;
214 INLINE
double get_axis_value(
size_t index)
const;
215 INLINE
bool is_axis_known(
size_t index)
const;
216 INLINE
AxisState get_axis(
size_t index)
const;
220 MAKE_PROPERTY(name, get_name);
223 MAKE_PROPERTY(manufacturer, get_manufacturer);
226 MAKE_PROPERTY(serial_number, get_serial_number);
229 MAKE_PROPERTY(vendor_id, get_vendor_id);
232 MAKE_PROPERTY(product_id, get_product_id);
240 MAKE_PROPERTY(device_class, get_device_class);
243 INLINE
bool has_feature(Feature feature)
const;
246 MAKE_PROPERTY2(tracker, has_tracker, get_tracker);
247 MAKE_PROPERTY2(battery, has_battery, get_battery);
250 MAKE_SEQ_PROPERTY(buttons, get_num_buttons, get_button);
251 MAKE_SEQ_PROPERTY(axes, get_num_axes, get_axis);
254 INLINE
void map_button(
size_t index,
ButtonHandle handle);
255 INLINE
void map_axis(
size_t index, Axis axis);
257 INLINE
AxisState find_axis(Axis axis)
const;
260 INLINE
void set_vibration(
double strong,
double weak);
262 INLINE
void enable_pointer_events();
263 INLINE
void disable_pointer_events();
267 bool has_button_event()
const;
269 bool has_pointer_event()
const;
272 virtual void output(std::ostream &out)
const;
275 static std::string format_device_class(DeviceClass dc);
276 static std::string format_axis(Axis axis);
279 INLINE
void enable_feature(Feature feature);
283 int add_axis(Axis axis,
int minimum,
int maximum,
bool centered);
284 int add_axis(Axis axis,
int minimum,
int maximum);
286 int add_pointer(
PointerType type,
int id,
bool primary =
false);
287 void remove_pointer(
int id);
288 void update_pointer(
PointerData data,
double time);
289 void pointer_moved(
int id,
double x,
double y,
double time);
290 void button_changed(
int index,
bool down);
291 void axis_changed(
int index,
int value);
292 void set_axis_value(
int index,
double state);
294 void tracker_changed(
const LPoint3 &pos,
const LOrientation &orient,
double time);
296 virtual void do_set_vibration(
double low,
double high);
297 virtual void do_poll();
300 INLINE
void set_connected(
bool connected);
302 void output_buttons(std::ostream &out)
const;
303 void write_buttons(std::ostream &out,
int indent_level)
const;
304 void write_axes(std::ostream &out,
int indent_level)
const;
312 std::string _serial_number;
313 std::string _manufacturer;
314 DeviceClass _device_class = DeviceClass::unknown;
315 unsigned int _features = 0;
316 int _event_sequence = 0;
317 unsigned short _vendor_id = 0;
318 unsigned short _product_id = 0;
319 bool _is_connected =
false;
320 bool _enable_pointer_events =
false;
324 size_t _num_pointers = 0;
335 BatteryData _battery_data;
342 static void init_type() {
343 TypedReferenceCount::init_type();
345 TypedReferenceCount::get_class_type());
348 return get_class_type();
350 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
356 INLINE std::ostream &operator << (std::ostream &out,
const InputDevice &device) {
361 EXPCL_PANDA_DEVICE std::ostream &operator << (std::ostream &out, InputDevice::DeviceClass dc);
362 EXPCL_PANDA_DEVICE std::ostream &operator << (std::ostream &out, InputDevice::Axis axis);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(), along with zero to four record_derivation()s.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
Records a set of pointer events that happened recently.
This is our own Panda specialization on the default STL deque.
PointerType
Contains the types of pointer device.
bool is_connected(MObject &node, const string &attribute_name)
Returns true if the named connection exists on the node and is connected to anything, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Holds the data that might be generated by a 2-d pointer input device, such as the mouse in the Graphi...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Stores the kinds of data that a tracker might output.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
This is a standard, non-reentrant mutex, similar to the Mutex class.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.