1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef touchinjection_sdk80_h
6 #define touchinjection_sdk80_h
7 
8 // Note, this isn't inclusive of all touch injection header info.
9 // You may need to add more to expand on current apis.
10 
11 #ifndef TOUCH_FEEDBACK_DEFAULT
12 
13 #define TOUCH_FEEDBACK_DEFAULT 0x1
14 #define TOUCH_FEEDBACK_INDIRECT 0x2
15 #define TOUCH_FEEDBACK_NONE 0x3
16 
17 enum {
18   PT_POINTER = 0x00000001,  // Generic pointer
19   PT_TOUCH = 0x00000002,    // Touch
20   PT_PEN = 0x00000003,      // Pen
21   PT_MOUSE = 0x00000004,    // Mouse
22 };
23 
24 typedef DWORD POINTER_INPUT_TYPE;
25 typedef UINT32 POINTER_FLAGS;
26 
27 typedef enum {
28   POINTER_CHANGE_NONE,
29   POINTER_CHANGE_FIRSTBUTTON_DOWN,
30   POINTER_CHANGE_FIRSTBUTTON_UP,
31   POINTER_CHANGE_SECONDBUTTON_DOWN,
32   POINTER_CHANGE_SECONDBUTTON_UP,
33   POINTER_CHANGE_THIRDBUTTON_DOWN,
34   POINTER_CHANGE_THIRDBUTTON_UP,
35   POINTER_CHANGE_FOURTHBUTTON_DOWN,
36   POINTER_CHANGE_FOURTHBUTTON_UP,
37   POINTER_CHANGE_FIFTHBUTTON_DOWN,
38   POINTER_CHANGE_FIFTHBUTTON_UP,
39 } POINTER_BUTTON_CHANGE_TYPE;
40 
41 typedef struct {
42   POINTER_INPUT_TYPE pointerType;
43   UINT32 pointerId;
44   UINT32 frameId;
45   POINTER_FLAGS pointerFlags;
46   HANDLE sourceDevice;
47   HWND hwndTarget;
48   POINT ptPixelLocation;
49   POINT ptHimetricLocation;
50   POINT ptPixelLocationRaw;
51   POINT ptHimetricLocationRaw;
52   DWORD dwTime;
53   UINT32 historyCount;
54   INT32 InputData;
55   DWORD dwKeyStates;
56   UINT64 PerformanceCount;
57   POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
58 } POINTER_INFO;
59 
60 typedef UINT32 TOUCH_FLAGS;
61 typedef UINT32 TOUCH_MASK;
62 
63 typedef struct {
64   POINTER_INFO pointerInfo;
65   TOUCH_FLAGS touchFlags;
66   TOUCH_MASK touchMask;
67   RECT rcContact;
68   RECT rcContactRaw;
69   UINT32 orientation;
70   UINT32 pressure;
71 } POINTER_TOUCH_INFO;
72 
73 #define TOUCH_FLAG_NONE 0x00000000  // Default
74 
75 #define TOUCH_MASK_NONE \
76   0x00000000  // Default - none of the optional fields are valid
77 #define TOUCH_MASK_CONTACTAREA 0x00000001  // The rcContact field is valid
78 #define TOUCH_MASK_ORIENTATION 0x00000002  // The orientation field is valid
79 #define TOUCH_MASK_PRESSURE 0x00000004     // The pressure field is valid
80 
81 #define POINTER_FLAG_NONE 0x00000000          // Default
82 #define POINTER_FLAG_NEW 0x00000001           // New pointer
83 #define POINTER_FLAG_INRANGE 0x00000002       // Pointer has not departed
84 #define POINTER_FLAG_INCONTACT 0x00000004     // Pointer is in contact
85 #define POINTER_FLAG_FIRSTBUTTON 0x00000010   // Primary action
86 #define POINTER_FLAG_SECONDBUTTON 0x00000020  // Secondary action
87 #define POINTER_FLAG_THIRDBUTTON 0x00000040   // Third button
88 #define POINTER_FLAG_FOURTHBUTTON 0x00000080  // Fourth button
89 #define POINTER_FLAG_FIFTHBUTTON 0x00000100   // Fifth button
90 #define POINTER_FLAG_PRIMARY 0x00002000       // Pointer is primary
91 #define POINTER_FLAG_CONFIDENCE \
92   0x00004000  // Pointer is considered unlikely to be accidental
93 #define POINTER_FLAG_CANCELED \
94   0x00008000  // Pointer is departing in an abnormal manner
95 #define POINTER_FLAG_DOWN \
96   0x00010000  // Pointer transitioned to down state (made contact)
97 #define POINTER_FLAG_UPDATE 0x00020000  // Pointer update
98 #define POINTER_FLAG_UP \
99   0x00040000  // Pointer transitioned from down state (broke contact)
100 #define POINTER_FLAG_WHEEL 0x00080000           // Vertical wheel
101 #define POINTER_FLAG_HWHEEL 0x00100000          // Horizontal wheel
102 #define POINTER_FLAG_CAPTURECHANGED 0x00200000  // Lost capture
103 
104 #endif  // TOUCH_FEEDBACK_DEFAULT
105 
106 #define TOUCH_FLAGS_CONTACTUPDATE \
107   (POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT)
108 #define TOUCH_FLAGS_CONTACTDOWN \
109   (POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT)
110 
111 typedef BOOL(WINAPI* InitializeTouchInjectionPtr)(UINT32 maxCount,
112                                                   DWORD dwMode);
113 typedef BOOL(WINAPI* InjectTouchInputPtr)(UINT32 count,
114                                           CONST POINTER_TOUCH_INFO* info);
115 
116 #endif  // touchinjection_sdk80_h