interaction-system 1.0.0 → 1.0.1
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/dist/common/TypedEmitter.d.ts +20 -0
- package/dist/common/TypedEmitter.d.ts.map +1 -0
- package/dist/index.cjs.js +17 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +17 -15
- package/dist/index.es.js.map +1 -1
- package/dist/input/KeyInputHandler.d.ts.map +1 -1
- package/dist/interaction/FeaturedInteractionHandler.d.ts.map +1 -1
- package/dist/interaction/InteractionHandler.d.ts.map +1 -1
- package/dist/messages/KeyCodeControlMessage.d.ts.map +1 -1
- package/dist/messages/ScrollControlMessage.d.ts.map +1 -1
- package/dist/messages/TouchControlMessage.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -54,6 +54,7 @@ const _TouchControlMessage = class _TouchControlMessage extends ControlMessage {
|
|
|
54
54
|
toBuffer() {
|
|
55
55
|
const buffer = Buffer.alloc(_TouchControlMessage.PAYLOAD_LENGTH + 1);
|
|
56
56
|
let offset = 0;
|
|
57
|
+
offset = buffer.writeUInt8(0, offset);
|
|
57
58
|
offset = buffer.writeUInt8(this.type, offset);
|
|
58
59
|
offset = buffer.writeUInt8(this.action, offset);
|
|
59
60
|
offset = buffer.writeUInt32BE(0, offset);
|
|
@@ -63,6 +64,7 @@ const _TouchControlMessage = class _TouchControlMessage extends ControlMessage {
|
|
|
63
64
|
offset = buffer.writeUInt16BE(this.position.screenSize.width, offset);
|
|
64
65
|
offset = buffer.writeUInt16BE(this.position.screenSize.height, offset);
|
|
65
66
|
offset = buffer.writeUInt16BE(this.pressure * _TouchControlMessage.MAX_PRESSURE_VALUE, offset);
|
|
67
|
+
offset = buffer.writeUInt32BE(0, offset);
|
|
66
68
|
buffer.writeUInt32BE(this.buttons, offset);
|
|
67
69
|
return buffer;
|
|
68
70
|
}
|
|
@@ -80,7 +82,7 @@ const _TouchControlMessage = class _TouchControlMessage extends ControlMessage {
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
};
|
|
83
|
-
_TouchControlMessage.PAYLOAD_LENGTH = 28;
|
|
85
|
+
_TouchControlMessage.PAYLOAD_LENGTH = 28 + 4;
|
|
84
86
|
_TouchControlMessage.MAX_PRESSURE_VALUE = 65535;
|
|
85
87
|
let TouchControlMessage = _TouchControlMessage;
|
|
86
88
|
class Size {
|
|
@@ -684,14 +686,6 @@ const _InteractionHandler = class _InteractionHandler {
|
|
|
684
686
|
}
|
|
685
687
|
}
|
|
686
688
|
});
|
|
687
|
-
if (this.multiTouchActive) {
|
|
688
|
-
if (this.multiTouchCenter) {
|
|
689
|
-
this.drawCenter(this.multiTouchCenter);
|
|
690
|
-
}
|
|
691
|
-
points.forEach((point) => {
|
|
692
|
-
this.drawPointer(point);
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
689
|
const hasActionUp = messages.find((message) => {
|
|
696
690
|
return message.action === MotionEvent.ACTION_UP;
|
|
697
691
|
});
|
|
@@ -747,6 +741,7 @@ _InteractionHandler.onKeyEvent = (event) => {
|
|
|
747
741
|
};
|
|
748
742
|
let InteractionHandler = _InteractionHandler;
|
|
749
743
|
const _ScrollControlMessage = class _ScrollControlMessage extends ControlMessage {
|
|
744
|
+
// 1字节代表群控还是单控,后面4字节为底层需要填充
|
|
750
745
|
constructor(position, hScroll, vScroll) {
|
|
751
746
|
super(ControlMessage.TYPE_SCROLL);
|
|
752
747
|
this.position = position;
|
|
@@ -759,13 +754,15 @@ const _ScrollControlMessage = class _ScrollControlMessage extends ControlMessage
|
|
|
759
754
|
toBuffer() {
|
|
760
755
|
const buffer = Buffer.alloc(_ScrollControlMessage.PAYLOAD_LENGTH + 1);
|
|
761
756
|
let offset = 0;
|
|
757
|
+
offset = buffer.writeUInt8(0, offset);
|
|
762
758
|
offset = buffer.writeUInt8(this.type, offset);
|
|
763
759
|
offset = buffer.writeUInt32BE(this.position.point.x, offset);
|
|
764
760
|
offset = buffer.writeUInt32BE(this.position.point.y, offset);
|
|
765
761
|
offset = buffer.writeUInt16BE(this.position.screenSize.width, offset);
|
|
766
762
|
offset = buffer.writeUInt16BE(this.position.screenSize.height, offset);
|
|
767
|
-
offset = buffer.
|
|
768
|
-
buffer.
|
|
763
|
+
offset = buffer.writeInt16BE(this.hScroll, offset);
|
|
764
|
+
offset = buffer.writeInt16BE(this.vScroll, offset);
|
|
765
|
+
buffer.writeInt32BE(0, offset);
|
|
769
766
|
return buffer;
|
|
770
767
|
}
|
|
771
768
|
toString() {
|
|
@@ -780,7 +777,7 @@ const _ScrollControlMessage = class _ScrollControlMessage extends ControlMessage
|
|
|
780
777
|
};
|
|
781
778
|
}
|
|
782
779
|
};
|
|
783
|
-
_ScrollControlMessage.PAYLOAD_LENGTH =
|
|
780
|
+
_ScrollControlMessage.PAYLOAD_LENGTH = 21;
|
|
784
781
|
let ScrollControlMessage = _ScrollControlMessage;
|
|
785
782
|
const TAG$1 = "[FeaturedTouchHandler]";
|
|
786
783
|
const _FeaturedInteractionHandler = class _FeaturedInteractionHandler extends InteractionHandler {
|
|
@@ -808,8 +805,8 @@ const _FeaturedInteractionHandler = class _FeaturedInteractionHandler extends In
|
|
|
808
805
|
const messages = [];
|
|
809
806
|
const touchOnClient = InteractionHandler.buildTouchOnClient(event, screenInfo);
|
|
810
807
|
if (touchOnClient) {
|
|
811
|
-
const hScroll = event.deltaX > 0 ? -
|
|
812
|
-
const vScroll = event.deltaY > 0 ? -
|
|
808
|
+
const hScroll = event.deltaX > 0 ? -1e3 : event.deltaX < -0 ? 1e3 : 0;
|
|
809
|
+
const vScroll = event.deltaY > 0 ? -1e3 : event.deltaY < -0 ? 1e3 : 0;
|
|
813
810
|
const time = Date.now();
|
|
814
811
|
if (!this.lastScrollEvent || time - this.lastScrollEvent.time > _FeaturedInteractionHandler.SCROLL_EVENT_THROTTLING_TIME || this.lastScrollEvent.vScroll !== vScroll || this.lastScrollEvent.hScroll !== hScroll) {
|
|
815
812
|
this.lastScrollEvent = { time, hScroll, vScroll };
|
|
@@ -976,6 +973,7 @@ const _KeyCodeControlMessage = class _KeyCodeControlMessage extends ControlMessa
|
|
|
976
973
|
toBuffer() {
|
|
977
974
|
const buffer = Buffer.alloc(_KeyCodeControlMessage.PAYLOAD_LENGTH + 1);
|
|
978
975
|
let offset = 0;
|
|
976
|
+
offset = buffer.writeInt8(0, offset);
|
|
979
977
|
offset = buffer.writeInt8(this.type, offset);
|
|
980
978
|
offset = buffer.writeInt8(this.action, offset);
|
|
981
979
|
offset = buffer.writeInt32BE(this.keycode, offset);
|
|
@@ -996,7 +994,7 @@ const _KeyCodeControlMessage = class _KeyCodeControlMessage extends ControlMessa
|
|
|
996
994
|
};
|
|
997
995
|
}
|
|
998
996
|
};
|
|
999
|
-
_KeyCodeControlMessage.PAYLOAD_LENGTH = 13;
|
|
997
|
+
_KeyCodeControlMessage.PAYLOAD_LENGTH = 13 + 1;
|
|
1000
998
|
let KeyCodeControlMessage = _KeyCodeControlMessage;
|
|
1001
999
|
const _TextControlMessage = class _TextControlMessage extends ControlMessage {
|
|
1002
1000
|
constructor(text) {
|
|
@@ -1841,6 +1839,10 @@ const _KeyInputHandler = class _KeyInputHandler {
|
|
|
1841
1839
|
_KeyInputHandler.repeatCounter = /* @__PURE__ */ new Map();
|
|
1842
1840
|
_KeyInputHandler.listeners = /* @__PURE__ */ new Set();
|
|
1843
1841
|
_KeyInputHandler.handler = (event) => {
|
|
1842
|
+
const target = event.target;
|
|
1843
|
+
if (target instanceof HTMLElement && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT" || target.isContentEditable)) {
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1844
1846
|
const keyboardEvent = event;
|
|
1845
1847
|
const keyCode = KeyToCodeMap.get(keyboardEvent.code);
|
|
1846
1848
|
if (!keyCode) {
|