Panda3D
ioKitInputDevice.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file ioKitInputDevice.h
10  * @author rdb
11  * @date 2017-12-21
12  */
13 
14 #ifndef IOKITINPUTDEVICE_H
15 #define IOKITINPUTDEVICE_H
16 
17 #include "pandabase.h"
18 #include "inputDevice.h"
19 
20 #if defined(__APPLE__) && !defined(CPPPARSER)
21 
22 #include <IOKit/hid/IOHIDDevice.h>
23 
24 /**
25  * This implementation uses the IOKit HID code that was introduced with macOS
26  * 10.5 to interface with USB HID devices.
27  */
28 class EXPCL_PANDA_DEVICE IOKitInputDevice final : public InputDevice {
29 public:
30  IOKitInputDevice(IOHIDDeviceRef device);
31  ~IOKitInputDevice();
32 
33  void on_remove();
34 
35 private:
36  void parse_element(IOHIDElementRef element);
37 
38  virtual void do_poll();
39 
40  IOHIDDeviceRef _device;
41  pvector<IOHIDElementRef> _button_elements;
42  pvector<IOHIDElementRef> _analog_elements;
43  IOHIDElementRef _hat_element;
44  int _hat_left_button;
45  IOHIDElementRef _pointer_x;
46  IOHIDElementRef _pointer_y;
47  IOHIDElementRef _scroll_wheel;
48  uint64_t _pointer_x_timestamp;
49  uint64_t _pointer_y_timestamp;
50  uint64_t _scroll_wheel_timestamp;
51 };
52 
53 #endif // __APPLE__
54 
55 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a structure representing a single input device.
Definition: inputDevice.h:53