-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.d.ts
196 lines (161 loc) · 4.86 KB
/
env.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/// <reference types="vite/client" />
/*
* Keyboards
*/
type KeyboardId = string
type VariantId = string
type KeyIndex = Array<number>
interface Key {
index: KeyIndex
x: number
y: number
w: number
h: number
}
type HexColor = string
type ColorMap = Map<string, HexColor>
type Layout = Array<Key>
interface Keyboard {
id: KeyboardId
name: string
manufacturer: string
url: string
usb: HIDDeviceFilter
variants: Record<string, Layout>
}
/*
* WebHID
*/
interface HIDDeviceFilter {
vendorId?: number | undefined;
productId?: number | undefined;
usagePage?: number | undefined;
usage?: number | undefined;
}
interface HIDDeviceRequestOptions {
filters: HIDDeviceFilter[];
}
declare class HID extends EventTarget {
onconnect: ((this: this, ev: Event) => any) | null;
ondisconnect: ((this: this, ev: Event) => any) | null;
getDevices(): Promise<HIDDevice[]>;
requestDevice(options?: HIDDeviceRequestOptions): Promise<HIDDevice[]>;
addEventListener(
type: 'connect' | 'disconnect',
listener: (this: this, ev: HIDConnectionEvent) => any,
useCapture?: boolean,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject | null,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener(
type: 'connect' | 'disconnect',
callback: (this: this, ev: HIDConnectionEvent) => any,
useCapture?: boolean,
): void;
removeEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean,
): void;
}
interface Navigator {
readonly hid: HID;
}
interface HIDConnectionEventInit {
device: HIDDevice;
}
declare class HIDConnectionEvent extends Event {
constructor(type: string, eventInitDict: HIDConnectionEventInit);
readonly device: HIDDevice;
}
interface HIDInputReportEventInit extends EventInit {
device: HIDDevice;
reportId: number;
data: DataView;
}
declare class HIDInputReportEvent extends Event {
constructor(type: string, eventInitDict: HIDInputReportEventInit);
readonly device: HIDDevice;
readonly reportId: number;
readonly data: DataView;
}
type HIDUnitSystem =
| 'none'
| 'si-linear'
| 'si-rotation'
| 'english-linear'
| 'english-rotation'
| 'vendor-defined'
| 'reserved';
interface HIDReportItem {
isAbsolute?: boolean | undefined;
isArray?: boolean | undefined;
isBufferedBytes?: boolean | undefined;
isConstant?: boolean | undefined;
isLinear?: boolean | undefined;
isRange?: boolean | undefined;
isVolatile?: boolean | undefined;
hasNull?: boolean | undefined;
hasPreferredState?: boolean | undefined;
wrap?: boolean | undefined;
usages?: number[] | undefined;
usageMinimum?: number | undefined;
usageMaximum?: number | undefined;
reportSize?: number | undefined;
reportCount?: number | undefined;
unitExponent?: number | undefined;
unitSystem?: HIDUnitSystem | undefined;
unitFactorLengthExponent?: number | undefined;
unitFactorMassExponent?: number | undefined;
unitFactorTimeExponent?: number | undefined;
unitFactorTemperatureExponent?: number | undefined;
unitFactorCurrentExponent?: number | undefined;
unitFactorLuminousIntensityExponent?: number | undefined;
logicalMinimum?: number | undefined;
logicalMaximum?: number | undefined;
physicalMinimum?: number | undefined;
physicalMaximum?: number | undefined;
strings?: string[] | undefined;
}
interface HIDReportInfo {
reportId?: number | undefined;
items?: HIDReportItem[] | undefined;
}
interface HIDCollectionInfo {
usagePage?: number | undefined;
usage?: number | undefined;
type?: number | undefined;
children?: HIDCollectionInfo[] | undefined;
inputReports?: HIDReportInfo[] | undefined;
outputReports?: HIDReportInfo[] | undefined;
featureReports?: HIDReportInfo[] | undefined;
}
declare class HIDDevice extends EventTarget {
oninputreport: ((this: this, ev: HIDInputReportEvent) => any) | null;
readonly opened: boolean;
readonly vendorId: number;
readonly productId: number;
readonly productName: string;
readonly collections: HIDCollectionInfo[];
open(): Promise<void>;
close(): Promise<void>;
forget(): Promise<void>;
sendReport(reportId: number, data: BufferSource): Promise<void>;
sendFeatureReport(reportId: number, data: BufferSource): Promise<void>;
receiveFeatureReport(reportId: number): Promise<DataView>;
addEventListener(type: 'inputreport', listener: (this: this, ev: HIDInputReportEvent) => any): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject | null,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener(type: 'inputreport', callback: (this: this, ev: HIDInputReportEvent) => any): void;
removeEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean,
): void;
}