Libpointing
An open-source cross-platform library to get raw events from pointing devices and master transfer functions.
osxHIDPointingDevice.h
1 /* -*- mode: c++ -*-
2  *
3  * pointing/input/osx/osxHIDPointingDevice.h --
4  *
5  * Initial software
6  * Authors: Nicolas Roussel
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 osxHIDPointingDevice_h
17 #define osxHIDPointingDevice_h
18 
19 #include <pointing/input/osx/osxHIDInputDevice.h>
20 #include <pointing/input/PointingDevice.h>
21 #include <pointing/utils/URI.h>
22 #include <pointing/utils/TimeStamp.h>
23 
24 namespace pointing {
25 
27 
28  struct PointingReport {
29  TimeStamp::inttime t ;
30  int32_t dx, dy ;
31  uint32_t btns ;
32 
33  PointingReport(void) ;
34  PointingReport& operator = (PointingReport& src) ;
35  void clear(void) ; // preserves btns
36  bool isOlderThan(TimeStamp::inttime t) const ;
37  // bool isMoreRecentThan(TimeStamp::inttime t) const ;
38  bool setButton(uint32_t index, uint32_t value) ;
39  std::string toString(void) const ;
40  } ;
41 
42  TimeStamp::inttime epoch_mach ;
43  TimeStamp::inttime epoch ;
44 
45  int vendorID, productID ;
46  int primaryUsagePage, primaryUsage ;
47 
48  osxHIDInputDevice *hiddev ;
49  PointingCallback callback ;
50  void *callback_context ;
51  bool use_report_callback ;
52  bool use_queue_callback ;
53  PointingReport qreport ;
54 
55  double forced_cpi, forced_hz ;
56 
57  bool isUSB(void) ;
58  bool isBluetooth(void) ;
59 
60  static void hidReportCallback(void *context, IOReturn result, void *sender,
61  IOHIDReportType type, uint32_t reportID,
62  uint8_t *report, CFIndex reportLength) ;
63 
64  static void hidQueueCallback(void *context, IOReturn result, void *sender) ;
65 
66  void report(osxHIDPointingDevice::PointingReport &r) ;
67 
68  public:
69 
70  osxHIDPointingDevice(URI uri) ;
71 
72  bool isActive(void) const ;
73 
74  int getVendorID(void) const ;
75  std::string getVendor(void) const ;
76  int getProductID(void) const ;
77  std::string getProduct(void) const ;
78  double getResolution(double *defval=0) const ;
79  double getUpdateFrequency(double *defval=0) const ;
80 
81  URI getURI(bool expanded=false, bool crossplatform=false) const ;
82 
83  void setPointingCallback(PointingCallback callback, void *context=0) ;
84 
85  void setDebugLevel(int level) ;
86 
87  ~osxHIDPointingDevice(void) ;
88 
89  } ;
90 
91 }
92 
93 #endif
std::string getProduct(void) const
Readable product name.
Definition: osxHIDPointingDevice.cpp:165
bool isActive(void) const
Indicates whether the current device is active.
Definition: osxHIDPointingDevice.cpp:83
void setPointingCallback(PointingCallback callback, void *context=0)
Sets the callback function which is called when device events occur.
Definition: osxHIDPointingDevice.cpp:210
URI getURI(bool expanded=false, bool crossplatform=false) const
Constructs the URI according to the parameters of the device.
Definition: osxHIDPointingDevice.cpp:88
double getUpdateFrequency(double *defval=0) const
Update frequency of the mouse in Hz.
Definition: osxHIDPointingDevice.cpp:187
int getProductID(void) const
Product identifier number.
Definition: osxHIDPointingDevice.cpp:158
std::string getVendor(void) const
Readable vendor name.
Definition: osxHIDPointingDevice.cpp:151
double getResolution(double *defval=0) const
Resolution of the mouse in CPI (counts per inch).
Definition: osxHIDPointingDevice.cpp:174
Definition: DummyPointingDevice.cpp:23
The PointingDevice class is used to represent Pointing Devices connected to the computer or pseudo-de...
Definition: PointingDevice.h:35
int getVendorID(void) const
Vendor identifier number.
Definition: osxHIDPointingDevice.cpp:144
void setDebugLevel(int level)
Sets the level of information for debugging purposes (default = 0).
Definition: osxHIDPointingDevice.cpp:205
void(* PointingCallback)(void *context, TimeStamp::inttime timestamp, int dx, int dy, int buttons)
Definition: PointingDevice.h:76
Definition: osxHIDPointingDevice.h:26