Libpointing
An open-source cross-platform library to get raw events from pointing devices and master transfer functions.
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 #include <pointing/utils/HIDReportParser.h>
24 
25 namespace pointing {
26 
32  {
33  friend class PointingDeviceManager;
34  friend class linuxPointingDevice;
35 
36  // Add linux-specific data
37  struct linuxPointingDeviceData : PointingDeviceData
38  {
39  int fd = -1;
40  pthread_t thread;
41  udev_device *evDev = NULL;
42  // If there are several PointingDevice objects with seize
43  // corresponding to the same physical device
44  // Seize the device until all of them are deleted
45  int seizeCount = 0;
46  int buttons = 0;
47  std::string devnode;
48  };
49 
50  struct udev *udev;
51  struct udev_monitor *monitor;
52 
53  pthread_t thread;
54 
55  static void cleanup_handler(void *arg);
56 
61  static void *eventloop(void *self);
62  static void *checkReports(void *self);
63 
64  void enableDevice(bool value, std::string fullName);
65 
66  void monitor_readable();
67  void readable(linuxPointingDeviceData *pdd);
68 
69  bool outputsRelative(udev_device *dev);
70 
71  int readHIDDescriptor(int devID, HIDReportParser *parser);
72  void fillDevInfo(udev_device *hiddev, linuxPointingDeviceData *pdd);
73 
74  void processMatching(PointingDeviceData *pdd, SystemPointingDevice *device);
75 
76  void checkFoundDevice(udev_device *device);
77  void checkLostDevice(udev_device *device);
78 
79  void unSeizeDevice(linuxPointingDeviceData *data);
80  virtual void removePointingDevice(SystemPointingDevice *device) override;
81 
84  };
85 
86 }
87 
88 #endif
The PointingDeviceManager class is a helper class which enumerates the list of existing pointing devi...
Definition: PointingDeviceManager.h:86
Definition: linuxPointingDevice.h:23
The linuxPointingDeviceManager class is the platform-specific subclass of the PointingDeviceManager c...
Definition: linuxPointingDeviceManager.h:31
Definition: PointingDeviceManager.h:96
Definition: DummyPointingDevice.cpp:23
The SystemPointingDevice class is used to represent Pointing Devices connected to the computer...
Definition: SystemPointingDevice.h:28