interaction-system 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +377 -0
- package/USAGE.md +490 -0
- package/dist/index.cjs.js +1983 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +1983 -0
- package/dist/index.es.js.map +1 -0
- package/dist/input/KeyEvent.d.ts +315 -0
- package/dist/input/KeyEvent.d.ts.map +1 -0
- package/dist/input/KeyInputHandler.d.ts +15 -0
- package/dist/input/KeyInputHandler.d.ts.map +1 -0
- package/dist/input/KeyToCodeMap.d.ts +2 -0
- package/dist/input/KeyToCodeMap.d.ts.map +1 -0
- package/dist/input/UIEventsCode.d.ts +175 -0
- package/dist/input/UIEventsCode.d.ts.map +1 -0
- package/dist/interaction/FeaturedInteractionHandler.d.ts +26 -0
- package/dist/interaction/FeaturedInteractionHandler.d.ts.map +1 -0
- package/dist/interaction/InteractionHandler.d.ts +86 -0
- package/dist/interaction/InteractionHandler.d.ts.map +1 -0
- package/dist/interaction/SimpleInteractionHandler.d.ts +19 -0
- package/dist/interaction/SimpleInteractionHandler.d.ts.map +1 -0
- package/dist/messages/CommandControlMessage.d.ts +49 -0
- package/dist/messages/CommandControlMessage.d.ts.map +1 -0
- package/dist/messages/ControlMessage.d.ts +25 -0
- package/dist/messages/ControlMessage.d.ts.map +1 -0
- package/dist/messages/KeyCodeControlMessage.d.ts +24 -0
- package/dist/messages/KeyCodeControlMessage.d.ts.map +1 -0
- package/dist/messages/ScrollControlMessage.d.ts +23 -0
- package/dist/messages/ScrollControlMessage.d.ts.map +1 -0
- package/dist/messages/TextControlMessage.d.ts +19 -0
- package/dist/messages/TextControlMessage.d.ts.map +1 -0
- package/dist/messages/TouchControlMessage.d.ts +44 -0
- package/dist/messages/TouchControlMessage.d.ts.map +1 -0
- package/dist/models/MotionEvent.d.ts +18 -0
- package/dist/models/MotionEvent.d.ts.map +1 -0
- package/dist/models/Point.d.ts +14 -0
- package/dist/models/Point.d.ts.map +1 -0
- package/dist/models/Position.d.ts +17 -0
- package/dist/models/Position.d.ts.map +1 -0
- package/dist/models/Rect.d.ts +22 -0
- package/dist/models/Rect.d.ts.map +1 -0
- package/dist/models/ScreenInfo.d.ts +14 -0
- package/dist/models/ScreenInfo.d.ts.map +1 -0
- package/dist/models/Size.d.ts +21 -0
- package/dist/models/Size.d.ts.map +1 -0
- package/dist/types/PlayerInterface.d.ts +20 -0
- package/dist/types/PlayerInterface.d.ts.map +1 -0
- package/dist/utils/Util.d.ts +26 -0
- package/dist/utils/Util.d.ts.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,1983 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const buffer = require("buffer");
|
|
4
|
+
const _MotionEvent = class _MotionEvent {
|
|
5
|
+
};
|
|
6
|
+
_MotionEvent.ACTION_DOWN = 0;
|
|
7
|
+
_MotionEvent.ACTION_UP = 1;
|
|
8
|
+
_MotionEvent.ACTION_MOVE = 2;
|
|
9
|
+
_MotionEvent.BUTTON_PRIMARY = 1 << 0;
|
|
10
|
+
_MotionEvent.BUTTON_SECONDARY = 1 << 1;
|
|
11
|
+
_MotionEvent.BUTTON_TERTIARY = 1 << 2;
|
|
12
|
+
let MotionEvent = _MotionEvent;
|
|
13
|
+
const _ControlMessage = class _ControlMessage {
|
|
14
|
+
constructor(type) {
|
|
15
|
+
this.type = type;
|
|
16
|
+
}
|
|
17
|
+
toBuffer() {
|
|
18
|
+
throw Error("Not implemented");
|
|
19
|
+
}
|
|
20
|
+
toString() {
|
|
21
|
+
return "ControlMessage";
|
|
22
|
+
}
|
|
23
|
+
toJSON() {
|
|
24
|
+
return {
|
|
25
|
+
type: this.type
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
_ControlMessage.TYPE_KEYCODE = 0;
|
|
30
|
+
_ControlMessage.TYPE_TEXT = 1;
|
|
31
|
+
_ControlMessage.TYPE_TOUCH = 2;
|
|
32
|
+
_ControlMessage.TYPE_SCROLL = 3;
|
|
33
|
+
_ControlMessage.TYPE_BACK_OR_SCREEN_ON = 4;
|
|
34
|
+
_ControlMessage.TYPE_EXPAND_NOTIFICATION_PANEL = 5;
|
|
35
|
+
_ControlMessage.TYPE_EXPAND_SETTINGS_PANEL = 6;
|
|
36
|
+
_ControlMessage.TYPE_COLLAPSE_PANELS = 7;
|
|
37
|
+
_ControlMessage.TYPE_GET_CLIPBOARD = 8;
|
|
38
|
+
_ControlMessage.TYPE_SET_CLIPBOARD = 9;
|
|
39
|
+
_ControlMessage.TYPE_SET_SCREEN_POWER_MODE = 10;
|
|
40
|
+
_ControlMessage.TYPE_ROTATE_DEVICE = 11;
|
|
41
|
+
_ControlMessage.TYPE_CHANGE_STREAM_PARAMETERS = 101;
|
|
42
|
+
_ControlMessage.TYPE_PUSH_FILE = 102;
|
|
43
|
+
let ControlMessage = _ControlMessage;
|
|
44
|
+
const _TouchControlMessage = class _TouchControlMessage extends ControlMessage {
|
|
45
|
+
constructor(action, pointerId, position, pressure, buttons) {
|
|
46
|
+
super(ControlMessage.TYPE_TOUCH);
|
|
47
|
+
this.action = action;
|
|
48
|
+
this.pointerId = pointerId;
|
|
49
|
+
this.position = position;
|
|
50
|
+
this.pressure = pressure;
|
|
51
|
+
this.buttons = buttons;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @override
|
|
55
|
+
*/
|
|
56
|
+
toBuffer() {
|
|
57
|
+
const buffer$1 = buffer.Buffer.alloc(_TouchControlMessage.PAYLOAD_LENGTH + 1);
|
|
58
|
+
let offset = 0;
|
|
59
|
+
offset = buffer$1.writeUInt8(this.type, offset);
|
|
60
|
+
offset = buffer$1.writeUInt8(this.action, offset);
|
|
61
|
+
offset = buffer$1.writeUInt32BE(0, offset);
|
|
62
|
+
offset = buffer$1.writeUInt32BE(this.pointerId, offset);
|
|
63
|
+
offset = buffer$1.writeUInt32BE(this.position.point.x, offset);
|
|
64
|
+
offset = buffer$1.writeUInt32BE(this.position.point.y, offset);
|
|
65
|
+
offset = buffer$1.writeUInt16BE(this.position.screenSize.width, offset);
|
|
66
|
+
offset = buffer$1.writeUInt16BE(this.position.screenSize.height, offset);
|
|
67
|
+
offset = buffer$1.writeUInt16BE(this.pressure * _TouchControlMessage.MAX_PRESSURE_VALUE, offset);
|
|
68
|
+
buffer$1.writeUInt32BE(this.buttons, offset);
|
|
69
|
+
return buffer$1;
|
|
70
|
+
}
|
|
71
|
+
toString() {
|
|
72
|
+
return `TouchControlMessage{action=${this.action}, pointerId=${this.pointerId}, position=${this.position}, pressure=${this.pressure}, buttons=${this.buttons}}`;
|
|
73
|
+
}
|
|
74
|
+
toJSON() {
|
|
75
|
+
return {
|
|
76
|
+
type: this.type,
|
|
77
|
+
action: this.action,
|
|
78
|
+
pointerId: this.pointerId,
|
|
79
|
+
position: this.position.toJSON(),
|
|
80
|
+
pressure: this.pressure,
|
|
81
|
+
buttons: this.buttons
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
_TouchControlMessage.PAYLOAD_LENGTH = 28;
|
|
86
|
+
_TouchControlMessage.MAX_PRESSURE_VALUE = 65535;
|
|
87
|
+
let TouchControlMessage = _TouchControlMessage;
|
|
88
|
+
class Size {
|
|
89
|
+
constructor(width, height) {
|
|
90
|
+
this.width = width;
|
|
91
|
+
this.height = height;
|
|
92
|
+
this.w = width;
|
|
93
|
+
this.h = height;
|
|
94
|
+
}
|
|
95
|
+
static equals(a, b) {
|
|
96
|
+
if (!a && !b) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return !!a && !!b && a.equals(b);
|
|
100
|
+
}
|
|
101
|
+
static copy(a) {
|
|
102
|
+
if (!a) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return new Size(a.width, a.height);
|
|
106
|
+
}
|
|
107
|
+
length() {
|
|
108
|
+
return this.w * this.h;
|
|
109
|
+
}
|
|
110
|
+
rotate() {
|
|
111
|
+
return new Size(this.height, this.width);
|
|
112
|
+
}
|
|
113
|
+
equals(o) {
|
|
114
|
+
if (this === o) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (!o) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return this.width === o.width && this.height === o.height;
|
|
121
|
+
}
|
|
122
|
+
intersect(o) {
|
|
123
|
+
if (!o) {
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
const minH = Math.min(this.height, o.height);
|
|
127
|
+
const minW = Math.min(this.width, o.width);
|
|
128
|
+
return new Size(minW, minH);
|
|
129
|
+
}
|
|
130
|
+
getHalfSize() {
|
|
131
|
+
return new Size(this.width >>> 1, this.height >>> 1);
|
|
132
|
+
}
|
|
133
|
+
toString() {
|
|
134
|
+
return `Size{width=${this.width}, height=${this.height}}`;
|
|
135
|
+
}
|
|
136
|
+
toJSON() {
|
|
137
|
+
return {
|
|
138
|
+
width: this.width,
|
|
139
|
+
height: this.height
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
class Point {
|
|
144
|
+
constructor(x, y) {
|
|
145
|
+
this.x = Math.round(x);
|
|
146
|
+
this.y = Math.round(y);
|
|
147
|
+
}
|
|
148
|
+
equals(o) {
|
|
149
|
+
if (this === o) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (o === null) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
return this.x === o.x && this.y === o.y;
|
|
156
|
+
}
|
|
157
|
+
distance(to) {
|
|
158
|
+
const x = this.x - to.x;
|
|
159
|
+
const y = this.y - to.y;
|
|
160
|
+
return Math.sqrt(x * x + y * y);
|
|
161
|
+
}
|
|
162
|
+
toString() {
|
|
163
|
+
return `Point{x=${this.x}, y=${this.y}}`;
|
|
164
|
+
}
|
|
165
|
+
toJSON() {
|
|
166
|
+
return {
|
|
167
|
+
x: this.x,
|
|
168
|
+
y: this.y
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
class Position {
|
|
173
|
+
constructor(point, screenSize) {
|
|
174
|
+
this.point = point;
|
|
175
|
+
this.screenSize = screenSize;
|
|
176
|
+
}
|
|
177
|
+
equals(o) {
|
|
178
|
+
if (this === o) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
if (o === null) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return this.point.equals(o.point) && this.screenSize.equals(o.screenSize);
|
|
185
|
+
}
|
|
186
|
+
rotate(rotation) {
|
|
187
|
+
switch (rotation) {
|
|
188
|
+
case 1:
|
|
189
|
+
return new Position(
|
|
190
|
+
new Point(this.screenSize.height - this.point.y, this.point.x),
|
|
191
|
+
this.screenSize.rotate()
|
|
192
|
+
);
|
|
193
|
+
case 2:
|
|
194
|
+
return new Position(
|
|
195
|
+
new Point(this.screenSize.width - this.point.x, this.screenSize.height - this.point.y),
|
|
196
|
+
this.screenSize
|
|
197
|
+
);
|
|
198
|
+
case 3:
|
|
199
|
+
return new Position(
|
|
200
|
+
new Point(this.point.y, this.screenSize.width - this.point.x),
|
|
201
|
+
this.screenSize.rotate()
|
|
202
|
+
);
|
|
203
|
+
default:
|
|
204
|
+
return this;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
toString() {
|
|
208
|
+
return `Position{point=${this.point}, screenSize=${this.screenSize}}`;
|
|
209
|
+
}
|
|
210
|
+
toJSON() {
|
|
211
|
+
return {
|
|
212
|
+
point: this.point.toJSON(),
|
|
213
|
+
screenSize: this.screenSize.toJSON()
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const _Util = class _Util {
|
|
218
|
+
/**
|
|
219
|
+
* 将 UTF-8 字节数组转换为 JavaScript 字符串
|
|
220
|
+
* @param bytes UTF-8 字节数组
|
|
221
|
+
* @returns 16位 Unicode 字符串
|
|
222
|
+
*/
|
|
223
|
+
static utf8ByteArrayToString(bytes) {
|
|
224
|
+
var out = [], pos = 0, c = 0;
|
|
225
|
+
while (pos < bytes.length) {
|
|
226
|
+
var c1 = bytes[pos++];
|
|
227
|
+
if (c1 < 128) {
|
|
228
|
+
out[c++] = String.fromCharCode(c1);
|
|
229
|
+
} else if (c1 > 191 && c1 < 224) {
|
|
230
|
+
var c2 = bytes[pos++];
|
|
231
|
+
out[c++] = String.fromCharCode((c1 & 31) << 6 | c2 & 63);
|
|
232
|
+
} else if (c1 > 239 && c1 < 365) {
|
|
233
|
+
var c2 = bytes[pos++];
|
|
234
|
+
var c3 = bytes[pos++];
|
|
235
|
+
var c4 = bytes[pos++];
|
|
236
|
+
var u = ((c1 & 7) << 18 | (c2 & 63) << 12 | (c3 & 63) << 6 | c4 & 63) - 65536;
|
|
237
|
+
out[c++] = String.fromCharCode(55296 + (u >> 10));
|
|
238
|
+
out[c++] = String.fromCharCode(56320 + (u & 1023));
|
|
239
|
+
} else {
|
|
240
|
+
var c2 = bytes[pos++];
|
|
241
|
+
var c3 = bytes[pos++];
|
|
242
|
+
out[c++] = String.fromCharCode((c1 & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return out.join("");
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* 检测浏览器是否支持 passive 事件监听器
|
|
249
|
+
* 参考: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
|
|
250
|
+
* @returns 是否支持 passive 选项
|
|
251
|
+
*/
|
|
252
|
+
static supportsPassive() {
|
|
253
|
+
if (typeof _Util.supportsPassiveValue === "boolean") {
|
|
254
|
+
return _Util.supportsPassiveValue;
|
|
255
|
+
}
|
|
256
|
+
let supportsPassive = false;
|
|
257
|
+
try {
|
|
258
|
+
const opts = Object.defineProperty({}, "passive", {
|
|
259
|
+
get: function() {
|
|
260
|
+
supportsPassive = true;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
window.addEventListener("testPassive", null, opts);
|
|
264
|
+
window.removeEventListener("testPassive", null, opts);
|
|
265
|
+
} catch (error) {
|
|
266
|
+
}
|
|
267
|
+
return _Util.supportsPassiveValue = supportsPassive;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
_Util.stringToUtf8ByteArray = function(str) {
|
|
271
|
+
var out = [], p = 0;
|
|
272
|
+
for (var i = 0; i < str.length; i++) {
|
|
273
|
+
var c = str.charCodeAt(i);
|
|
274
|
+
if (c < 128) {
|
|
275
|
+
out[p++] = c;
|
|
276
|
+
} else if (c < 2048) {
|
|
277
|
+
out[p++] = c >> 6 | 192;
|
|
278
|
+
out[p++] = c & 63 | 128;
|
|
279
|
+
} else if ((c & 64512) == 55296 && i + 1 < str.length && (str.charCodeAt(i + 1) & 64512) == 56320) {
|
|
280
|
+
c = 65536 + ((c & 1023) << 10) + (str.charCodeAt(++i) & 1023);
|
|
281
|
+
out[p++] = c >> 18 | 240;
|
|
282
|
+
out[p++] = c >> 12 & 63 | 128;
|
|
283
|
+
out[p++] = c >> 6 & 63 | 128;
|
|
284
|
+
out[p++] = c & 63 | 128;
|
|
285
|
+
} else {
|
|
286
|
+
out[p++] = c >> 12 | 224;
|
|
287
|
+
out[p++] = c >> 6 & 63 | 128;
|
|
288
|
+
out[p++] = c & 63 | 128;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return Uint8Array.from(out);
|
|
292
|
+
};
|
|
293
|
+
let Util = _Util;
|
|
294
|
+
const TouchPointPNG = "../assets/images/touch_point.png";
|
|
295
|
+
const CenterPointPNG = "../assets/images/center_point.png";
|
|
296
|
+
const TAG$2 = "[TouchHandler]";
|
|
297
|
+
const _InteractionHandler = class _InteractionHandler {
|
|
298
|
+
constructor(player, touchEventsNames, keyEventsNames) {
|
|
299
|
+
this.player = player;
|
|
300
|
+
this.touchEventsNames = touchEventsNames;
|
|
301
|
+
this.keyEventsNames = keyEventsNames;
|
|
302
|
+
this.multiTouchActive = false;
|
|
303
|
+
this.multiTouchShift = false;
|
|
304
|
+
this.dirtyPlace = [];
|
|
305
|
+
this.over = false;
|
|
306
|
+
this.tag = player.getTouchableElement();
|
|
307
|
+
this.ctx = this.tag.getContext("2d");
|
|
308
|
+
_InteractionHandler.loadImages();
|
|
309
|
+
_InteractionHandler.bindGlobalListeners(this);
|
|
310
|
+
}
|
|
311
|
+
static bindGlobalListeners(interactionHandler) {
|
|
312
|
+
interactionHandler.touchEventsNames.forEach((eventName) => {
|
|
313
|
+
let set = _InteractionHandler.eventListeners.get(eventName);
|
|
314
|
+
if (!set) {
|
|
315
|
+
set = /* @__PURE__ */ new Set();
|
|
316
|
+
document.body.addEventListener(eventName, this.onInteractionEvent, _InteractionHandler.options);
|
|
317
|
+
this.eventListeners.set(eventName, set);
|
|
318
|
+
}
|
|
319
|
+
set.add(interactionHandler);
|
|
320
|
+
});
|
|
321
|
+
interactionHandler.keyEventsNames.forEach((eventName) => {
|
|
322
|
+
let set = _InteractionHandler.eventListeners.get(eventName);
|
|
323
|
+
if (!set) {
|
|
324
|
+
set = /* @__PURE__ */ new Set();
|
|
325
|
+
document.body.addEventListener(eventName, this.onKeyEvent);
|
|
326
|
+
this.eventListeners.set(eventName, set);
|
|
327
|
+
}
|
|
328
|
+
set.add(interactionHandler);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
static unbindListeners(touchHandler) {
|
|
332
|
+
touchHandler.touchEventsNames.forEach((eventName) => {
|
|
333
|
+
const set = _InteractionHandler.eventListeners.get(eventName);
|
|
334
|
+
if (!set) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
set.delete(touchHandler);
|
|
338
|
+
if (set.size <= 0) {
|
|
339
|
+
this.eventListeners.delete(eventName);
|
|
340
|
+
document.body.removeEventListener(eventName, this.onInteractionEvent);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
touchHandler.keyEventsNames.forEach((eventName) => {
|
|
344
|
+
const set = _InteractionHandler.eventListeners.get(eventName);
|
|
345
|
+
if (!set) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
set.delete(touchHandler);
|
|
349
|
+
if (set.size <= 0) {
|
|
350
|
+
this.eventListeners.delete(eventName);
|
|
351
|
+
document.body.removeEventListener(eventName, this.onKeyEvent);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
static loadImages() {
|
|
356
|
+
if (this.pointImagesLoaded) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const total = 2;
|
|
360
|
+
let current = 0;
|
|
361
|
+
const onload = (event) => {
|
|
362
|
+
if (++current === total) {
|
|
363
|
+
this.pointImagesLoaded = true;
|
|
364
|
+
}
|
|
365
|
+
if (event.target === this.touchPointImage) {
|
|
366
|
+
this.touchPointRadius = this.touchPointImage.width / 2;
|
|
367
|
+
} else if (event.target === this.centerPointImage) {
|
|
368
|
+
this.centerPointRadius = this.centerPointImage.width / 2;
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const touch = this.touchPointImage = new Image();
|
|
372
|
+
touch.src = TouchPointPNG;
|
|
373
|
+
touch.onload = onload;
|
|
374
|
+
const center = this.centerPointImage = new Image();
|
|
375
|
+
center.src = CenterPointPNG;
|
|
376
|
+
center.onload = onload;
|
|
377
|
+
}
|
|
378
|
+
static getPointerId(type, identifier) {
|
|
379
|
+
if (this.idToPointerMap.has(identifier)) {
|
|
380
|
+
const pointerId2 = this.idToPointerMap.get(identifier);
|
|
381
|
+
if (type === "touchend" || type === "touchcancel") {
|
|
382
|
+
this.idToPointerMap.delete(identifier);
|
|
383
|
+
this.pointerToIdMap.delete(pointerId2);
|
|
384
|
+
}
|
|
385
|
+
return pointerId2;
|
|
386
|
+
}
|
|
387
|
+
let pointerId = 0;
|
|
388
|
+
while (this.pointerToIdMap.has(pointerId)) {
|
|
389
|
+
pointerId++;
|
|
390
|
+
}
|
|
391
|
+
this.idToPointerMap.set(identifier, pointerId);
|
|
392
|
+
this.pointerToIdMap.set(pointerId, identifier);
|
|
393
|
+
return pointerId;
|
|
394
|
+
}
|
|
395
|
+
static buildTouchOnClient(event, screenInfo) {
|
|
396
|
+
const action = this.mapTypeToAction(event.type);
|
|
397
|
+
const { width, height } = screenInfo.videoSize;
|
|
398
|
+
const target = event.target;
|
|
399
|
+
const rect = target.getBoundingClientRect();
|
|
400
|
+
let { clientWidth, clientHeight } = target;
|
|
401
|
+
let touchX = event.clientX - rect.left;
|
|
402
|
+
let touchY = event.clientY - rect.top;
|
|
403
|
+
let invalid = false;
|
|
404
|
+
if (touchX < 0 || touchX > clientWidth || touchY < 0 || touchY > clientHeight) {
|
|
405
|
+
invalid = true;
|
|
406
|
+
}
|
|
407
|
+
const eps = 1e5;
|
|
408
|
+
const ratio = width / height;
|
|
409
|
+
const shouldBe = Math.round(eps * ratio);
|
|
410
|
+
const haveNow = Math.round(eps * clientWidth / clientHeight);
|
|
411
|
+
if (shouldBe > haveNow) {
|
|
412
|
+
const realHeight = Math.ceil(clientWidth / ratio);
|
|
413
|
+
const top = (clientHeight - realHeight) / 2;
|
|
414
|
+
if (touchY < top || touchY > top + realHeight) {
|
|
415
|
+
invalid = true;
|
|
416
|
+
}
|
|
417
|
+
touchY -= top;
|
|
418
|
+
clientHeight = realHeight;
|
|
419
|
+
} else if (shouldBe < haveNow) {
|
|
420
|
+
const realWidth = Math.ceil(clientHeight * ratio);
|
|
421
|
+
const left = (clientWidth - realWidth) / 2;
|
|
422
|
+
if (touchX < left || touchX > left + realWidth) {
|
|
423
|
+
invalid = true;
|
|
424
|
+
}
|
|
425
|
+
touchX -= left;
|
|
426
|
+
clientWidth = realWidth;
|
|
427
|
+
}
|
|
428
|
+
const x = touchX * width / clientWidth;
|
|
429
|
+
const y = touchY * height / clientHeight;
|
|
430
|
+
const size = new Size(width, height);
|
|
431
|
+
const point = new Point(x, y);
|
|
432
|
+
const position = new Position(point, size);
|
|
433
|
+
if (x < 0 || y < 0 || x > width || y > height) {
|
|
434
|
+
invalid = true;
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
client: {
|
|
438
|
+
width: clientWidth,
|
|
439
|
+
height: clientHeight
|
|
440
|
+
},
|
|
441
|
+
touch: {
|
|
442
|
+
invalid,
|
|
443
|
+
action,
|
|
444
|
+
position,
|
|
445
|
+
buttons: event.buttons
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
static validateMessage(originalEvent, message, storage, logPrefix) {
|
|
450
|
+
const messages = [];
|
|
451
|
+
const { action, pointerId } = message;
|
|
452
|
+
const previous = storage.get(pointerId);
|
|
453
|
+
if (action === MotionEvent.ACTION_UP) {
|
|
454
|
+
if (!previous) {
|
|
455
|
+
console.warn(logPrefix, "Received ACTION_UP while there are no DOWN stored");
|
|
456
|
+
} else {
|
|
457
|
+
storage.delete(pointerId);
|
|
458
|
+
messages.push(message);
|
|
459
|
+
}
|
|
460
|
+
} else if (action === MotionEvent.ACTION_DOWN) {
|
|
461
|
+
if (previous) {
|
|
462
|
+
console.warn(logPrefix, "Received ACTION_DOWN while already has one stored");
|
|
463
|
+
} else {
|
|
464
|
+
storage.set(pointerId, message);
|
|
465
|
+
messages.push(message);
|
|
466
|
+
}
|
|
467
|
+
} else if (action === MotionEvent.ACTION_MOVE) {
|
|
468
|
+
if (!previous) {
|
|
469
|
+
if (originalEvent instanceof MouseEvent && originalEvent.buttons || window["TouchEvent"] && originalEvent instanceof TouchEvent) {
|
|
470
|
+
console.warn(logPrefix, "Received ACTION_MOVE while there are no DOWN stored");
|
|
471
|
+
const emulated = _InteractionHandler.createEmulatedMessage(MotionEvent.ACTION_DOWN, message);
|
|
472
|
+
messages.push(emulated);
|
|
473
|
+
storage.set(pointerId, emulated);
|
|
474
|
+
}
|
|
475
|
+
} else {
|
|
476
|
+
messages.push(message);
|
|
477
|
+
storage.set(pointerId, message);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return messages;
|
|
481
|
+
}
|
|
482
|
+
static createEmulatedMessage(action, event) {
|
|
483
|
+
const { pointerId, position, buttons } = event;
|
|
484
|
+
let pressure = event.pressure;
|
|
485
|
+
if (action === MotionEvent.ACTION_UP) {
|
|
486
|
+
pressure = 0;
|
|
487
|
+
}
|
|
488
|
+
return new TouchControlMessage(action, pointerId, position, pressure, buttons);
|
|
489
|
+
}
|
|
490
|
+
static mapTypeToAction(type) {
|
|
491
|
+
return this.EVENT_ACTION_MAP[type];
|
|
492
|
+
}
|
|
493
|
+
getTouch(e, screenInfo, ctrlKey, shiftKey) {
|
|
494
|
+
const touchOnClient = _InteractionHandler.buildTouchOnClient(e, screenInfo);
|
|
495
|
+
if (!touchOnClient) {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
const { client, touch } = touchOnClient;
|
|
499
|
+
const result = [touch];
|
|
500
|
+
if (!ctrlKey) {
|
|
501
|
+
this.multiTouchActive = false;
|
|
502
|
+
this.multiTouchCenter = void 0;
|
|
503
|
+
this.multiTouchShift = false;
|
|
504
|
+
this.clearCanvas();
|
|
505
|
+
return result;
|
|
506
|
+
}
|
|
507
|
+
const { position, action, buttons } = touch;
|
|
508
|
+
const { point, screenSize } = position;
|
|
509
|
+
const { width, height } = screenSize;
|
|
510
|
+
const { x, y } = point;
|
|
511
|
+
if (!this.multiTouchActive) {
|
|
512
|
+
if (shiftKey) {
|
|
513
|
+
this.multiTouchCenter = point;
|
|
514
|
+
this.multiTouchShift = true;
|
|
515
|
+
} else {
|
|
516
|
+
this.multiTouchCenter = new Point(client.width / 2, client.height / 2);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
this.multiTouchActive = true;
|
|
520
|
+
let opposite;
|
|
521
|
+
let invalid = false;
|
|
522
|
+
if (this.multiTouchShift && this.multiTouchCenter) {
|
|
523
|
+
const oppoX = 2 * this.multiTouchCenter.x - x;
|
|
524
|
+
const oppoY = 2 * this.multiTouchCenter.y - y;
|
|
525
|
+
opposite = new Point(oppoX, oppoY);
|
|
526
|
+
if (!(oppoX <= width && oppoX >= 0 && oppoY <= height && oppoY >= 0)) {
|
|
527
|
+
invalid = true;
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
opposite = new Point(client.width - x, client.height - y);
|
|
531
|
+
invalid = touch.invalid;
|
|
532
|
+
}
|
|
533
|
+
if (opposite) {
|
|
534
|
+
result.push({
|
|
535
|
+
invalid,
|
|
536
|
+
action,
|
|
537
|
+
buttons,
|
|
538
|
+
position: new Position(opposite, screenSize)
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return result;
|
|
542
|
+
}
|
|
543
|
+
drawCircle(ctx, point, radius) {
|
|
544
|
+
ctx.beginPath();
|
|
545
|
+
ctx.arc(point.x, point.y, radius, 0, Math.PI * 2, true);
|
|
546
|
+
ctx.stroke();
|
|
547
|
+
}
|
|
548
|
+
drawLine(point1, point2) {
|
|
549
|
+
if (!this.ctx) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.ctx.save();
|
|
553
|
+
this.ctx.strokeStyle = _InteractionHandler.STROKE_STYLE;
|
|
554
|
+
this.ctx.beginPath();
|
|
555
|
+
this.ctx.moveTo(point1.x, point1.y);
|
|
556
|
+
this.ctx.lineTo(point2.x, point2.y);
|
|
557
|
+
this.ctx.stroke();
|
|
558
|
+
this.ctx.restore();
|
|
559
|
+
}
|
|
560
|
+
drawPoint(point, radius, image) {
|
|
561
|
+
if (!this.ctx) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
let { lineWidth } = this.ctx;
|
|
565
|
+
if (_InteractionHandler.pointImagesLoaded && image) {
|
|
566
|
+
radius = image.width / 2;
|
|
567
|
+
lineWidth = 0;
|
|
568
|
+
this.ctx.drawImage(image, point.x - radius, point.y - radius);
|
|
569
|
+
} else {
|
|
570
|
+
this.drawCircle(this.ctx, point, radius);
|
|
571
|
+
}
|
|
572
|
+
const topLeft = new Point(point.x - radius - lineWidth, point.y - radius - lineWidth);
|
|
573
|
+
const bottomRight = new Point(point.x + radius + lineWidth, point.y + radius + lineWidth);
|
|
574
|
+
this.updateDirty(topLeft, bottomRight);
|
|
575
|
+
}
|
|
576
|
+
drawPointer(point) {
|
|
577
|
+
this.drawPoint(point, _InteractionHandler.touchPointRadius, _InteractionHandler.touchPointImage);
|
|
578
|
+
if (this.multiTouchCenter) {
|
|
579
|
+
this.drawLine(this.multiTouchCenter, point);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
drawCenter(point) {
|
|
583
|
+
this.drawPoint(point, _InteractionHandler.centerPointRadius, _InteractionHandler.centerPointImage);
|
|
584
|
+
}
|
|
585
|
+
updateDirty(topLeft, bottomRight) {
|
|
586
|
+
if (!this.dirtyPlace.length) {
|
|
587
|
+
this.dirtyPlace.push(topLeft, bottomRight);
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const currentTopLeft = this.dirtyPlace[0];
|
|
591
|
+
const currentBottomRight = this.dirtyPlace[1];
|
|
592
|
+
const newTopLeft = new Point(Math.min(currentTopLeft.x, topLeft.x), Math.min(currentTopLeft.y, topLeft.y));
|
|
593
|
+
const newBottomRight = new Point(
|
|
594
|
+
Math.max(currentBottomRight.x, bottomRight.x),
|
|
595
|
+
Math.max(currentBottomRight.y, bottomRight.y)
|
|
596
|
+
);
|
|
597
|
+
this.dirtyPlace.length = 0;
|
|
598
|
+
this.dirtyPlace.push(newTopLeft, newBottomRight);
|
|
599
|
+
}
|
|
600
|
+
clearCanvas() {
|
|
601
|
+
const { clientWidth, clientHeight } = this.tag;
|
|
602
|
+
const ctx = this.ctx;
|
|
603
|
+
if (ctx && this.dirtyPlace.length) {
|
|
604
|
+
const topLeft = this.dirtyPlace[0];
|
|
605
|
+
const bottomRight = this.dirtyPlace[1];
|
|
606
|
+
this.dirtyPlace.length = 0;
|
|
607
|
+
const x = Math.max(topLeft.x, 0);
|
|
608
|
+
const y = Math.max(topLeft.y, 0);
|
|
609
|
+
const w = Math.min(clientWidth, bottomRight.x - x);
|
|
610
|
+
const h = Math.min(clientHeight, bottomRight.y - y);
|
|
611
|
+
ctx.clearRect(x, y, w, h);
|
|
612
|
+
ctx.strokeStyle = _InteractionHandler.STROKE_STYLE;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
formatTouchEvent(e, screenInfo, storage) {
|
|
616
|
+
const logPrefix = `${TAG$2}[formatTouchEvent]`;
|
|
617
|
+
const messages = [];
|
|
618
|
+
const touches = e.changedTouches;
|
|
619
|
+
if (touches && touches.length) {
|
|
620
|
+
for (let i = 0, l = touches.length; i < l; i++) {
|
|
621
|
+
const touch = touches[i];
|
|
622
|
+
const pointerId = _InteractionHandler.getPointerId(e.type, touch.identifier);
|
|
623
|
+
if (touch.target !== this.tag) {
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
const previous = storage.get(pointerId);
|
|
627
|
+
const item = {
|
|
628
|
+
clientX: touch.clientX,
|
|
629
|
+
clientY: touch.clientY,
|
|
630
|
+
type: e.type,
|
|
631
|
+
buttons: MotionEvent.BUTTON_PRIMARY,
|
|
632
|
+
target: e.target
|
|
633
|
+
};
|
|
634
|
+
const event = _InteractionHandler.buildTouchOnClient(item, screenInfo);
|
|
635
|
+
if (event) {
|
|
636
|
+
const { action, buttons, position, invalid } = event.touch;
|
|
637
|
+
let pressure = 1;
|
|
638
|
+
if (action === MotionEvent.ACTION_UP) {
|
|
639
|
+
pressure = 0;
|
|
640
|
+
} else if (typeof touch.force === "number") {
|
|
641
|
+
pressure = touch.force;
|
|
642
|
+
}
|
|
643
|
+
if (!invalid) {
|
|
644
|
+
const message = new TouchControlMessage(action, pointerId, position, pressure, buttons);
|
|
645
|
+
messages.push(
|
|
646
|
+
..._InteractionHandler.validateMessage(e, message, storage, `${logPrefix}[validate]`)
|
|
647
|
+
);
|
|
648
|
+
} else {
|
|
649
|
+
if (previous) {
|
|
650
|
+
messages.push(_InteractionHandler.createEmulatedMessage(MotionEvent.ACTION_UP, previous));
|
|
651
|
+
storage.delete(pointerId);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
} else {
|
|
655
|
+
console.error(logPrefix, `Failed to format touch`, touch);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
} else {
|
|
659
|
+
console.error(logPrefix, 'No "touches"', e);
|
|
660
|
+
}
|
|
661
|
+
return messages;
|
|
662
|
+
}
|
|
663
|
+
buildTouchEvent(e, screenInfo, storage) {
|
|
664
|
+
const logPrefix = `${TAG$2}[buildTouchEvent]`;
|
|
665
|
+
const touches = this.getTouch(e, screenInfo, e.ctrlKey, e.shiftKey);
|
|
666
|
+
if (!touches) {
|
|
667
|
+
return [];
|
|
668
|
+
}
|
|
669
|
+
const messages = [];
|
|
670
|
+
const points = [];
|
|
671
|
+
this.clearCanvas();
|
|
672
|
+
touches.forEach((touch, pointerId) => {
|
|
673
|
+
const { action, buttons, position } = touch;
|
|
674
|
+
const previous = storage.get(pointerId);
|
|
675
|
+
if (!touch.invalid) {
|
|
676
|
+
let pressure = 1;
|
|
677
|
+
if (action === MotionEvent.ACTION_UP) {
|
|
678
|
+
pressure = 0;
|
|
679
|
+
}
|
|
680
|
+
const message = new TouchControlMessage(action, pointerId, position, pressure, buttons);
|
|
681
|
+
messages.push(..._InteractionHandler.validateMessage(e, message, storage, `${logPrefix}[validate]`));
|
|
682
|
+
points.push(touch.position.point);
|
|
683
|
+
} else {
|
|
684
|
+
if (previous) {
|
|
685
|
+
points.push(previous.position.point);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
if (this.multiTouchActive) {
|
|
690
|
+
if (this.multiTouchCenter) {
|
|
691
|
+
this.drawCenter(this.multiTouchCenter);
|
|
692
|
+
}
|
|
693
|
+
points.forEach((point) => {
|
|
694
|
+
this.drawPointer(point);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
const hasActionUp = messages.find((message) => {
|
|
698
|
+
return message.action === MotionEvent.ACTION_UP;
|
|
699
|
+
});
|
|
700
|
+
if (hasActionUp && storage.size) {
|
|
701
|
+
console.warn(logPrefix, "Looks like one of Multi-touch pointers was not raised up");
|
|
702
|
+
storage.forEach((message) => {
|
|
703
|
+
messages.push(_InteractionHandler.createEmulatedMessage(MotionEvent.ACTION_UP, message));
|
|
704
|
+
});
|
|
705
|
+
storage.clear();
|
|
706
|
+
}
|
|
707
|
+
return messages;
|
|
708
|
+
}
|
|
709
|
+
release() {
|
|
710
|
+
_InteractionHandler.unbindListeners(this);
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
_InteractionHandler.SIMULATE_MULTI_TOUCH = "SIMULATE_MULTI_TOUCH";
|
|
714
|
+
_InteractionHandler.STROKE_STYLE = "#00BEA4";
|
|
715
|
+
_InteractionHandler.EVENT_ACTION_MAP = {
|
|
716
|
+
touchstart: MotionEvent.ACTION_DOWN,
|
|
717
|
+
touchend: MotionEvent.ACTION_UP,
|
|
718
|
+
touchmove: MotionEvent.ACTION_MOVE,
|
|
719
|
+
touchcancel: MotionEvent.ACTION_UP,
|
|
720
|
+
mousedown: MotionEvent.ACTION_DOWN,
|
|
721
|
+
mousemove: MotionEvent.ACTION_MOVE,
|
|
722
|
+
mouseup: MotionEvent.ACTION_UP,
|
|
723
|
+
[_InteractionHandler.SIMULATE_MULTI_TOUCH]: -1
|
|
724
|
+
};
|
|
725
|
+
_InteractionHandler.options = Util.supportsPassive() ? { passive: false } : false;
|
|
726
|
+
_InteractionHandler.idToPointerMap = /* @__PURE__ */ new Map();
|
|
727
|
+
_InteractionHandler.pointerToIdMap = /* @__PURE__ */ new Map();
|
|
728
|
+
_InteractionHandler.touchPointRadius = 10;
|
|
729
|
+
_InteractionHandler.centerPointRadius = 5;
|
|
730
|
+
_InteractionHandler.pointImagesLoaded = false;
|
|
731
|
+
_InteractionHandler.eventListeners = /* @__PURE__ */ new Map();
|
|
732
|
+
_InteractionHandler.onInteractionEvent = (event) => {
|
|
733
|
+
const set = _InteractionHandler.eventListeners.get(event.type);
|
|
734
|
+
if (!set) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
set.forEach((instance) => {
|
|
738
|
+
instance.onInteraction(event);
|
|
739
|
+
});
|
|
740
|
+
};
|
|
741
|
+
_InteractionHandler.onKeyEvent = (event) => {
|
|
742
|
+
const set = _InteractionHandler.eventListeners.get(event.type);
|
|
743
|
+
if (!set) {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
set.forEach((instance) => {
|
|
747
|
+
instance.onKey(event);
|
|
748
|
+
});
|
|
749
|
+
};
|
|
750
|
+
let InteractionHandler = _InteractionHandler;
|
|
751
|
+
const _ScrollControlMessage = class _ScrollControlMessage extends ControlMessage {
|
|
752
|
+
constructor(position, hScroll, vScroll) {
|
|
753
|
+
super(ControlMessage.TYPE_SCROLL);
|
|
754
|
+
this.position = position;
|
|
755
|
+
this.hScroll = hScroll;
|
|
756
|
+
this.vScroll = vScroll;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* @override
|
|
760
|
+
*/
|
|
761
|
+
toBuffer() {
|
|
762
|
+
const buffer$1 = buffer.Buffer.alloc(_ScrollControlMessage.PAYLOAD_LENGTH + 1);
|
|
763
|
+
let offset = 0;
|
|
764
|
+
offset = buffer$1.writeUInt8(this.type, offset);
|
|
765
|
+
offset = buffer$1.writeUInt32BE(this.position.point.x, offset);
|
|
766
|
+
offset = buffer$1.writeUInt32BE(this.position.point.y, offset);
|
|
767
|
+
offset = buffer$1.writeUInt16BE(this.position.screenSize.width, offset);
|
|
768
|
+
offset = buffer$1.writeUInt16BE(this.position.screenSize.height, offset);
|
|
769
|
+
offset = buffer$1.writeInt32BE(this.hScroll, offset);
|
|
770
|
+
buffer$1.writeInt32BE(this.vScroll, offset);
|
|
771
|
+
return buffer$1;
|
|
772
|
+
}
|
|
773
|
+
toString() {
|
|
774
|
+
return `ScrollControlMessage{hScroll=${this.hScroll}, vScroll=${this.vScroll}, position=${this.position}}`;
|
|
775
|
+
}
|
|
776
|
+
toJSON() {
|
|
777
|
+
return {
|
|
778
|
+
type: this.type,
|
|
779
|
+
position: this.position.toJSON(),
|
|
780
|
+
hScroll: this.hScroll,
|
|
781
|
+
vScroll: this.vScroll
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
_ScrollControlMessage.PAYLOAD_LENGTH = 20;
|
|
786
|
+
let ScrollControlMessage = _ScrollControlMessage;
|
|
787
|
+
const TAG$1 = "[FeaturedTouchHandler]";
|
|
788
|
+
const _FeaturedInteractionHandler = class _FeaturedInteractionHandler extends InteractionHandler {
|
|
789
|
+
constructor(player, listener) {
|
|
790
|
+
super(player, _FeaturedInteractionHandler.touchEventsNames, _FeaturedInteractionHandler.keyEventsNames);
|
|
791
|
+
this.listener = listener;
|
|
792
|
+
this.storedFromMouseEvent = /* @__PURE__ */ new Map();
|
|
793
|
+
this.storedFromTouchEvent = /* @__PURE__ */ new Map();
|
|
794
|
+
this.onMouseEnter = () => {
|
|
795
|
+
this.over = true;
|
|
796
|
+
};
|
|
797
|
+
this.onMouseLeave = () => {
|
|
798
|
+
this.lastPosition = void 0;
|
|
799
|
+
this.over = false;
|
|
800
|
+
this.storedFromMouseEvent.forEach((message) => {
|
|
801
|
+
this.listener.sendMessage(InteractionHandler.createEmulatedMessage(MotionEvent.ACTION_UP, message));
|
|
802
|
+
});
|
|
803
|
+
this.storedFromMouseEvent.clear();
|
|
804
|
+
this.clearCanvas();
|
|
805
|
+
};
|
|
806
|
+
this.tag.addEventListener("mouseleave", this.onMouseLeave);
|
|
807
|
+
this.tag.addEventListener("mouseenter", this.onMouseEnter);
|
|
808
|
+
}
|
|
809
|
+
buildScrollEvent(event, screenInfo) {
|
|
810
|
+
const messages = [];
|
|
811
|
+
const touchOnClient = InteractionHandler.buildTouchOnClient(event, screenInfo);
|
|
812
|
+
if (touchOnClient) {
|
|
813
|
+
const hScroll = event.deltaX > 0 ? -1 : event.deltaX < -0 ? 1 : 0;
|
|
814
|
+
const vScroll = event.deltaY > 0 ? -1 : event.deltaY < -0 ? 1 : 0;
|
|
815
|
+
const time = Date.now();
|
|
816
|
+
if (!this.lastScrollEvent || time - this.lastScrollEvent.time > _FeaturedInteractionHandler.SCROLL_EVENT_THROTTLING_TIME || this.lastScrollEvent.vScroll !== vScroll || this.lastScrollEvent.hScroll !== hScroll) {
|
|
817
|
+
this.lastScrollEvent = { time, hScroll, vScroll };
|
|
818
|
+
messages.push(new ScrollControlMessage(touchOnClient.touch.position, hScroll, vScroll));
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return messages;
|
|
822
|
+
}
|
|
823
|
+
onInteraction(event) {
|
|
824
|
+
const screenInfo = this.player.getScreenInfo();
|
|
825
|
+
if (!screenInfo) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
let messages;
|
|
829
|
+
let storage;
|
|
830
|
+
if (event instanceof MouseEvent) {
|
|
831
|
+
if (event.target !== this.tag) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
if (window["WheelEvent"] && event instanceof WheelEvent) {
|
|
835
|
+
messages = this.buildScrollEvent(event, screenInfo);
|
|
836
|
+
} else {
|
|
837
|
+
storage = this.storedFromMouseEvent;
|
|
838
|
+
messages = this.buildTouchEvent(event, screenInfo, storage);
|
|
839
|
+
}
|
|
840
|
+
if (this.over) {
|
|
841
|
+
this.lastPosition = event;
|
|
842
|
+
}
|
|
843
|
+
} else if (window["TouchEvent"] && event instanceof TouchEvent) {
|
|
844
|
+
if (event.target !== this.tag) {
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
storage = this.storedFromTouchEvent;
|
|
848
|
+
messages = this.formatTouchEvent(event, screenInfo, storage);
|
|
849
|
+
} else {
|
|
850
|
+
console.error(TAG$1, "Unsupported event", event);
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
if (event.cancelable) {
|
|
854
|
+
event.preventDefault();
|
|
855
|
+
}
|
|
856
|
+
event.stopPropagation();
|
|
857
|
+
messages.forEach((message) => {
|
|
858
|
+
this.listener.sendMessage(message);
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
onKey(event) {
|
|
862
|
+
if (!this.lastPosition) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
const screenInfo = this.player.getScreenInfo();
|
|
866
|
+
if (!screenInfo) {
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
const { ctrlKey, shiftKey } = event;
|
|
870
|
+
const { target, button, buttons, clientY, clientX } = this.lastPosition;
|
|
871
|
+
const type = InteractionHandler.SIMULATE_MULTI_TOUCH;
|
|
872
|
+
const props = { ctrlKey, shiftKey, type, target, button, buttons, clientX, clientY };
|
|
873
|
+
this.buildTouchEvent(props, screenInfo, /* @__PURE__ */ new Map());
|
|
874
|
+
}
|
|
875
|
+
release() {
|
|
876
|
+
super.release();
|
|
877
|
+
this.tag.removeEventListener("mouseleave", this.onMouseLeave);
|
|
878
|
+
this.tag.removeEventListener("mouseenter", this.onMouseEnter);
|
|
879
|
+
this.storedFromMouseEvent.clear();
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
_FeaturedInteractionHandler.touchEventsNames = [
|
|
883
|
+
"touchstart",
|
|
884
|
+
"touchend",
|
|
885
|
+
"touchmove",
|
|
886
|
+
"touchcancel",
|
|
887
|
+
"mousedown",
|
|
888
|
+
"mouseup",
|
|
889
|
+
"mousemove",
|
|
890
|
+
"wheel"
|
|
891
|
+
];
|
|
892
|
+
_FeaturedInteractionHandler.keyEventsNames = ["keydown", "keyup"];
|
|
893
|
+
_FeaturedInteractionHandler.SCROLL_EVENT_THROTTLING_TIME = 30;
|
|
894
|
+
let FeaturedInteractionHandler = _FeaturedInteractionHandler;
|
|
895
|
+
const TAG = "[SimpleTouchHandler]";
|
|
896
|
+
const _SimpleInteractionHandler = class _SimpleInteractionHandler extends InteractionHandler {
|
|
897
|
+
constructor(player, listener) {
|
|
898
|
+
super(player, _SimpleInteractionHandler.touchEventsNames, []);
|
|
899
|
+
this.listener = listener;
|
|
900
|
+
this.storage = /* @__PURE__ */ new Map();
|
|
901
|
+
}
|
|
902
|
+
onInteraction(event) {
|
|
903
|
+
let handled = false;
|
|
904
|
+
if (!(event instanceof MouseEvent)) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
if (event.target === this.tag) {
|
|
908
|
+
const screenInfo = this.player.getScreenInfo();
|
|
909
|
+
if (!screenInfo) {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
const events = this.buildTouchEvent(event, screenInfo, this.storage);
|
|
913
|
+
if (events.length > 1) {
|
|
914
|
+
console.warn(TAG, "Too many events", events);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
const downEventName = "mousedown";
|
|
918
|
+
if (events.length === 1) {
|
|
919
|
+
handled = true;
|
|
920
|
+
if (event.type === downEventName) {
|
|
921
|
+
this.startPosition = events[0].position;
|
|
922
|
+
} else {
|
|
923
|
+
if (this.startPosition) {
|
|
924
|
+
this.endPosition = events[0].position;
|
|
925
|
+
} else {
|
|
926
|
+
console.warn(TAG, `Received "${event.type}" before "${downEventName}"`);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
if (this.startPosition) {
|
|
930
|
+
this.drawPointer(this.startPosition.point);
|
|
931
|
+
}
|
|
932
|
+
if (this.endPosition) {
|
|
933
|
+
this.drawPointer(this.endPosition.point);
|
|
934
|
+
if (this.startPosition) {
|
|
935
|
+
this.drawLine(this.startPosition.point, this.endPosition.point);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
if (event.type === "mouseup") {
|
|
939
|
+
if (this.startPosition && this.endPosition) {
|
|
940
|
+
this.clearCanvas();
|
|
941
|
+
if (this.startPosition.point.distance(this.endPosition.point) < 10) {
|
|
942
|
+
this.listener.performClick(this.endPosition);
|
|
943
|
+
} else {
|
|
944
|
+
this.listener.performScroll(this.startPosition, this.endPosition);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
if (handled) {
|
|
950
|
+
if (event.cancelable) {
|
|
951
|
+
event.preventDefault();
|
|
952
|
+
}
|
|
953
|
+
event.stopPropagation();
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
if (event.type === "mouseup") {
|
|
957
|
+
this.startPosition = void 0;
|
|
958
|
+
this.endPosition = void 0;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
onKey() {
|
|
962
|
+
throw Error(`${TAG} Unsupported`);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
_SimpleInteractionHandler.touchEventsNames = ["mousedown", "mouseup", "mousemove"];
|
|
966
|
+
let SimpleInteractionHandler = _SimpleInteractionHandler;
|
|
967
|
+
const _KeyCodeControlMessage = class _KeyCodeControlMessage extends ControlMessage {
|
|
968
|
+
constructor(action, keycode, repeat, metaState) {
|
|
969
|
+
super(ControlMessage.TYPE_KEYCODE);
|
|
970
|
+
this.action = action;
|
|
971
|
+
this.keycode = keycode;
|
|
972
|
+
this.repeat = repeat;
|
|
973
|
+
this.metaState = metaState;
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* @override
|
|
977
|
+
*/
|
|
978
|
+
toBuffer() {
|
|
979
|
+
const buffer$1 = buffer.Buffer.alloc(_KeyCodeControlMessage.PAYLOAD_LENGTH + 1);
|
|
980
|
+
let offset = 0;
|
|
981
|
+
offset = buffer$1.writeInt8(this.type, offset);
|
|
982
|
+
offset = buffer$1.writeInt8(this.action, offset);
|
|
983
|
+
offset = buffer$1.writeInt32BE(this.keycode, offset);
|
|
984
|
+
offset = buffer$1.writeInt32BE(this.repeat, offset);
|
|
985
|
+
buffer$1.writeInt32BE(this.metaState, offset);
|
|
986
|
+
return buffer$1;
|
|
987
|
+
}
|
|
988
|
+
toString() {
|
|
989
|
+
return `KeyCodeControlMessage{action=${this.action}, keycode=${this.keycode}, metaState=${this.metaState}}`;
|
|
990
|
+
}
|
|
991
|
+
toJSON() {
|
|
992
|
+
return {
|
|
993
|
+
type: this.type,
|
|
994
|
+
action: this.action,
|
|
995
|
+
keycode: this.keycode,
|
|
996
|
+
metaState: this.metaState,
|
|
997
|
+
repeat: this.repeat
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
_KeyCodeControlMessage.PAYLOAD_LENGTH = 13;
|
|
1002
|
+
let KeyCodeControlMessage = _KeyCodeControlMessage;
|
|
1003
|
+
const _TextControlMessage = class _TextControlMessage extends ControlMessage {
|
|
1004
|
+
constructor(text) {
|
|
1005
|
+
super(ControlMessage.TYPE_TEXT);
|
|
1006
|
+
this.text = text;
|
|
1007
|
+
}
|
|
1008
|
+
getText() {
|
|
1009
|
+
return this.text;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* @override
|
|
1013
|
+
*/
|
|
1014
|
+
toBuffer() {
|
|
1015
|
+
const length = this.text.length;
|
|
1016
|
+
const buffer$1 = buffer.Buffer.alloc(length + 1 + _TextControlMessage.TEXT_SIZE_FIELD_LENGTH);
|
|
1017
|
+
let offset = 0;
|
|
1018
|
+
offset = buffer$1.writeUInt8(this.type, offset);
|
|
1019
|
+
offset = buffer$1.writeUInt32BE(length, offset);
|
|
1020
|
+
buffer$1.write(this.text, offset);
|
|
1021
|
+
return buffer$1;
|
|
1022
|
+
}
|
|
1023
|
+
toString() {
|
|
1024
|
+
return `TextControlMessage{text=${this.text}}`;
|
|
1025
|
+
}
|
|
1026
|
+
toJSON() {
|
|
1027
|
+
return {
|
|
1028
|
+
type: this.type,
|
|
1029
|
+
text: this.text
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
_TextControlMessage.TEXT_SIZE_FIELD_LENGTH = 4;
|
|
1034
|
+
let TextControlMessage = _TextControlMessage;
|
|
1035
|
+
var FilePushState = /* @__PURE__ */ ((FilePushState2) => {
|
|
1036
|
+
FilePushState2[FilePushState2["NEW"] = 0] = "NEW";
|
|
1037
|
+
FilePushState2[FilePushState2["START"] = 1] = "START";
|
|
1038
|
+
FilePushState2[FilePushState2["APPEND"] = 2] = "APPEND";
|
|
1039
|
+
FilePushState2[FilePushState2["FINISH"] = 3] = "FINISH";
|
|
1040
|
+
FilePushState2[FilePushState2["CANCEL"] = 4] = "CANCEL";
|
|
1041
|
+
return FilePushState2;
|
|
1042
|
+
})(FilePushState || {});
|
|
1043
|
+
const _CommandControlMessage = class _CommandControlMessage extends ControlMessage {
|
|
1044
|
+
constructor(type) {
|
|
1045
|
+
super(type);
|
|
1046
|
+
this.type = type;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* 注意: createSetVideoSettingsCommand 方法依赖 VideoSettings 类
|
|
1050
|
+
* 该方法未包含在此独立模块中
|
|
1051
|
+
* 如需使用,请在应用中自行实现或从原项目导入
|
|
1052
|
+
*/
|
|
1053
|
+
// public static createSetVideoSettingsCommand(videoSettings: VideoSettings): CommandControlMessage {
|
|
1054
|
+
// ...
|
|
1055
|
+
// }
|
|
1056
|
+
static createSetClipboardCommand(text, paste = false) {
|
|
1057
|
+
const event = new _CommandControlMessage(ControlMessage.TYPE_SET_CLIPBOARD);
|
|
1058
|
+
const textBytes = text ? Util.stringToUtf8ByteArray(text) : null;
|
|
1059
|
+
const textLength = textBytes ? textBytes.length : 0;
|
|
1060
|
+
let offset = 0;
|
|
1061
|
+
const buffer$1 = buffer.Buffer.alloc(1 + 1 + 4 + textLength);
|
|
1062
|
+
offset = buffer$1.writeInt8(event.type, offset);
|
|
1063
|
+
offset = buffer$1.writeInt8(paste ? 1 : 0, offset);
|
|
1064
|
+
offset = buffer$1.writeInt32BE(textLength, offset);
|
|
1065
|
+
if (textBytes) {
|
|
1066
|
+
textBytes.forEach((byte, index) => {
|
|
1067
|
+
buffer$1.writeUInt8(byte, index + offset);
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
event.buffer = buffer$1;
|
|
1071
|
+
return event;
|
|
1072
|
+
}
|
|
1073
|
+
static createSetScreenPowerModeCommand(mode) {
|
|
1074
|
+
const event = new _CommandControlMessage(ControlMessage.TYPE_SET_SCREEN_POWER_MODE);
|
|
1075
|
+
let offset = 0;
|
|
1076
|
+
const buffer$1 = buffer.Buffer.alloc(1 + 1);
|
|
1077
|
+
offset = buffer$1.writeInt8(event.type, offset);
|
|
1078
|
+
buffer$1.writeUInt8(mode ? 1 : 0, offset);
|
|
1079
|
+
event.buffer = buffer$1;
|
|
1080
|
+
return event;
|
|
1081
|
+
}
|
|
1082
|
+
static createPushFileCommand(params) {
|
|
1083
|
+
const { id, fileName, fileSize, chunk, state } = params;
|
|
1084
|
+
if (state === 1) {
|
|
1085
|
+
return this.createPushFileStartCommand(id, fileName, fileSize);
|
|
1086
|
+
}
|
|
1087
|
+
if (state === 2) {
|
|
1088
|
+
if (!chunk) {
|
|
1089
|
+
throw TypeError("Invalid type");
|
|
1090
|
+
}
|
|
1091
|
+
return this.createPushFileChunkCommand(id, chunk);
|
|
1092
|
+
}
|
|
1093
|
+
if (state === 4 || state === 3 || state === 0) {
|
|
1094
|
+
return this.createPushFileOtherCommand(id, state);
|
|
1095
|
+
}
|
|
1096
|
+
throw TypeError(`Unsupported state: "${state}"`);
|
|
1097
|
+
}
|
|
1098
|
+
static createPushFileStartCommand(id, fileName, fileSize) {
|
|
1099
|
+
const event = new _CommandControlMessage(ControlMessage.TYPE_PUSH_FILE);
|
|
1100
|
+
const text = Util.stringToUtf8ByteArray(fileName);
|
|
1101
|
+
const typeField = 1;
|
|
1102
|
+
const idField = 2;
|
|
1103
|
+
const stateField = 1;
|
|
1104
|
+
const sizeField = 4;
|
|
1105
|
+
const textLengthField = 2;
|
|
1106
|
+
const textLength = text.length;
|
|
1107
|
+
let offset = _CommandControlMessage.PAYLOAD_LENGTH;
|
|
1108
|
+
const buffer$1 = buffer.Buffer.alloc(
|
|
1109
|
+
offset + typeField + idField + stateField + sizeField + textLengthField + textLength
|
|
1110
|
+
);
|
|
1111
|
+
buffer$1.writeUInt8(event.type, offset);
|
|
1112
|
+
offset += typeField;
|
|
1113
|
+
buffer$1.writeInt16BE(id, offset);
|
|
1114
|
+
offset += idField;
|
|
1115
|
+
buffer$1.writeInt8(1, offset);
|
|
1116
|
+
offset += stateField;
|
|
1117
|
+
buffer$1.writeUInt32BE(fileSize, offset);
|
|
1118
|
+
offset += sizeField;
|
|
1119
|
+
buffer$1.writeUInt16BE(textLength, offset);
|
|
1120
|
+
offset += textLengthField;
|
|
1121
|
+
text.forEach((byte, index) => {
|
|
1122
|
+
buffer$1.writeUInt8(byte, index + offset);
|
|
1123
|
+
});
|
|
1124
|
+
event.buffer = buffer$1;
|
|
1125
|
+
return event;
|
|
1126
|
+
}
|
|
1127
|
+
static createPushFileChunkCommand(id, chunk) {
|
|
1128
|
+
const event = new _CommandControlMessage(ControlMessage.TYPE_PUSH_FILE);
|
|
1129
|
+
const typeField = 1;
|
|
1130
|
+
const idField = 2;
|
|
1131
|
+
const stateField = 1;
|
|
1132
|
+
const chunkLengthField = 4;
|
|
1133
|
+
const chunkLength = chunk.byteLength;
|
|
1134
|
+
let offset = _CommandControlMessage.PAYLOAD_LENGTH;
|
|
1135
|
+
const buffer$1 = buffer.Buffer.alloc(offset + typeField + idField + stateField + chunkLengthField + chunkLength);
|
|
1136
|
+
buffer$1.writeUInt8(event.type, offset);
|
|
1137
|
+
offset += typeField;
|
|
1138
|
+
buffer$1.writeInt16BE(id, offset);
|
|
1139
|
+
offset += idField;
|
|
1140
|
+
buffer$1.writeInt8(2, offset);
|
|
1141
|
+
offset += stateField;
|
|
1142
|
+
buffer$1.writeUInt32BE(chunkLength, offset);
|
|
1143
|
+
offset += chunkLengthField;
|
|
1144
|
+
Array.from(chunk).forEach((byte, index) => {
|
|
1145
|
+
buffer$1.writeUInt8(byte, index + offset);
|
|
1146
|
+
});
|
|
1147
|
+
event.buffer = buffer$1;
|
|
1148
|
+
return event;
|
|
1149
|
+
}
|
|
1150
|
+
static createPushFileOtherCommand(id, state) {
|
|
1151
|
+
const event = new _CommandControlMessage(ControlMessage.TYPE_PUSH_FILE);
|
|
1152
|
+
const typeField = 1;
|
|
1153
|
+
const idField = 2;
|
|
1154
|
+
const stateField = 1;
|
|
1155
|
+
let offset = _CommandControlMessage.PAYLOAD_LENGTH;
|
|
1156
|
+
const buffer$1 = buffer.Buffer.alloc(offset + typeField + idField + stateField);
|
|
1157
|
+
buffer$1.writeUInt8(event.type, offset);
|
|
1158
|
+
offset += typeField;
|
|
1159
|
+
buffer$1.writeInt16BE(id, offset);
|
|
1160
|
+
offset += idField;
|
|
1161
|
+
buffer$1.writeInt8(state, offset);
|
|
1162
|
+
event.buffer = buffer$1;
|
|
1163
|
+
return event;
|
|
1164
|
+
}
|
|
1165
|
+
static pushFileCommandFromBuffer(buffer2) {
|
|
1166
|
+
let offset = 0;
|
|
1167
|
+
const type = buffer2.readUInt8(offset);
|
|
1168
|
+
offset += 1;
|
|
1169
|
+
if (type !== _CommandControlMessage.TYPE_PUSH_FILE) {
|
|
1170
|
+
throw TypeError(`Incorrect type: "${type}"`);
|
|
1171
|
+
}
|
|
1172
|
+
const id = buffer2.readInt16BE(offset);
|
|
1173
|
+
offset += 2;
|
|
1174
|
+
const state = buffer2.readInt8(offset);
|
|
1175
|
+
offset += 1;
|
|
1176
|
+
let chunk;
|
|
1177
|
+
let fileSize;
|
|
1178
|
+
let fileName;
|
|
1179
|
+
if (state === 2) {
|
|
1180
|
+
const chunkLength = buffer2.readUInt32BE(offset);
|
|
1181
|
+
offset += 4;
|
|
1182
|
+
chunk = buffer2.slice(offset, offset + chunkLength);
|
|
1183
|
+
} else if (state === 1) {
|
|
1184
|
+
fileSize = buffer2.readUInt32BE(offset);
|
|
1185
|
+
offset += 4;
|
|
1186
|
+
const textLength = buffer2.readUInt16BE(offset);
|
|
1187
|
+
offset += 2;
|
|
1188
|
+
fileName = Util.utf8ByteArrayToString(buffer2.slice(offset, offset + textLength));
|
|
1189
|
+
}
|
|
1190
|
+
return { id, state, chunk, fileName, fileSize };
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* @override
|
|
1194
|
+
*/
|
|
1195
|
+
toBuffer() {
|
|
1196
|
+
if (!this.buffer) {
|
|
1197
|
+
const buffer$1 = buffer.Buffer.alloc(_CommandControlMessage.PAYLOAD_LENGTH + 1);
|
|
1198
|
+
buffer$1.writeUInt8(this.type, 0);
|
|
1199
|
+
this.buffer = buffer$1;
|
|
1200
|
+
}
|
|
1201
|
+
return this.buffer;
|
|
1202
|
+
}
|
|
1203
|
+
toString() {
|
|
1204
|
+
const buffer2 = this.buffer ? `, buffer=[${this.buffer.join(",")}]` : "";
|
|
1205
|
+
return `CommandControlMessage{action=${this.type}${buffer2}}`;
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
_CommandControlMessage.PAYLOAD_LENGTH = 0;
|
|
1209
|
+
_CommandControlMessage.Commands = /* @__PURE__ */ new Map([
|
|
1210
|
+
[ControlMessage.TYPE_EXPAND_NOTIFICATION_PANEL, "Expand notifications"],
|
|
1211
|
+
[ControlMessage.TYPE_EXPAND_SETTINGS_PANEL, "Expand settings"],
|
|
1212
|
+
[ControlMessage.TYPE_COLLAPSE_PANELS, "Collapse panels"],
|
|
1213
|
+
[ControlMessage.TYPE_GET_CLIPBOARD, "Get clipboard"],
|
|
1214
|
+
[ControlMessage.TYPE_SET_CLIPBOARD, "Set clipboard"],
|
|
1215
|
+
[ControlMessage.TYPE_ROTATE_DEVICE, "Rotate device"],
|
|
1216
|
+
[ControlMessage.TYPE_CHANGE_STREAM_PARAMETERS, "Change video settings"]
|
|
1217
|
+
]);
|
|
1218
|
+
let CommandControlMessage = _CommandControlMessage;
|
|
1219
|
+
const _KeyEvent = class _KeyEvent {
|
|
1220
|
+
};
|
|
1221
|
+
_KeyEvent.ACTION_DOWN = 0;
|
|
1222
|
+
_KeyEvent.ACTION_UP = 1;
|
|
1223
|
+
_KeyEvent.KEYCODE_0 = 7;
|
|
1224
|
+
_KeyEvent.KEYCODE_1 = 8;
|
|
1225
|
+
_KeyEvent.KEYCODE_11 = 227;
|
|
1226
|
+
_KeyEvent.KEYCODE_12 = 228;
|
|
1227
|
+
_KeyEvent.KEYCODE_2 = 9;
|
|
1228
|
+
_KeyEvent.KEYCODE_3 = 10;
|
|
1229
|
+
_KeyEvent.KEYCODE_3D_MODE = 206;
|
|
1230
|
+
_KeyEvent.KEYCODE_4 = 11;
|
|
1231
|
+
_KeyEvent.KEYCODE_5 = 12;
|
|
1232
|
+
_KeyEvent.KEYCODE_6 = 13;
|
|
1233
|
+
_KeyEvent.KEYCODE_7 = 14;
|
|
1234
|
+
_KeyEvent.KEYCODE_8 = 15;
|
|
1235
|
+
_KeyEvent.KEYCODE_9 = 16;
|
|
1236
|
+
_KeyEvent.KEYCODE_A = 29;
|
|
1237
|
+
_KeyEvent.KEYCODE_ALL_APPS = 284;
|
|
1238
|
+
_KeyEvent.KEYCODE_ALT_LEFT = 57;
|
|
1239
|
+
_KeyEvent.KEYCODE_ALT_RIGHT = 58;
|
|
1240
|
+
_KeyEvent.KEYCODE_APOSTROPHE = 75;
|
|
1241
|
+
_KeyEvent.KEYCODE_APP_SWITCH = 187;
|
|
1242
|
+
_KeyEvent.KEYCODE_ASSIST = 219;
|
|
1243
|
+
_KeyEvent.KEYCODE_AT = 77;
|
|
1244
|
+
_KeyEvent.KEYCODE_AVR_INPUT = 182;
|
|
1245
|
+
_KeyEvent.KEYCODE_AVR_POWER = 181;
|
|
1246
|
+
_KeyEvent.KEYCODE_B = 30;
|
|
1247
|
+
_KeyEvent.KEYCODE_BACK = 4;
|
|
1248
|
+
_KeyEvent.KEYCODE_BACKSLASH = 73;
|
|
1249
|
+
_KeyEvent.KEYCODE_BOOKMARK = 174;
|
|
1250
|
+
_KeyEvent.KEYCODE_BREAK = 121;
|
|
1251
|
+
_KeyEvent.KEYCODE_BRIGHTNESS_DOWN = 220;
|
|
1252
|
+
_KeyEvent.KEYCODE_BRIGHTNESS_UP = 221;
|
|
1253
|
+
_KeyEvent.KEYCODE_BUTTON_1 = 188;
|
|
1254
|
+
_KeyEvent.KEYCODE_BUTTON_10 = 197;
|
|
1255
|
+
_KeyEvent.KEYCODE_BUTTON_11 = 198;
|
|
1256
|
+
_KeyEvent.KEYCODE_BUTTON_12 = 199;
|
|
1257
|
+
_KeyEvent.KEYCODE_BUTTON_13 = 200;
|
|
1258
|
+
_KeyEvent.KEYCODE_BUTTON_14 = 201;
|
|
1259
|
+
_KeyEvent.KEYCODE_BUTTON_15 = 202;
|
|
1260
|
+
_KeyEvent.KEYCODE_BUTTON_16 = 203;
|
|
1261
|
+
_KeyEvent.KEYCODE_BUTTON_2 = 189;
|
|
1262
|
+
_KeyEvent.KEYCODE_BUTTON_3 = 190;
|
|
1263
|
+
_KeyEvent.KEYCODE_BUTTON_4 = 191;
|
|
1264
|
+
_KeyEvent.KEYCODE_BUTTON_5 = 192;
|
|
1265
|
+
_KeyEvent.KEYCODE_BUTTON_6 = 193;
|
|
1266
|
+
_KeyEvent.KEYCODE_BUTTON_7 = 194;
|
|
1267
|
+
_KeyEvent.KEYCODE_BUTTON_8 = 195;
|
|
1268
|
+
_KeyEvent.KEYCODE_BUTTON_9 = 196;
|
|
1269
|
+
_KeyEvent.KEYCODE_BUTTON_A = 96;
|
|
1270
|
+
_KeyEvent.KEYCODE_BUTTON_B = 97;
|
|
1271
|
+
_KeyEvent.KEYCODE_BUTTON_C = 98;
|
|
1272
|
+
_KeyEvent.KEYCODE_BUTTON_L1 = 102;
|
|
1273
|
+
_KeyEvent.KEYCODE_BUTTON_L2 = 104;
|
|
1274
|
+
_KeyEvent.KEYCODE_BUTTON_MODE = 110;
|
|
1275
|
+
_KeyEvent.KEYCODE_BUTTON_R1 = 103;
|
|
1276
|
+
_KeyEvent.KEYCODE_BUTTON_R2 = 105;
|
|
1277
|
+
_KeyEvent.KEYCODE_BUTTON_SELECT = 109;
|
|
1278
|
+
_KeyEvent.KEYCODE_BUTTON_START = 108;
|
|
1279
|
+
_KeyEvent.KEYCODE_BUTTON_THUMBL = 106;
|
|
1280
|
+
_KeyEvent.KEYCODE_BUTTON_THUMBR = 107;
|
|
1281
|
+
_KeyEvent.KEYCODE_BUTTON_X = 99;
|
|
1282
|
+
_KeyEvent.KEYCODE_BUTTON_Y = 100;
|
|
1283
|
+
_KeyEvent.KEYCODE_BUTTON_Z = 101;
|
|
1284
|
+
_KeyEvent.KEYCODE_C = 31;
|
|
1285
|
+
_KeyEvent.KEYCODE_CALCULATOR = 210;
|
|
1286
|
+
_KeyEvent.KEYCODE_CALENDAR = 208;
|
|
1287
|
+
_KeyEvent.KEYCODE_CALL = 5;
|
|
1288
|
+
_KeyEvent.KEYCODE_CAMERA = 27;
|
|
1289
|
+
_KeyEvent.KEYCODE_CAPS_LOCK = 115;
|
|
1290
|
+
_KeyEvent.KEYCODE_CAPTIONS = 175;
|
|
1291
|
+
_KeyEvent.KEYCODE_CHANNEL_DOWN = 167;
|
|
1292
|
+
_KeyEvent.KEYCODE_CHANNEL_UP = 166;
|
|
1293
|
+
_KeyEvent.KEYCODE_CLEAR = 28;
|
|
1294
|
+
_KeyEvent.KEYCODE_COMMA = 55;
|
|
1295
|
+
_KeyEvent.KEYCODE_CONTACTS = 207;
|
|
1296
|
+
_KeyEvent.KEYCODE_COPY = 278;
|
|
1297
|
+
_KeyEvent.KEYCODE_CTRL_LEFT = 113;
|
|
1298
|
+
_KeyEvent.KEYCODE_CTRL_RIGHT = 114;
|
|
1299
|
+
_KeyEvent.KEYCODE_CUT = 277;
|
|
1300
|
+
_KeyEvent.KEYCODE_D = 32;
|
|
1301
|
+
_KeyEvent.KEYCODE_DEL = 67;
|
|
1302
|
+
_KeyEvent.KEYCODE_DPAD_CENTER = 23;
|
|
1303
|
+
_KeyEvent.KEYCODE_DPAD_DOWN = 20;
|
|
1304
|
+
_KeyEvent.KEYCODE_DPAD_DOWN_LEFT = 269;
|
|
1305
|
+
_KeyEvent.KEYCODE_DPAD_DOWN_RIGHT = 271;
|
|
1306
|
+
_KeyEvent.KEYCODE_DPAD_LEFT = 21;
|
|
1307
|
+
_KeyEvent.KEYCODE_DPAD_RIGHT = 22;
|
|
1308
|
+
_KeyEvent.KEYCODE_DPAD_UP = 19;
|
|
1309
|
+
_KeyEvent.KEYCODE_DPAD_UP_LEFT = 268;
|
|
1310
|
+
_KeyEvent.KEYCODE_DPAD_UP_RIGHT = 270;
|
|
1311
|
+
_KeyEvent.KEYCODE_DVR = 173;
|
|
1312
|
+
_KeyEvent.KEYCODE_E = 33;
|
|
1313
|
+
_KeyEvent.KEYCODE_EISU = 212;
|
|
1314
|
+
_KeyEvent.KEYCODE_ENDCALL = 6;
|
|
1315
|
+
_KeyEvent.KEYCODE_ENTER = 66;
|
|
1316
|
+
_KeyEvent.KEYCODE_ENVELOPE = 65;
|
|
1317
|
+
_KeyEvent.KEYCODE_EQUALS = 70;
|
|
1318
|
+
_KeyEvent.KEYCODE_ESCAPE = 111;
|
|
1319
|
+
_KeyEvent.KEYCODE_EXPLORER = 64;
|
|
1320
|
+
_KeyEvent.KEYCODE_F = 34;
|
|
1321
|
+
_KeyEvent.KEYCODE_F1 = 131;
|
|
1322
|
+
_KeyEvent.KEYCODE_F10 = 140;
|
|
1323
|
+
_KeyEvent.KEYCODE_F11 = 141;
|
|
1324
|
+
_KeyEvent.KEYCODE_F12 = 142;
|
|
1325
|
+
_KeyEvent.KEYCODE_F2 = 132;
|
|
1326
|
+
_KeyEvent.KEYCODE_F3 = 133;
|
|
1327
|
+
_KeyEvent.KEYCODE_F4 = 134;
|
|
1328
|
+
_KeyEvent.KEYCODE_F5 = 135;
|
|
1329
|
+
_KeyEvent.KEYCODE_F6 = 136;
|
|
1330
|
+
_KeyEvent.KEYCODE_F7 = 137;
|
|
1331
|
+
_KeyEvent.KEYCODE_F8 = 138;
|
|
1332
|
+
_KeyEvent.KEYCODE_F9 = 139;
|
|
1333
|
+
_KeyEvent.KEYCODE_FOCUS = 80;
|
|
1334
|
+
_KeyEvent.KEYCODE_FORWARD = 125;
|
|
1335
|
+
_KeyEvent.KEYCODE_FORWARD_DEL = 112;
|
|
1336
|
+
_KeyEvent.KEYCODE_FUNCTION = 119;
|
|
1337
|
+
_KeyEvent.KEYCODE_G = 35;
|
|
1338
|
+
_KeyEvent.KEYCODE_GRAVE = 68;
|
|
1339
|
+
_KeyEvent.KEYCODE_GUIDE = 172;
|
|
1340
|
+
_KeyEvent.KEYCODE_H = 36;
|
|
1341
|
+
_KeyEvent.KEYCODE_HEADSETHOOK = 79;
|
|
1342
|
+
_KeyEvent.KEYCODE_HELP = 259;
|
|
1343
|
+
_KeyEvent.KEYCODE_HENKAN = 214;
|
|
1344
|
+
_KeyEvent.KEYCODE_HOME = 3;
|
|
1345
|
+
_KeyEvent.KEYCODE_I = 37;
|
|
1346
|
+
_KeyEvent.KEYCODE_INFO = 165;
|
|
1347
|
+
_KeyEvent.KEYCODE_INSERT = 124;
|
|
1348
|
+
_KeyEvent.KEYCODE_J = 38;
|
|
1349
|
+
_KeyEvent.KEYCODE_K = 39;
|
|
1350
|
+
_KeyEvent.KEYCODE_KANA = 218;
|
|
1351
|
+
_KeyEvent.KEYCODE_KATAKANA_HIRAGANA = 215;
|
|
1352
|
+
_KeyEvent.KEYCODE_L = 40;
|
|
1353
|
+
_KeyEvent.KEYCODE_LANGUAGE_SWITCH = 204;
|
|
1354
|
+
_KeyEvent.KEYCODE_LAST_CHANNEL = 229;
|
|
1355
|
+
_KeyEvent.KEYCODE_LEFT_BRACKET = 71;
|
|
1356
|
+
_KeyEvent.KEYCODE_M = 41;
|
|
1357
|
+
_KeyEvent.KEYCODE_MANNER_MODE = 205;
|
|
1358
|
+
_KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK = 222;
|
|
1359
|
+
_KeyEvent.KEYCODE_MEDIA_CLOSE = 128;
|
|
1360
|
+
_KeyEvent.KEYCODE_MEDIA_EJECT = 129;
|
|
1361
|
+
_KeyEvent.KEYCODE_MEDIA_FAST_FORWARD = 90;
|
|
1362
|
+
_KeyEvent.KEYCODE_MEDIA_NEXT = 87;
|
|
1363
|
+
_KeyEvent.KEYCODE_MEDIA_PAUSE = 127;
|
|
1364
|
+
_KeyEvent.KEYCODE_MEDIA_PLAY = 126;
|
|
1365
|
+
_KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE = 85;
|
|
1366
|
+
_KeyEvent.KEYCODE_MEDIA_PREVIOUS = 88;
|
|
1367
|
+
_KeyEvent.KEYCODE_MEDIA_RECORD = 130;
|
|
1368
|
+
_KeyEvent.KEYCODE_MEDIA_REWIND = 89;
|
|
1369
|
+
_KeyEvent.KEYCODE_MEDIA_SKIP_BACKWARD = 273;
|
|
1370
|
+
_KeyEvent.KEYCODE_MEDIA_SKIP_FORWARD = 272;
|
|
1371
|
+
_KeyEvent.KEYCODE_MEDIA_STEP_BACKWARD = 275;
|
|
1372
|
+
_KeyEvent.KEYCODE_MEDIA_STEP_FORWARD = 274;
|
|
1373
|
+
_KeyEvent.KEYCODE_MEDIA_STOP = 86;
|
|
1374
|
+
_KeyEvent.KEYCODE_MEDIA_TOP_MENU = 226;
|
|
1375
|
+
_KeyEvent.KEYCODE_MENU = 82;
|
|
1376
|
+
_KeyEvent.KEYCODE_META_LEFT = 117;
|
|
1377
|
+
_KeyEvent.KEYCODE_META_RIGHT = 118;
|
|
1378
|
+
_KeyEvent.KEYCODE_MINUS = 69;
|
|
1379
|
+
_KeyEvent.KEYCODE_MOVE_END = 123;
|
|
1380
|
+
_KeyEvent.KEYCODE_MOVE_HOME = 122;
|
|
1381
|
+
_KeyEvent.KEYCODE_MUHENKAN = 213;
|
|
1382
|
+
_KeyEvent.KEYCODE_MUSIC = 209;
|
|
1383
|
+
_KeyEvent.KEYCODE_MUTE = 91;
|
|
1384
|
+
_KeyEvent.KEYCODE_N = 42;
|
|
1385
|
+
_KeyEvent.KEYCODE_NAVIGATE_IN = 262;
|
|
1386
|
+
_KeyEvent.KEYCODE_NAVIGATE_NEXT = 261;
|
|
1387
|
+
_KeyEvent.KEYCODE_NAVIGATE_OUT = 263;
|
|
1388
|
+
_KeyEvent.KEYCODE_NAVIGATE_PREVIOUS = 260;
|
|
1389
|
+
_KeyEvent.KEYCODE_NOTIFICATION = 83;
|
|
1390
|
+
_KeyEvent.KEYCODE_NUM = 78;
|
|
1391
|
+
_KeyEvent.KEYCODE_NUMPAD_0 = 144;
|
|
1392
|
+
_KeyEvent.KEYCODE_NUMPAD_1 = 145;
|
|
1393
|
+
_KeyEvent.KEYCODE_NUMPAD_2 = 146;
|
|
1394
|
+
_KeyEvent.KEYCODE_NUMPAD_3 = 147;
|
|
1395
|
+
_KeyEvent.KEYCODE_NUMPAD_4 = 148;
|
|
1396
|
+
_KeyEvent.KEYCODE_NUMPAD_5 = 149;
|
|
1397
|
+
_KeyEvent.KEYCODE_NUMPAD_6 = 150;
|
|
1398
|
+
_KeyEvent.KEYCODE_NUMPAD_7 = 151;
|
|
1399
|
+
_KeyEvent.KEYCODE_NUMPAD_8 = 152;
|
|
1400
|
+
_KeyEvent.KEYCODE_NUMPAD_9 = 153;
|
|
1401
|
+
_KeyEvent.KEYCODE_NUMPAD_ADD = 157;
|
|
1402
|
+
_KeyEvent.KEYCODE_NUMPAD_COMMA = 159;
|
|
1403
|
+
_KeyEvent.KEYCODE_NUMPAD_DIVIDE = 154;
|
|
1404
|
+
_KeyEvent.KEYCODE_NUMPAD_DOT = 158;
|
|
1405
|
+
_KeyEvent.KEYCODE_NUMPAD_ENTER = 160;
|
|
1406
|
+
_KeyEvent.KEYCODE_NUMPAD_EQUALS = 161;
|
|
1407
|
+
_KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN = 162;
|
|
1408
|
+
_KeyEvent.KEYCODE_NUMPAD_MULTIPLY = 155;
|
|
1409
|
+
_KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN = 163;
|
|
1410
|
+
_KeyEvent.KEYCODE_NUMPAD_SUBTRACT = 156;
|
|
1411
|
+
_KeyEvent.KEYCODE_NUM_LOCK = 143;
|
|
1412
|
+
_KeyEvent.KEYCODE_O = 43;
|
|
1413
|
+
_KeyEvent.KEYCODE_P = 44;
|
|
1414
|
+
_KeyEvent.KEYCODE_PAGE_DOWN = 93;
|
|
1415
|
+
_KeyEvent.KEYCODE_PAGE_UP = 92;
|
|
1416
|
+
_KeyEvent.KEYCODE_PAIRING = 225;
|
|
1417
|
+
_KeyEvent.KEYCODE_PASTE = 279;
|
|
1418
|
+
_KeyEvent.KEYCODE_PERIOD = 56;
|
|
1419
|
+
_KeyEvent.KEYCODE_PICTSYMBOLS = 94;
|
|
1420
|
+
_KeyEvent.KEYCODE_PLUS = 81;
|
|
1421
|
+
_KeyEvent.KEYCODE_POUND = 18;
|
|
1422
|
+
_KeyEvent.KEYCODE_POWER = 26;
|
|
1423
|
+
_KeyEvent.KEYCODE_PROFILE_SWITCH = 288;
|
|
1424
|
+
_KeyEvent.KEYCODE_PROG_BLUE = 186;
|
|
1425
|
+
_KeyEvent.KEYCODE_PROG_GREEN = 184;
|
|
1426
|
+
_KeyEvent.KEYCODE_PROG_RED = 183;
|
|
1427
|
+
_KeyEvent.KEYCODE_PROG_YELLOW = 185;
|
|
1428
|
+
_KeyEvent.KEYCODE_Q = 45;
|
|
1429
|
+
_KeyEvent.KEYCODE_R = 46;
|
|
1430
|
+
_KeyEvent.KEYCODE_REFRESH = 285;
|
|
1431
|
+
_KeyEvent.KEYCODE_RIGHT_BRACKET = 72;
|
|
1432
|
+
_KeyEvent.KEYCODE_RO = 217;
|
|
1433
|
+
_KeyEvent.KEYCODE_S = 47;
|
|
1434
|
+
_KeyEvent.KEYCODE_SCROLL_LOCK = 116;
|
|
1435
|
+
_KeyEvent.KEYCODE_SEARCH = 84;
|
|
1436
|
+
_KeyEvent.KEYCODE_SEMICOLON = 74;
|
|
1437
|
+
_KeyEvent.KEYCODE_SETTINGS = 176;
|
|
1438
|
+
_KeyEvent.KEYCODE_SHIFT_LEFT = 59;
|
|
1439
|
+
_KeyEvent.KEYCODE_SHIFT_RIGHT = 60;
|
|
1440
|
+
_KeyEvent.KEYCODE_SLASH = 76;
|
|
1441
|
+
_KeyEvent.KEYCODE_SLEEP = 223;
|
|
1442
|
+
_KeyEvent.KEYCODE_SOFT_LEFT = 1;
|
|
1443
|
+
_KeyEvent.KEYCODE_SOFT_RIGHT = 2;
|
|
1444
|
+
_KeyEvent.KEYCODE_SOFT_SLEEP = 276;
|
|
1445
|
+
_KeyEvent.KEYCODE_SPACE = 62;
|
|
1446
|
+
_KeyEvent.KEYCODE_STAR = 17;
|
|
1447
|
+
_KeyEvent.KEYCODE_STB_INPUT = 180;
|
|
1448
|
+
_KeyEvent.KEYCODE_STB_POWER = 179;
|
|
1449
|
+
_KeyEvent.KEYCODE_STEM_1 = 265;
|
|
1450
|
+
_KeyEvent.KEYCODE_STEM_2 = 266;
|
|
1451
|
+
_KeyEvent.KEYCODE_STEM_3 = 267;
|
|
1452
|
+
_KeyEvent.KEYCODE_STEM_PRIMARY = 264;
|
|
1453
|
+
_KeyEvent.KEYCODE_SWITCH_CHARSET = 95;
|
|
1454
|
+
_KeyEvent.KEYCODE_SYM = 63;
|
|
1455
|
+
_KeyEvent.KEYCODE_SYSRQ = 120;
|
|
1456
|
+
_KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN = 281;
|
|
1457
|
+
_KeyEvent.KEYCODE_SYSTEM_NAVIGATION_LEFT = 282;
|
|
1458
|
+
_KeyEvent.KEYCODE_SYSTEM_NAVIGATION_RIGHT = 283;
|
|
1459
|
+
_KeyEvent.KEYCODE_SYSTEM_NAVIGATION_UP = 280;
|
|
1460
|
+
_KeyEvent.KEYCODE_T = 48;
|
|
1461
|
+
_KeyEvent.KEYCODE_TAB = 61;
|
|
1462
|
+
_KeyEvent.KEYCODE_THUMBS_DOWN = 287;
|
|
1463
|
+
_KeyEvent.KEYCODE_THUMBS_UP = 286;
|
|
1464
|
+
_KeyEvent.KEYCODE_TV = 170;
|
|
1465
|
+
_KeyEvent.KEYCODE_TV_ANTENNA_CABLE = 242;
|
|
1466
|
+
_KeyEvent.KEYCODE_TV_AUDIO_DESCRIPTION = 252;
|
|
1467
|
+
_KeyEvent.KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254;
|
|
1468
|
+
_KeyEvent.KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253;
|
|
1469
|
+
_KeyEvent.KEYCODE_TV_CONTENTS_MENU = 256;
|
|
1470
|
+
_KeyEvent.KEYCODE_TV_DATA_SERVICE = 230;
|
|
1471
|
+
_KeyEvent.KEYCODE_TV_INPUT = 178;
|
|
1472
|
+
_KeyEvent.KEYCODE_TV_INPUT_COMPONENT_1 = 249;
|
|
1473
|
+
_KeyEvent.KEYCODE_TV_INPUT_COMPONENT_2 = 250;
|
|
1474
|
+
_KeyEvent.KEYCODE_TV_INPUT_COMPOSITE_1 = 247;
|
|
1475
|
+
_KeyEvent.KEYCODE_TV_INPUT_COMPOSITE_2 = 248;
|
|
1476
|
+
_KeyEvent.KEYCODE_TV_INPUT_HDMI_1 = 243;
|
|
1477
|
+
_KeyEvent.KEYCODE_TV_INPUT_HDMI_2 = 244;
|
|
1478
|
+
_KeyEvent.KEYCODE_TV_INPUT_HDMI_3 = 245;
|
|
1479
|
+
_KeyEvent.KEYCODE_TV_INPUT_HDMI_4 = 246;
|
|
1480
|
+
_KeyEvent.KEYCODE_TV_INPUT_VGA_1 = 251;
|
|
1481
|
+
_KeyEvent.KEYCODE_TV_MEDIA_CONTEXT_MENU = 257;
|
|
1482
|
+
_KeyEvent.KEYCODE_TV_NETWORK = 241;
|
|
1483
|
+
_KeyEvent.KEYCODE_TV_NUMBER_ENTRY = 234;
|
|
1484
|
+
_KeyEvent.KEYCODE_TV_POWER = 177;
|
|
1485
|
+
_KeyEvent.KEYCODE_TV_RADIO_SERVICE = 232;
|
|
1486
|
+
_KeyEvent.KEYCODE_TV_SATELLITE = 237;
|
|
1487
|
+
_KeyEvent.KEYCODE_TV_SATELLITE_BS = 238;
|
|
1488
|
+
_KeyEvent.KEYCODE_TV_SATELLITE_CS = 239;
|
|
1489
|
+
_KeyEvent.KEYCODE_TV_SATELLITE_SERVICE = 240;
|
|
1490
|
+
_KeyEvent.KEYCODE_TV_TELETEXT = 233;
|
|
1491
|
+
_KeyEvent.KEYCODE_TV_TERRESTRIAL_ANALOG = 235;
|
|
1492
|
+
_KeyEvent.KEYCODE_TV_TERRESTRIAL_DIGITAL = 236;
|
|
1493
|
+
_KeyEvent.KEYCODE_TV_TIMER_PROGRAMMING = 258;
|
|
1494
|
+
_KeyEvent.KEYCODE_TV_ZOOM_MODE = 255;
|
|
1495
|
+
_KeyEvent.KEYCODE_U = 49;
|
|
1496
|
+
_KeyEvent.KEYCODE_UNKNOWN = 0;
|
|
1497
|
+
_KeyEvent.KEYCODE_V = 50;
|
|
1498
|
+
_KeyEvent.KEYCODE_VOICE_ASSIST = 231;
|
|
1499
|
+
_KeyEvent.KEYCODE_VOLUME_DOWN = 25;
|
|
1500
|
+
_KeyEvent.KEYCODE_VOLUME_MUTE = 164;
|
|
1501
|
+
_KeyEvent.KEYCODE_VOLUME_UP = 24;
|
|
1502
|
+
_KeyEvent.KEYCODE_W = 51;
|
|
1503
|
+
_KeyEvent.KEYCODE_WAKEUP = 224;
|
|
1504
|
+
_KeyEvent.KEYCODE_WINDOW = 171;
|
|
1505
|
+
_KeyEvent.KEYCODE_X = 52;
|
|
1506
|
+
_KeyEvent.KEYCODE_Y = 53;
|
|
1507
|
+
_KeyEvent.KEYCODE_YEN = 216;
|
|
1508
|
+
_KeyEvent.KEYCODE_Z = 54;
|
|
1509
|
+
_KeyEvent.KEYCODE_ZENKAKU_HANKAKU = 211;
|
|
1510
|
+
_KeyEvent.KEYCODE_ZOOM_IN = 168;
|
|
1511
|
+
_KeyEvent.KEYCODE_ZOOM_OUT = 169;
|
|
1512
|
+
_KeyEvent.META_ALT_LEFT_ON = 16;
|
|
1513
|
+
_KeyEvent.META_ALT_MASK = 50;
|
|
1514
|
+
_KeyEvent.META_ALT_ON = 2;
|
|
1515
|
+
_KeyEvent.META_ALT_RIGHT_ON = 32;
|
|
1516
|
+
_KeyEvent.META_CAPS_LOCK_ON = 1048576;
|
|
1517
|
+
_KeyEvent.META_CTRL_LEFT_ON = 8192;
|
|
1518
|
+
_KeyEvent.META_CTRL_MASK = 28672;
|
|
1519
|
+
_KeyEvent.META_CTRL_ON = 4096;
|
|
1520
|
+
_KeyEvent.META_CTRL_RIGHT_ON = 16384;
|
|
1521
|
+
_KeyEvent.META_FUNCTION_ON = 8;
|
|
1522
|
+
_KeyEvent.META_META_LEFT_ON = 131072;
|
|
1523
|
+
_KeyEvent.META_META_MASK = 458752;
|
|
1524
|
+
_KeyEvent.META_META_ON = 65536;
|
|
1525
|
+
_KeyEvent.META_META_RIGHT_ON = 262144;
|
|
1526
|
+
_KeyEvent.META_NUM_LOCK_ON = 2097152;
|
|
1527
|
+
_KeyEvent.META_SCROLL_LOCK_ON = 4194304;
|
|
1528
|
+
_KeyEvent.META_SHIFT_LEFT_ON = 64;
|
|
1529
|
+
_KeyEvent.META_SHIFT_MASK = 193;
|
|
1530
|
+
_KeyEvent.META_SHIFT_ON = 1;
|
|
1531
|
+
_KeyEvent.META_SHIFT_RIGHT_ON = 128;
|
|
1532
|
+
_KeyEvent.META_SYM_ON = 4;
|
|
1533
|
+
let KeyEvent = _KeyEvent;
|
|
1534
|
+
const _UIEventsCode = class _UIEventsCode {
|
|
1535
|
+
};
|
|
1536
|
+
_UIEventsCode.Backquote = "Backquote";
|
|
1537
|
+
_UIEventsCode.Backslash = "Backslash";
|
|
1538
|
+
_UIEventsCode.BracketLeft = "BracketLeft";
|
|
1539
|
+
_UIEventsCode.BracketRight = "BracketRight";
|
|
1540
|
+
_UIEventsCode.Comma = "Comma";
|
|
1541
|
+
_UIEventsCode.Digit0 = "Digit0";
|
|
1542
|
+
_UIEventsCode.Digit1 = "Digit1";
|
|
1543
|
+
_UIEventsCode.Digit2 = "Digit2";
|
|
1544
|
+
_UIEventsCode.Digit3 = "Digit3";
|
|
1545
|
+
_UIEventsCode.Digit4 = "Digit4";
|
|
1546
|
+
_UIEventsCode.Digit5 = "Digit5";
|
|
1547
|
+
_UIEventsCode.Digit6 = "Digit6";
|
|
1548
|
+
_UIEventsCode.Digit7 = "Digit7";
|
|
1549
|
+
_UIEventsCode.Digit8 = "Digit8";
|
|
1550
|
+
_UIEventsCode.Digit9 = "Digit9";
|
|
1551
|
+
_UIEventsCode.Equal = "Equal";
|
|
1552
|
+
_UIEventsCode.IntlBackslash = "IntlBackslash";
|
|
1553
|
+
_UIEventsCode.IntlRo = "IntlRo";
|
|
1554
|
+
_UIEventsCode.IntlYen = "IntlYen";
|
|
1555
|
+
_UIEventsCode.KeyA = "KeyA";
|
|
1556
|
+
_UIEventsCode.KeyB = "KeyB";
|
|
1557
|
+
_UIEventsCode.KeyC = "KeyC";
|
|
1558
|
+
_UIEventsCode.KeyD = "KeyD";
|
|
1559
|
+
_UIEventsCode.KeyE = "KeyE";
|
|
1560
|
+
_UIEventsCode.KeyF = "KeyF";
|
|
1561
|
+
_UIEventsCode.KeyG = "KeyG";
|
|
1562
|
+
_UIEventsCode.KeyH = "KeyH";
|
|
1563
|
+
_UIEventsCode.KeyI = "KeyI";
|
|
1564
|
+
_UIEventsCode.KeyJ = "KeyJ";
|
|
1565
|
+
_UIEventsCode.KeyK = "KeyK";
|
|
1566
|
+
_UIEventsCode.KeyL = "KeyL";
|
|
1567
|
+
_UIEventsCode.KeyM = "KeyM";
|
|
1568
|
+
_UIEventsCode.KeyN = "KeyN";
|
|
1569
|
+
_UIEventsCode.KeyO = "KeyO";
|
|
1570
|
+
_UIEventsCode.KeyP = "KeyP";
|
|
1571
|
+
_UIEventsCode.KeyQ = "KeyQ";
|
|
1572
|
+
_UIEventsCode.KeyR = "KeyR";
|
|
1573
|
+
_UIEventsCode.KeyS = "KeyS";
|
|
1574
|
+
_UIEventsCode.KeyT = "KeyT";
|
|
1575
|
+
_UIEventsCode.KeyU = "KeyU";
|
|
1576
|
+
_UIEventsCode.KeyV = "KeyV";
|
|
1577
|
+
_UIEventsCode.KeyW = "KeyW";
|
|
1578
|
+
_UIEventsCode.KeyX = "KeyX";
|
|
1579
|
+
_UIEventsCode.KeyY = "KeyY";
|
|
1580
|
+
_UIEventsCode.KeyZ = "KeyZ";
|
|
1581
|
+
_UIEventsCode.Minus = "Minus";
|
|
1582
|
+
_UIEventsCode.Period = "Period";
|
|
1583
|
+
_UIEventsCode.Quote = "Quote";
|
|
1584
|
+
_UIEventsCode.Semicolon = "Semicolon";
|
|
1585
|
+
_UIEventsCode.Slash = "Slash";
|
|
1586
|
+
_UIEventsCode.AltLeft = "AltLeft";
|
|
1587
|
+
_UIEventsCode.AltRight = "AltRight";
|
|
1588
|
+
_UIEventsCode.Backspace = "Backspace";
|
|
1589
|
+
_UIEventsCode.CapsLock = "CapsLock";
|
|
1590
|
+
_UIEventsCode.ContextMenu = "ContextMenu";
|
|
1591
|
+
_UIEventsCode.ControlLeft = "ControlLeft";
|
|
1592
|
+
_UIEventsCode.ControlRight = "ControlRight";
|
|
1593
|
+
_UIEventsCode.Enter = "Enter";
|
|
1594
|
+
_UIEventsCode.MetaLeft = "MetaLeft";
|
|
1595
|
+
_UIEventsCode.MetaRight = "MetaRight";
|
|
1596
|
+
_UIEventsCode.ShiftLeft = "ShiftLeft";
|
|
1597
|
+
_UIEventsCode.ShiftRight = "ShiftRight";
|
|
1598
|
+
_UIEventsCode.Space = "Space";
|
|
1599
|
+
_UIEventsCode.Tab = "Tab";
|
|
1600
|
+
_UIEventsCode.Convert = "Convert";
|
|
1601
|
+
_UIEventsCode.KanaMode = "KanaMode";
|
|
1602
|
+
_UIEventsCode.Lang1 = "Lang1";
|
|
1603
|
+
_UIEventsCode.Lang2 = "Lang2";
|
|
1604
|
+
_UIEventsCode.Lang3 = "Lang3";
|
|
1605
|
+
_UIEventsCode.Lang4 = "Lang4";
|
|
1606
|
+
_UIEventsCode.Lang5 = "Lang5";
|
|
1607
|
+
_UIEventsCode.NonConvert = "NonConvert";
|
|
1608
|
+
_UIEventsCode.Delete = "Delete";
|
|
1609
|
+
_UIEventsCode.End = "End";
|
|
1610
|
+
_UIEventsCode.Help = "Help";
|
|
1611
|
+
_UIEventsCode.Home = "Home";
|
|
1612
|
+
_UIEventsCode.Insert = "Insert";
|
|
1613
|
+
_UIEventsCode.PageDown = "PageDown";
|
|
1614
|
+
_UIEventsCode.PageUp = "PageUp";
|
|
1615
|
+
_UIEventsCode.ArrowDown = "ArrowDown";
|
|
1616
|
+
_UIEventsCode.ArrowLeft = "ArrowLeft";
|
|
1617
|
+
_UIEventsCode.ArrowRight = "ArrowRight";
|
|
1618
|
+
_UIEventsCode.ArrowUp = "ArrowUp";
|
|
1619
|
+
_UIEventsCode.NumLock = "NumLock";
|
|
1620
|
+
_UIEventsCode.Numpad0 = "Numpad0";
|
|
1621
|
+
_UIEventsCode.Numpad1 = "Numpad1";
|
|
1622
|
+
_UIEventsCode.Numpad2 = "Numpad2";
|
|
1623
|
+
_UIEventsCode.Numpad3 = "Numpad3";
|
|
1624
|
+
_UIEventsCode.Numpad4 = "Numpad4";
|
|
1625
|
+
_UIEventsCode.Numpad5 = "Numpad5";
|
|
1626
|
+
_UIEventsCode.Numpad6 = "Numpad6";
|
|
1627
|
+
_UIEventsCode.Numpad7 = "Numpad7";
|
|
1628
|
+
_UIEventsCode.Numpad8 = "Numpad8";
|
|
1629
|
+
_UIEventsCode.Numpad9 = "Numpad9";
|
|
1630
|
+
_UIEventsCode.NumpadAdd = "NumpadAdd";
|
|
1631
|
+
_UIEventsCode.NumpadBackspace = "NumpadBackspace";
|
|
1632
|
+
_UIEventsCode.NumpadClear = "NumpadClear";
|
|
1633
|
+
_UIEventsCode.NumpadClearEntry = "NumpadClearEntry";
|
|
1634
|
+
_UIEventsCode.NumpadComma = "NumpadComma";
|
|
1635
|
+
_UIEventsCode.NumpadDecimal = "NumpadDecimal";
|
|
1636
|
+
_UIEventsCode.NumpadDivide = "NumpadDivide";
|
|
1637
|
+
_UIEventsCode.NumpadEnter = "NumpadEnter";
|
|
1638
|
+
_UIEventsCode.NumpadEqual = "NumpadEqual";
|
|
1639
|
+
_UIEventsCode.NumpadHash = "NumpadHash";
|
|
1640
|
+
_UIEventsCode.NumpadMemoryAdd = "NumpadMemoryAdd";
|
|
1641
|
+
_UIEventsCode.NumpadMemoryClear = "NumpadMemoryClear";
|
|
1642
|
+
_UIEventsCode.NumpadMemoryRecall = "NumpadMemoryRecall";
|
|
1643
|
+
_UIEventsCode.NumpadMemoryStore = "NumpadMemoryStore";
|
|
1644
|
+
_UIEventsCode.NumpadMemorySubtract = "NumpadMemorySubtract";
|
|
1645
|
+
_UIEventsCode.NumpadMultiply = "NumpadMultiply";
|
|
1646
|
+
_UIEventsCode.NumpadParenLeft = "NumpadParenLeft";
|
|
1647
|
+
_UIEventsCode.NumpadParenRight = "NumpadParenRight";
|
|
1648
|
+
_UIEventsCode.NumpadStar = "NumpadStar";
|
|
1649
|
+
_UIEventsCode.NumpadSubtract = "NumpadSubtract";
|
|
1650
|
+
_UIEventsCode.Escape = "Escape";
|
|
1651
|
+
_UIEventsCode.F1 = "F1";
|
|
1652
|
+
_UIEventsCode.F2 = "F2";
|
|
1653
|
+
_UIEventsCode.F3 = "F3";
|
|
1654
|
+
_UIEventsCode.F4 = "F4";
|
|
1655
|
+
_UIEventsCode.F5 = "F5";
|
|
1656
|
+
_UIEventsCode.F6 = "F6";
|
|
1657
|
+
_UIEventsCode.F7 = "F7";
|
|
1658
|
+
_UIEventsCode.F8 = "F8";
|
|
1659
|
+
_UIEventsCode.F9 = "F9";
|
|
1660
|
+
_UIEventsCode.F10 = "F10";
|
|
1661
|
+
_UIEventsCode.F11 = "F11";
|
|
1662
|
+
_UIEventsCode.F12 = "F12";
|
|
1663
|
+
_UIEventsCode.Fn = "Fn";
|
|
1664
|
+
_UIEventsCode.FnLock = "FnLock";
|
|
1665
|
+
_UIEventsCode.PrintScreen = "PrintScreen";
|
|
1666
|
+
_UIEventsCode.ScrollLock = "ScrollLock";
|
|
1667
|
+
_UIEventsCode.Pause = "Pause";
|
|
1668
|
+
_UIEventsCode.BrowserBack = "BrowserBack";
|
|
1669
|
+
_UIEventsCode.BrowserFavorites = "BrowserFavorites";
|
|
1670
|
+
_UIEventsCode.BrowserForward = "BrowserForward";
|
|
1671
|
+
_UIEventsCode.BrowserHome = "BrowserHome";
|
|
1672
|
+
_UIEventsCode.BrowserRefresh = "BrowserRefresh";
|
|
1673
|
+
_UIEventsCode.BrowserSearch = "BrowserSearch";
|
|
1674
|
+
_UIEventsCode.BrowserStop = "BrowserStop";
|
|
1675
|
+
_UIEventsCode.Eject = "Eject";
|
|
1676
|
+
_UIEventsCode.LaunchApp1 = "LaunchApp1";
|
|
1677
|
+
_UIEventsCode.LaunchApp2 = "LaunchApp2";
|
|
1678
|
+
_UIEventsCode.LaunchMail = "LaunchMail";
|
|
1679
|
+
_UIEventsCode.MediaPlayPause = "MediaPlayPause";
|
|
1680
|
+
_UIEventsCode.MediaSelect = "MediaSelect";
|
|
1681
|
+
_UIEventsCode.MediaStop = "MediaStop";
|
|
1682
|
+
_UIEventsCode.MediaTrackNext = "MediaTrackNext";
|
|
1683
|
+
_UIEventsCode.MediaTrackPrevious = "MediaTrackPrevious";
|
|
1684
|
+
_UIEventsCode.Power = "Power";
|
|
1685
|
+
_UIEventsCode.Sleep = "Sleep";
|
|
1686
|
+
_UIEventsCode.AudioVolumeDown = "AudioVolumeDown";
|
|
1687
|
+
_UIEventsCode.AudioVolumeMute = "AudioVolumeMute";
|
|
1688
|
+
_UIEventsCode.AudioVolumeUp = "AudioVolumeUp";
|
|
1689
|
+
_UIEventsCode.WakeUp = "WakeUp";
|
|
1690
|
+
_UIEventsCode.Hyper = "Hyper";
|
|
1691
|
+
_UIEventsCode.Super = "Super";
|
|
1692
|
+
_UIEventsCode.Turbo = "Turbo";
|
|
1693
|
+
_UIEventsCode.Abort = "Abort";
|
|
1694
|
+
_UIEventsCode.Resume = "Resume";
|
|
1695
|
+
_UIEventsCode.Suspend = "Suspend";
|
|
1696
|
+
_UIEventsCode.Again = "Again";
|
|
1697
|
+
_UIEventsCode.Copy = "Copy";
|
|
1698
|
+
_UIEventsCode.Cut = "Cut";
|
|
1699
|
+
_UIEventsCode.Find = "Find";
|
|
1700
|
+
_UIEventsCode.Open = "Open";
|
|
1701
|
+
_UIEventsCode.Paste = "Paste";
|
|
1702
|
+
_UIEventsCode.Props = "Props";
|
|
1703
|
+
_UIEventsCode.Select = "Select";
|
|
1704
|
+
_UIEventsCode.Undo = "Undo";
|
|
1705
|
+
_UIEventsCode.Hiragana = "Hiragana";
|
|
1706
|
+
_UIEventsCode.Katakana = "Katakana";
|
|
1707
|
+
_UIEventsCode.Unidentified = "Unidentified";
|
|
1708
|
+
let UIEventsCode = _UIEventsCode;
|
|
1709
|
+
const KeyToCodeMap = /* @__PURE__ */ new Map([
|
|
1710
|
+
[UIEventsCode.Backquote, KeyEvent.KEYCODE_GRAVE],
|
|
1711
|
+
[UIEventsCode.Backslash, KeyEvent.KEYCODE_BACKSLASH],
|
|
1712
|
+
[UIEventsCode.BracketLeft, KeyEvent.KEYCODE_LEFT_BRACKET],
|
|
1713
|
+
[UIEventsCode.BracketRight, KeyEvent.KEYCODE_RIGHT_BRACKET],
|
|
1714
|
+
[UIEventsCode.Comma, KeyEvent.KEYCODE_COMMA],
|
|
1715
|
+
[UIEventsCode.Digit0, KeyEvent.KEYCODE_0],
|
|
1716
|
+
[UIEventsCode.Digit1, KeyEvent.KEYCODE_1],
|
|
1717
|
+
[UIEventsCode.Digit2, KeyEvent.KEYCODE_2],
|
|
1718
|
+
[UIEventsCode.Digit3, KeyEvent.KEYCODE_3],
|
|
1719
|
+
[UIEventsCode.Digit4, KeyEvent.KEYCODE_4],
|
|
1720
|
+
[UIEventsCode.Digit5, KeyEvent.KEYCODE_5],
|
|
1721
|
+
[UIEventsCode.Digit6, KeyEvent.KEYCODE_6],
|
|
1722
|
+
[UIEventsCode.Digit7, KeyEvent.KEYCODE_7],
|
|
1723
|
+
[UIEventsCode.Digit8, KeyEvent.KEYCODE_8],
|
|
1724
|
+
[UIEventsCode.Digit9, KeyEvent.KEYCODE_9],
|
|
1725
|
+
[UIEventsCode.Equal, KeyEvent.KEYCODE_EQUALS],
|
|
1726
|
+
[UIEventsCode.IntlRo, KeyEvent.KEYCODE_RO],
|
|
1727
|
+
[UIEventsCode.IntlYen, KeyEvent.KEYCODE_YEN],
|
|
1728
|
+
[UIEventsCode.KeyA, KeyEvent.KEYCODE_A],
|
|
1729
|
+
[UIEventsCode.KeyB, KeyEvent.KEYCODE_B],
|
|
1730
|
+
[UIEventsCode.KeyC, KeyEvent.KEYCODE_C],
|
|
1731
|
+
[UIEventsCode.KeyD, KeyEvent.KEYCODE_D],
|
|
1732
|
+
[UIEventsCode.KeyE, KeyEvent.KEYCODE_E],
|
|
1733
|
+
[UIEventsCode.KeyF, KeyEvent.KEYCODE_F],
|
|
1734
|
+
[UIEventsCode.KeyG, KeyEvent.KEYCODE_G],
|
|
1735
|
+
[UIEventsCode.KeyH, KeyEvent.KEYCODE_H],
|
|
1736
|
+
[UIEventsCode.KeyI, KeyEvent.KEYCODE_I],
|
|
1737
|
+
[UIEventsCode.KeyJ, KeyEvent.KEYCODE_J],
|
|
1738
|
+
[UIEventsCode.KeyK, KeyEvent.KEYCODE_K],
|
|
1739
|
+
[UIEventsCode.KeyL, KeyEvent.KEYCODE_L],
|
|
1740
|
+
[UIEventsCode.KeyM, KeyEvent.KEYCODE_M],
|
|
1741
|
+
[UIEventsCode.KeyN, KeyEvent.KEYCODE_N],
|
|
1742
|
+
[UIEventsCode.KeyO, KeyEvent.KEYCODE_O],
|
|
1743
|
+
[UIEventsCode.KeyP, KeyEvent.KEYCODE_P],
|
|
1744
|
+
[UIEventsCode.KeyQ, KeyEvent.KEYCODE_Q],
|
|
1745
|
+
[UIEventsCode.KeyR, KeyEvent.KEYCODE_R],
|
|
1746
|
+
[UIEventsCode.KeyS, KeyEvent.KEYCODE_S],
|
|
1747
|
+
[UIEventsCode.KeyT, KeyEvent.KEYCODE_T],
|
|
1748
|
+
[UIEventsCode.KeyU, KeyEvent.KEYCODE_U],
|
|
1749
|
+
[UIEventsCode.KeyV, KeyEvent.KEYCODE_V],
|
|
1750
|
+
[UIEventsCode.KeyW, KeyEvent.KEYCODE_W],
|
|
1751
|
+
[UIEventsCode.KeyX, KeyEvent.KEYCODE_X],
|
|
1752
|
+
[UIEventsCode.KeyY, KeyEvent.KEYCODE_Y],
|
|
1753
|
+
[UIEventsCode.KeyZ, KeyEvent.KEYCODE_Z],
|
|
1754
|
+
[UIEventsCode.Minus, KeyEvent.KEYCODE_MINUS],
|
|
1755
|
+
[UIEventsCode.Period, KeyEvent.KEYCODE_PERIOD],
|
|
1756
|
+
[UIEventsCode.Quote, KeyEvent.KEYCODE_APOSTROPHE],
|
|
1757
|
+
[UIEventsCode.Semicolon, KeyEvent.KEYCODE_SEMICOLON],
|
|
1758
|
+
[UIEventsCode.Slash, KeyEvent.KEYCODE_SLASH],
|
|
1759
|
+
[UIEventsCode.KanaMode, KeyEvent.KEYCODE_KANA],
|
|
1760
|
+
[UIEventsCode.Delete, KeyEvent.KEYCODE_FORWARD_DEL],
|
|
1761
|
+
[UIEventsCode.End, KeyEvent.KEYCODE_MOVE_END],
|
|
1762
|
+
[UIEventsCode.Help, KeyEvent.KEYCODE_HELP],
|
|
1763
|
+
[UIEventsCode.Home, KeyEvent.KEYCODE_MOVE_HOME],
|
|
1764
|
+
[UIEventsCode.Insert, KeyEvent.KEYCODE_INSERT],
|
|
1765
|
+
[UIEventsCode.PageDown, KeyEvent.KEYCODE_PAGE_DOWN],
|
|
1766
|
+
[UIEventsCode.PageUp, KeyEvent.KEYCODE_PAGE_UP],
|
|
1767
|
+
[UIEventsCode.AltLeft, KeyEvent.KEYCODE_ALT_LEFT],
|
|
1768
|
+
[UIEventsCode.AltRight, KeyEvent.KEYCODE_ALT_RIGHT],
|
|
1769
|
+
[UIEventsCode.Backspace, KeyEvent.KEYCODE_DEL],
|
|
1770
|
+
[UIEventsCode.CapsLock, KeyEvent.KEYCODE_CAPS_LOCK],
|
|
1771
|
+
[UIEventsCode.ControlLeft, KeyEvent.KEYCODE_CTRL_LEFT],
|
|
1772
|
+
[UIEventsCode.ControlRight, KeyEvent.KEYCODE_CTRL_RIGHT],
|
|
1773
|
+
[UIEventsCode.Enter, KeyEvent.KEYCODE_ENTER],
|
|
1774
|
+
[UIEventsCode.MetaLeft, KeyEvent.KEYCODE_META_LEFT],
|
|
1775
|
+
[UIEventsCode.MetaRight, KeyEvent.KEYCODE_META_RIGHT],
|
|
1776
|
+
[UIEventsCode.ShiftLeft, KeyEvent.KEYCODE_SHIFT_LEFT],
|
|
1777
|
+
[UIEventsCode.ShiftRight, KeyEvent.KEYCODE_SHIFT_RIGHT],
|
|
1778
|
+
[UIEventsCode.Space, KeyEvent.KEYCODE_SPACE],
|
|
1779
|
+
[UIEventsCode.Tab, KeyEvent.KEYCODE_TAB],
|
|
1780
|
+
[UIEventsCode.ArrowLeft, KeyEvent.KEYCODE_DPAD_LEFT],
|
|
1781
|
+
[UIEventsCode.ArrowUp, KeyEvent.KEYCODE_DPAD_UP],
|
|
1782
|
+
[UIEventsCode.ArrowRight, KeyEvent.KEYCODE_DPAD_RIGHT],
|
|
1783
|
+
[UIEventsCode.ArrowDown, KeyEvent.KEYCODE_DPAD_DOWN],
|
|
1784
|
+
[UIEventsCode.NumLock, KeyEvent.KEYCODE_NUM_LOCK],
|
|
1785
|
+
[UIEventsCode.Numpad0, KeyEvent.KEYCODE_NUMPAD_0],
|
|
1786
|
+
[UIEventsCode.Numpad1, KeyEvent.KEYCODE_NUMPAD_1],
|
|
1787
|
+
[UIEventsCode.Numpad2, KeyEvent.KEYCODE_NUMPAD_2],
|
|
1788
|
+
[UIEventsCode.Numpad3, KeyEvent.KEYCODE_NUMPAD_3],
|
|
1789
|
+
[UIEventsCode.Numpad4, KeyEvent.KEYCODE_NUMPAD_4],
|
|
1790
|
+
[UIEventsCode.Numpad5, KeyEvent.KEYCODE_NUMPAD_5],
|
|
1791
|
+
[UIEventsCode.Numpad6, KeyEvent.KEYCODE_NUMPAD_7],
|
|
1792
|
+
[UIEventsCode.Numpad8, KeyEvent.KEYCODE_NUMPAD_8],
|
|
1793
|
+
[UIEventsCode.Numpad9, KeyEvent.KEYCODE_NUMPAD_9],
|
|
1794
|
+
[UIEventsCode.NumpadAdd, KeyEvent.KEYCODE_NUMPAD_ADD],
|
|
1795
|
+
[UIEventsCode.NumpadComma, KeyEvent.KEYCODE_NUMPAD_COMMA],
|
|
1796
|
+
[UIEventsCode.NumpadDecimal, KeyEvent.KEYCODE_NUMPAD_DOT],
|
|
1797
|
+
[UIEventsCode.NumpadDivide, KeyEvent.KEYCODE_NUMPAD_DIVIDE],
|
|
1798
|
+
[UIEventsCode.NumpadEnter, KeyEvent.KEYCODE_NUMPAD_ENTER],
|
|
1799
|
+
[UIEventsCode.NumpadEqual, KeyEvent.KEYCODE_NUMPAD_EQUALS],
|
|
1800
|
+
[UIEventsCode.NumpadMultiply, KeyEvent.KEYCODE_NUMPAD_MULTIPLY],
|
|
1801
|
+
[UIEventsCode.NumpadParenLeft, KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN],
|
|
1802
|
+
[UIEventsCode.NumpadParenRight, KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN],
|
|
1803
|
+
[UIEventsCode.NumpadSubtract, KeyEvent.KEYCODE_NUMPAD_SUBTRACT],
|
|
1804
|
+
[UIEventsCode.Escape, KeyEvent.KEYCODE_ESCAPE],
|
|
1805
|
+
[UIEventsCode.F1, KeyEvent.KEYCODE_F1],
|
|
1806
|
+
[UIEventsCode.F2, KeyEvent.KEYCODE_F2],
|
|
1807
|
+
[UIEventsCode.F3, KeyEvent.KEYCODE_F3],
|
|
1808
|
+
[UIEventsCode.F4, KeyEvent.KEYCODE_F4],
|
|
1809
|
+
[UIEventsCode.F5, KeyEvent.KEYCODE_F5],
|
|
1810
|
+
[UIEventsCode.F6, KeyEvent.KEYCODE_F6],
|
|
1811
|
+
[UIEventsCode.F7, KeyEvent.KEYCODE_F7],
|
|
1812
|
+
[UIEventsCode.F8, KeyEvent.KEYCODE_F8],
|
|
1813
|
+
[UIEventsCode.F9, KeyEvent.KEYCODE_F9],
|
|
1814
|
+
[UIEventsCode.F10, KeyEvent.KEYCODE_F10],
|
|
1815
|
+
[UIEventsCode.F11, KeyEvent.KEYCODE_F11],
|
|
1816
|
+
[UIEventsCode.F12, KeyEvent.KEYCODE_F12],
|
|
1817
|
+
[UIEventsCode.Fn, KeyEvent.KEYCODE_FUNCTION],
|
|
1818
|
+
[UIEventsCode.PrintScreen, KeyEvent.KEYCODE_SYSRQ],
|
|
1819
|
+
[UIEventsCode.Pause, KeyEvent.KEYCODE_BREAK]
|
|
1820
|
+
]);
|
|
1821
|
+
const _KeyInputHandler = class _KeyInputHandler {
|
|
1822
|
+
static attachListeners() {
|
|
1823
|
+
document.body.addEventListener("keydown", this.handler);
|
|
1824
|
+
document.body.addEventListener("keyup", this.handler);
|
|
1825
|
+
}
|
|
1826
|
+
static detachListeners() {
|
|
1827
|
+
document.body.removeEventListener("keydown", this.handler);
|
|
1828
|
+
document.body.removeEventListener("keyup", this.handler);
|
|
1829
|
+
}
|
|
1830
|
+
static addEventListener(listener) {
|
|
1831
|
+
if (!this.listeners.size) {
|
|
1832
|
+
this.attachListeners();
|
|
1833
|
+
}
|
|
1834
|
+
this.listeners.add(listener);
|
|
1835
|
+
}
|
|
1836
|
+
static removeEventListener(listener) {
|
|
1837
|
+
this.listeners.delete(listener);
|
|
1838
|
+
if (!this.listeners.size) {
|
|
1839
|
+
this.detachListeners();
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
};
|
|
1843
|
+
_KeyInputHandler.repeatCounter = /* @__PURE__ */ new Map();
|
|
1844
|
+
_KeyInputHandler.listeners = /* @__PURE__ */ new Set();
|
|
1845
|
+
_KeyInputHandler.handler = (event) => {
|
|
1846
|
+
const keyboardEvent = event;
|
|
1847
|
+
const keyCode = KeyToCodeMap.get(keyboardEvent.code);
|
|
1848
|
+
if (!keyCode) {
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
let action;
|
|
1852
|
+
let repeatCount = 0;
|
|
1853
|
+
if (keyboardEvent.type === "keydown") {
|
|
1854
|
+
action = KeyEvent.ACTION_DOWN;
|
|
1855
|
+
if (keyboardEvent.repeat) {
|
|
1856
|
+
let count = _KeyInputHandler.repeatCounter.get(keyCode);
|
|
1857
|
+
if (typeof count !== "number") {
|
|
1858
|
+
count = 1;
|
|
1859
|
+
} else {
|
|
1860
|
+
count++;
|
|
1861
|
+
}
|
|
1862
|
+
repeatCount = count;
|
|
1863
|
+
_KeyInputHandler.repeatCounter.set(keyCode, count);
|
|
1864
|
+
}
|
|
1865
|
+
} else if (keyboardEvent.type === "keyup") {
|
|
1866
|
+
action = KeyEvent.ACTION_UP;
|
|
1867
|
+
_KeyInputHandler.repeatCounter.delete(keyCode);
|
|
1868
|
+
} else {
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
const metaState = (keyboardEvent.getModifierState("Alt") ? KeyEvent.META_ALT_ON : 0) | (keyboardEvent.getModifierState("Shift") ? KeyEvent.META_SHIFT_ON : 0) | (keyboardEvent.getModifierState("Control") ? KeyEvent.META_CTRL_ON : 0) | (keyboardEvent.getModifierState("Meta") ? KeyEvent.META_META_ON : 0) | (keyboardEvent.getModifierState("CapsLock") ? KeyEvent.META_CAPS_LOCK_ON : 0) | (keyboardEvent.getModifierState("ScrollLock") ? KeyEvent.META_SCROLL_LOCK_ON : 0) | (keyboardEvent.getModifierState("NumLock") ? KeyEvent.META_NUM_LOCK_ON : 0);
|
|
1872
|
+
const controlMessage = new KeyCodeControlMessage(
|
|
1873
|
+
action,
|
|
1874
|
+
keyCode,
|
|
1875
|
+
repeatCount,
|
|
1876
|
+
metaState
|
|
1877
|
+
);
|
|
1878
|
+
_KeyInputHandler.listeners.forEach((listener) => {
|
|
1879
|
+
listener.onKeyEvent(controlMessage);
|
|
1880
|
+
});
|
|
1881
|
+
event.preventDefault();
|
|
1882
|
+
};
|
|
1883
|
+
let KeyInputHandler = _KeyInputHandler;
|
|
1884
|
+
class Rect {
|
|
1885
|
+
constructor(left, top, right, bottom) {
|
|
1886
|
+
this.left = left;
|
|
1887
|
+
this.top = top;
|
|
1888
|
+
this.right = right;
|
|
1889
|
+
this.bottom = bottom;
|
|
1890
|
+
this.left = left;
|
|
1891
|
+
this.top = top;
|
|
1892
|
+
this.right = right;
|
|
1893
|
+
this.bottom = bottom;
|
|
1894
|
+
}
|
|
1895
|
+
static equals(a, b) {
|
|
1896
|
+
if (!a && !b) {
|
|
1897
|
+
return true;
|
|
1898
|
+
}
|
|
1899
|
+
return !!a && !!b && a.equals(b);
|
|
1900
|
+
}
|
|
1901
|
+
static copy(a) {
|
|
1902
|
+
if (!a) {
|
|
1903
|
+
return null;
|
|
1904
|
+
}
|
|
1905
|
+
return new Rect(a.left, a.top, a.right, a.bottom);
|
|
1906
|
+
}
|
|
1907
|
+
equals(o) {
|
|
1908
|
+
if (this === o) {
|
|
1909
|
+
return true;
|
|
1910
|
+
}
|
|
1911
|
+
if (!o) {
|
|
1912
|
+
return false;
|
|
1913
|
+
}
|
|
1914
|
+
return this.left === o.left && this.top === o.top && this.right === o.right && this.bottom === o.bottom;
|
|
1915
|
+
}
|
|
1916
|
+
getWidth() {
|
|
1917
|
+
return this.right - this.left;
|
|
1918
|
+
}
|
|
1919
|
+
getHeight() {
|
|
1920
|
+
return this.bottom - this.top;
|
|
1921
|
+
}
|
|
1922
|
+
toString() {
|
|
1923
|
+
return `Rect{left=${this.left}, top=${this.top}, right=${this.right}, bottom=${this.bottom}}`;
|
|
1924
|
+
}
|
|
1925
|
+
toJSON() {
|
|
1926
|
+
return {
|
|
1927
|
+
left: this.left,
|
|
1928
|
+
right: this.right,
|
|
1929
|
+
top: this.top,
|
|
1930
|
+
bottom: this.bottom
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
const _ScreenInfo = class _ScreenInfo {
|
|
1935
|
+
constructor(contentRect, videoSize, deviceRotation) {
|
|
1936
|
+
this.contentRect = contentRect;
|
|
1937
|
+
this.videoSize = videoSize;
|
|
1938
|
+
this.deviceRotation = deviceRotation;
|
|
1939
|
+
}
|
|
1940
|
+
static fromBuffer(buffer2) {
|
|
1941
|
+
const left = buffer2.readInt32BE(0);
|
|
1942
|
+
const top = buffer2.readInt32BE(4);
|
|
1943
|
+
const right = buffer2.readInt32BE(8);
|
|
1944
|
+
const bottom = buffer2.readInt32BE(12);
|
|
1945
|
+
const width = buffer2.readInt32BE(16);
|
|
1946
|
+
const height = buffer2.readInt32BE(20);
|
|
1947
|
+
const deviceRotation = buffer2.readUInt8(24);
|
|
1948
|
+
return new _ScreenInfo(new Rect(left, top, right, bottom), new Size(width, height), deviceRotation);
|
|
1949
|
+
}
|
|
1950
|
+
equals(o) {
|
|
1951
|
+
if (!o) {
|
|
1952
|
+
return false;
|
|
1953
|
+
}
|
|
1954
|
+
return this.contentRect.equals(o.contentRect) && this.videoSize.equals(o.videoSize) && this.deviceRotation === o.deviceRotation;
|
|
1955
|
+
}
|
|
1956
|
+
toString() {
|
|
1957
|
+
return `ScreenInfo{contentRect=${this.contentRect}, videoSize=${this.videoSize}, deviceRotation=${this.deviceRotation}}`;
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
_ScreenInfo.BUFFER_LENGTH = 25;
|
|
1961
|
+
let ScreenInfo = _ScreenInfo;
|
|
1962
|
+
exports.CommandControlMessage = CommandControlMessage;
|
|
1963
|
+
exports.ControlMessage = ControlMessage;
|
|
1964
|
+
exports.FeaturedInteractionHandler = FeaturedInteractionHandler;
|
|
1965
|
+
exports.FilePushState = FilePushState;
|
|
1966
|
+
exports.InteractionHandler = InteractionHandler;
|
|
1967
|
+
exports.KeyCodeControlMessage = KeyCodeControlMessage;
|
|
1968
|
+
exports.KeyEvent = KeyEvent;
|
|
1969
|
+
exports.KeyInputHandler = KeyInputHandler;
|
|
1970
|
+
exports.KeyToCodeMap = KeyToCodeMap;
|
|
1971
|
+
exports.MotionEvent = MotionEvent;
|
|
1972
|
+
exports.Point = Point;
|
|
1973
|
+
exports.Position = Position;
|
|
1974
|
+
exports.Rect = Rect;
|
|
1975
|
+
exports.ScreenInfo = ScreenInfo;
|
|
1976
|
+
exports.ScrollControlMessage = ScrollControlMessage;
|
|
1977
|
+
exports.SimpleInteractionHandler = SimpleInteractionHandler;
|
|
1978
|
+
exports.Size = Size;
|
|
1979
|
+
exports.TextControlMessage = TextControlMessage;
|
|
1980
|
+
exports.TouchControlMessage = TouchControlMessage;
|
|
1981
|
+
exports.UIEventsCode = UIEventsCode;
|
|
1982
|
+
exports.Util = Util;
|
|
1983
|
+
//# sourceMappingURL=index.cjs.js.map
|