1e902cc1852ce90c0d47dd739ac4a2821fd4118e
[WebKit-https.git] / Tools / WebKitTestRunner / ios / IOKitSPI.h
1 /*
2  * Copyright (C) 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef IOKitSPI_h
27 #define IOKitSPI_h
28
29 #import <wtf/Platform.h>
30
31 #if PLATFORM(IOS)
32
33 #if USE(APPLE_INTERNAL_SDK)
34
35 #import <IOKit/hid/IOHIDEvent.h>
36 #import <IOKit/hid/IOHIDEventSystemClient.h>
37 #import <IOKit/hid/IOHIDUsageTables.h>
38
39 #else
40
41 WTF_EXTERN_C_BEGIN
42
43 #ifdef __LP64__
44 typedef double IOHIDFloat;
45 #else
46 typedef float IOHIDFloat;
47 #endif
48
49 enum {
50     kIOHIDEventOptionNone = 0,
51 };
52
53 typedef UInt32 IOOptionBits;
54 typedef uint32_t IOHIDEventOptionBits;
55 typedef uint32_t IOHIDEventField;
56
57 typedef struct __IOHIDEventSystemClient * IOHIDEventSystemClientRef;
58 typedef struct __IOHIDEvent * IOHIDEventRef;
59
60 #define IOHIDEventFieldBase(type) (type << 16)
61
62 enum {
63     kHIDPage_VendorDefinedStart     = 0xFF00
64 };
65
66 enum {
67     kIOHIDDigitizerEventRange       = 1<<0,
68     kIOHIDDigitizerEventTouch       = 1<<1,
69     kIOHIDDigitizerEventPosition    = 1<<2,
70     kIOHIDDigitizerEventIdentity    = 1<<5,
71     kIOHIDDigitizerEventAttribute   = 1<<6,
72     kIOHIDDigitizerEventCancel      = 1<<7,
73     kIOHIDDigitizerEventStart       = 1<<8,
74 };
75 typedef uint32_t IOHIDDigitizerEventMask;
76
77 enum {
78     kIOHIDEventTypeNULL,
79     kIOHIDEventTypeVendorDefined,
80     kIOHIDEventTypeKeyboard = 3,
81     kIOHIDEventTypeDigitizer = 11,
82 };
83 typedef uint32_t IOHIDEventType;
84
85 enum {
86     kIOHIDEventFieldVendorDefinedUsagePage = IOHIDEventFieldBase(kIOHIDEventTypeVendorDefined),
87     kIOHIDEventFieldVendorDefinedReserved,
88     kIOHIDEventFieldVendorDefinedReserved1,
89     kIOHIDEventFieldVendorDefinedDataLength,
90     kIOHIDEventFieldVendorDefinedData
91 };
92
93 enum {
94     kIOHIDEventFieldDigitizerX = IOHIDEventFieldBase(kIOHIDEventTypeDigitizer),
95     kIOHIDEventFieldDigitizerY,
96     kIOHIDEventFieldDigitizerMajorRadius = kIOHIDEventFieldDigitizerX + 20,
97     kIOHIDEventFieldDigitizerMinorRadius,
98     kIOHIDEventFieldDigitizerIsDisplayIntegrated = kIOHIDEventFieldDigitizerMajorRadius + 5,
99 };
100
101 enum {
102     kIOHIDDigitizerTransducerTypeHand = 3
103 };
104 typedef uint32_t IOHIDDigitizerTransducerType;
105
106 IOHIDEventRef IOHIDEventCreateDigitizerEvent(CFAllocatorRef, uint64_t, IOHIDDigitizerTransducerType, uint32_t, uint32_t, IOHIDDigitizerEventMask, uint32_t, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, boolean_t, boolean_t, IOOptionBits);
107
108 IOHIDEventRef IOHIDEventCreateDigitizerFingerEvent(CFAllocatorRef, uint64_t, uint32_t, uint32_t, IOHIDDigitizerEventMask, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, boolean_t, boolean_t, IOHIDEventOptionBits);
109
110 IOHIDEventRef IOHIDEventCreateForceEvent(CFAllocatorRef, uint64_t, uint32_t, IOHIDFloat, uint32_t, IOHIDFloat, IOHIDEventOptionBits);
111
112 IOHIDEventRef IOHIDEventCreateKeyboardEvent(CFAllocatorRef, uint64_t, uint32_t, uint32_t, boolean_t, IOOptionBits);
113
114 IOHIDEventRef IOHIDEventCreateVendorDefinedEvent(CFAllocatorRef, uint64_t, uint32_t, uint32_t, uint32_t, uint8_t*, CFIndex, IOHIDEventOptionBits);
115
116 IOHIDEventType IOHIDEventGetType(IOHIDEventRef);
117
118 void IOHIDEventSetFloatValue(IOHIDEventRef, IOHIDEventField, IOHIDFloat);
119
120 CFIndex IOHIDEventGetIntegerValue(IOHIDEventRef, IOHIDEventField);
121 void IOHIDEventSetIntegerValue(IOHIDEventRef, IOHIDEventField, CFIndex);
122
123 void IOHIDEventAppendEvent(IOHIDEventRef, IOHIDEventRef, IOOptionBits);
124
125 IOHIDEventSystemClientRef IOHIDEventSystemClientCreate(CFAllocatorRef);
126
127 #define kGSEventPathInfoInRange (1 << 0)
128 #define kGSEventPathInfoInTouch (1 << 1)
129
130 WTF_EXTERN_C_END
131
132 #endif // USE(APPLE_INTERNAL_SDK)
133
134 #endif // PLATFORM(IOS)
135
136 #endif // IOKitSPI_h