Libpointing
An open-source cross-platform library to get raw events from pointing devices and master transfer functions.
 All Classes Functions Variables Typedefs Enumerator Pages
linuxPointingDeviceManager.h
1 /* -*- mode: c++ -*-
2  *
3  * pointing/input/linux/linuxPointingDeviceManager.h --
4  *
5  * Initial software
6  * Authors: Izzatbek Mukhanov
7  * Copyright © Inria
8  *
9  * http://libpointing.org/
10  *
11  * This software may be used and distributed according to the terms of
12  * the GNU General Public License version 2 or any later version.
13  *
14  */
15 
16 #ifndef linuxPointingDeviceManager_h
17 #define linuxPointingDeviceManager_h
18 
19 #include <pointing/input/PointingDeviceManager.h>
20 #include <pointing/input/linux/linuxPointingDevice.h>
21 #include <pthread.h>
22 #include <libudev.h>
23 
24 namespace pointing {
25 
26  class HIDReportParser;
27 
33  {
34  friend class PointingDeviceManager;
35  friend class linuxPointingDevice;
36 
37  // Add linux-specific data
38  struct linuxPointingDeviceData : PointingDeviceData
39  {
40  int fd = -1;
41  pthread_t thread;
42  udev_device *evDev = NULL;
43  // If there are several PointingDevice objects with seize
44  // corresponding to the same physical device
45  // Seize the device until all of them are deleted
46  int seizeCount = 0;
47  int buttons = 0;
48  std::string devnode;
49  };
50 
51  struct udev *udev;
52  struct udev_monitor *monitor;
53 
54  pthread_t thread;
55 
56  static void cleanup_handler(void *arg);
57 
62  static void *eventloop(void *self);
63  static void *checkReports(void *self);
64 
65  void enableDevice(bool value, std::string fullName);
66 
67  void monitor_readable();
68  void readable(linuxPointingDeviceData *pdd);
69 
70  bool outputsRelative(udev_device *dev);
71 
72  int readHIDDescriptor(int devID, HIDReportParser *parser);
73  void fillDevInfo(udev_device *hiddev, linuxPointingDeviceData *pdd);
74 
75  void processMatching(PointingDeviceData *pdd, SystemPointingDevice *device);
76 
77  void checkFoundDevice(udev_device *device);
78  void checkLostDevice(udev_device *device);
79 
80  void unSeizeDevice(linuxPointingDeviceData *data);
81  virtual void removePointingDevice(SystemPointingDevice *device) override;
82 
85  };
86 }
87 
88 #endif
Definition: linuxPointingDevice.h:23
The PointingDeviceManager class is a helper class which enumerates the list of existing pointing devi...
Definition: PointingDeviceManager.h:87
The SystemPointingDevice class is used to represent Pointing Devices connected to the computer...
Definition: SystemPointingDevice.h:28
Definition: PointingDeviceManager.h:112
The linuxPointingDeviceManager class is the platform-specific subclass of the PointingDeviceManager c...
Definition: linuxPointingDeviceManager.h:32