57 enum class DeviceClass {
143 ALWAYS_INLINE
bool is_known()
const;
144 ALWAYS_INLINE
bool is_pressed()
const;
147 operator bool() {
return _state != S_unknown; }
149 MAKE_PROPERTY(known, is_known);
150 MAKE_PROPERTY(pressed, is_pressed);
155 State _state = S_unknown;
163 operator bool() {
return known && value != 0.0; }
165 Axis axis = Axis::none;
180 short max_level = -1;
184 InputDevice(
const std::string &name, DeviceClass dev_class);
192 INLINE std::string get_name()
const;
193 INLINE std::string get_manufacturer()
const;
194 INLINE std::string get_serial_number()
const;
195 INLINE
unsigned short get_vendor_id()
const;
196 INLINE
unsigned short get_product_id()
const;
198 INLINE DeviceClass get_device_class()
const;
200 INLINE
bool has_pointer()
const;
201 INLINE
bool has_keyboard()
const;
202 INLINE
bool has_tracker()
const;
203 INLINE
bool has_vibration()
const;
204 INLINE
bool has_battery()
const;
209 INLINE
size_t get_num_buttons()
const;
211 INLINE
bool is_button_pressed(
size_t index)
const;
212 INLINE
bool is_button_known(
size_t index)
const;
215 INLINE
size_t get_num_axes()
const;
216 INLINE
double get_axis_value(
size_t index)
const;
217 INLINE
bool is_axis_known(
size_t index)
const;
218 INLINE
AxisState get_axis(
size_t index)
const;
222 MAKE_PROPERTY(name, get_name);
225 MAKE_PROPERTY(manufacturer, get_manufacturer);
228 MAKE_PROPERTY(serial_number, get_serial_number);
231 MAKE_PROPERTY(vendor_id, get_vendor_id);
234 MAKE_PROPERTY(product_id, get_product_id);
242 MAKE_PROPERTY(device_class, get_device_class);
245 INLINE
bool has_feature(Feature feature)
const;
248 MAKE_PROPERTY2(tracker, has_tracker, get_tracker);
249 MAKE_PROPERTY2(battery, has_battery, get_battery);
252 MAKE_SEQ_PROPERTY(buttons, get_num_buttons, get_button);
253 MAKE_SEQ_PROPERTY(axes, get_num_axes, get_axis);
256 INLINE
void map_button(
size_t index,
ButtonHandle handle);
257 INLINE
void map_axis(
size_t index, Axis axis);
259 INLINE
AxisState find_axis(Axis axis)
const;
262 INLINE
void set_vibration(
double strong,
double weak);
264 INLINE
void enable_pointer_events();
265 INLINE
void disable_pointer_events();
269 bool has_button_event()
const;
271 bool has_pointer_event()
const;
274 virtual void output(std::ostream &out)
const;
277 static std::string format_device_class(DeviceClass dc);
278 static std::string format_axis(Axis axis);
281 INLINE
void enable_feature(Feature feature);
285 int add_axis(Axis axis,
int minimum,
int maximum,
bool centered);
286 int add_axis(Axis axis,
int minimum,
int maximum);
288 int add_pointer(
PointerType type,
int id,
bool primary =
false);
289 void remove_pointer(
int id);
290 void update_pointer(
PointerData data,
double time);
291 void pointer_moved(
int id,
double x,
double y,
double time);
292 void button_changed(
int index,
bool down);
293 void axis_changed(
int index,
int value);
294 void set_axis_value(
int index,
double state);
296 void tracker_changed(
const LPoint3 &pos,
const LOrientation &orient,
double time);
298 virtual void do_set_vibration(
double low,
double high);
299 virtual void do_poll();
302 INLINE
void set_connected(
bool connected);
304 void output_buttons(std::ostream &out)
const;
305 void write_buttons(std::ostream &out,
int indent_level)
const;
306 void write_axes(std::ostream &out,
int indent_level)
const;
314 std::string _serial_number;
315 std::string _manufacturer;
316 DeviceClass _device_class = DeviceClass::unknown;
317 unsigned int _features = 0;
318 int _event_sequence = 0;
319 unsigned short _vendor_id = 0;
320 unsigned short _product_id = 0;
321 bool _is_connected =
false;
322 bool _enable_pointer_events =
false;
326 size_t _num_pointers = 0;
337 BatteryData _battery_data;
344 static void init_type() {
345 TypedReferenceCount::init_type();
347 TypedReferenceCount::get_class_type());
350 return get_class_type();
352 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
358 INLINE std::ostream &operator << (std::ostream &out,
const InputDevice &device) {
363 EXPCL_PANDA_DEVICE std::ostream &operator << (std::ostream &out, InputDevice::DeviceClass dc);
364 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(),...
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,...
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.