53class EXPCL_PANDA_DEVICE InputDevice :
public TypedReferenceCount {
57 enum class DeviceClass {
147 constexpr ButtonState() =
default;
149 ALWAYS_INLINE
bool is_known()
const;
153 operator bool() {
return _state != S_unknown; }
161 State _state = S_unknown;
166 constexpr AxisState() =
default;
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);
194 InputDevice(
const InputDevice ©) =
delete;
195 InputDevice &operator = (
const InputDevice ©) =
delete;
196 virtual ~InputDevice();
198 INLINE std::string
get_name()
const;
263 INLINE
void map_axis(
size_t index, Axis axis);
280 virtual void output(std::ostream &out)
const;
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();
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;
333 typedef pvector<PointerData> Pointers;
337 typedef pvector<ButtonState> Buttons;
338 typedef pvector<AxisState> Axes;
343 BatteryData _battery_data;
350 static void init_type() {
351 TypedReferenceCount::init_type();
353 TypedReferenceCount::get_class_type());
355 virtual TypeHandle get_type()
const {
356 return get_class_type();
358 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
361 static TypeHandle _type_handle;
364INLINE std::ostream &operator << (std::ostream &out,
const InputDevice &device) {
369EXPCL_PANDA_DEVICE std::ostream &operator << (std::ostream &out, InputDevice::DeviceClass dc);
370EXPCL_PANDA_DEVICE std::ostream &operator << (std::ostream &out, InputDevice::Axis axis);
This is a standard, non-reentrant mutex, similar to the Mutex class.
Holds the data that might be generated by a 2-d pointer input device, such as the mouse in the Graphi...
Records a set of pointer events that happened recently.
Stores the kinds of data that a tracker might output.
TypeHandle is the identifier used to differentiate C++ class types.
This is our own Panda specialization on the default STL deque.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PointerType
Contains the types of pointer device.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.