From 4ceca53d82cbe0ca4ead2691e51fbac2e67e4b0b Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 17 Aug 2023 04:05:44 +0800 Subject: [PATCH 01/28] =?UTF-8?q?=E6=96=B0=E5=A2=9E'=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=A7=A6=E6=8E=A7=E6=95=B0=E9=87=8F'=20?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95(=20touch-manager.ts)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 需要获取 当前有效的触控数量(按在屏幕上的手指数) 时使用. --- pal/input/touch-manager.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 6c4ec9a4bc2..b448b421326 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -124,6 +124,14 @@ class TouchManager { return touches; } + /** + * Get the number of touches. + * @returns + */ + public getTouchCount (): number { + return this._touchMap.size; + } + /** * Update the location and previous location of current touch ID. * @param touchID From 53cac1a89398b63c807d155a086e0360456cc593 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 17 Aug 2023 11:32:20 +0800 Subject: [PATCH 02/28] =?UTF-8?q?=E4=BD=BF=E7=94=A8ccLog=20=E4=BB=A3?= =?UTF-8?q?=E6=9B=BF=20console.log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pal/input/touch-manager.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index b448b421326..4b06b0effb2 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -22,9 +22,10 @@ THE SOFTWARE. */ +import { Vec2 } from '../../cocos/core/math/vec2'; +import { log as ccLog } from '../../cocos/core/platform/debug'; import { macro } from '../../cocos/core/platform/macro'; import { Touch } from '../../cocos/input/types'; -import { Vec2 } from '../../cocos/core/math/vec2'; const tempVec2 = new Vec2(); @@ -68,12 +69,12 @@ class TouchManager { */ private _createTouch (touchID: number, x: number, y: number): Touch | undefined { if (this._touchMap.has(touchID)) { - console.log('Cannot create the same touch object.'); + ccLog('Cannot create the same touch object.'); return undefined; } const checkResult = this._checkTouchMapSizeMoreThanMax(touchID); if (checkResult) { - console.log('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 + ccLog('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 return undefined; } const touch = new Touch(x, y, touchID); @@ -156,7 +157,7 @@ class TouchManager { const now = performance.now(); this._touchMap.forEach((touch) => { if (now - touch.lastModified > macro.TOUCH_TIMEOUT) { - console.log(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); + ccLog(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); // TODO: need to handle touch cancel event when exceed the max number of touches ? this.releaseTouch(touch.getID()); } From e95ea77e1b64e8afb71a8fe924c1e684bdc77fb8 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 17 Aug 2023 13:16:06 +0800 Subject: [PATCH 03/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 不依赖 ccLog ,直接禁用警告 --- pal/input/touch-manager.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 4b06b0effb2..ba255d46909 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -23,7 +23,6 @@ */ import { Vec2 } from '../../cocos/core/math/vec2'; -import { log as ccLog } from '../../cocos/core/platform/debug'; import { macro } from '../../cocos/core/platform/macro'; import { Touch } from '../../cocos/input/types'; @@ -69,12 +68,14 @@ class TouchManager { */ private _createTouch (touchID: number, x: number, y: number): Touch | undefined { if (this._touchMap.has(touchID)) { - ccLog('Cannot create the same touch object.'); + // eslint-disable-next-line no-console + console.log('Cannot create the same touch object.'); return undefined; } const checkResult = this._checkTouchMapSizeMoreThanMax(touchID); if (checkResult) { - ccLog('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 + // eslint-disable-next-line no-console + console.log('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 return undefined; } const touch = new Touch(x, y, touchID); @@ -157,7 +158,8 @@ class TouchManager { const now = performance.now(); this._touchMap.forEach((touch) => { if (now - touch.lastModified > macro.TOUCH_TIMEOUT) { - ccLog(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); + // eslint-disable-next-line no-console + console.log(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); // TODO: need to handle touch cancel event when exceed the max number of touches ? this.releaseTouch(touch.getID()); } From 7ea4a9c51bc09e827d89f3cc12e5235f406e7033 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 17 Aug 2023 13:20:15 +0800 Subject: [PATCH 04/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重新用回 ccLog --- pal/input/touch-manager.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index ba255d46909..4b06b0effb2 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -23,6 +23,7 @@ */ import { Vec2 } from '../../cocos/core/math/vec2'; +import { log as ccLog } from '../../cocos/core/platform/debug'; import { macro } from '../../cocos/core/platform/macro'; import { Touch } from '../../cocos/input/types'; @@ -68,14 +69,12 @@ class TouchManager { */ private _createTouch (touchID: number, x: number, y: number): Touch | undefined { if (this._touchMap.has(touchID)) { - // eslint-disable-next-line no-console - console.log('Cannot create the same touch object.'); + ccLog('Cannot create the same touch object.'); return undefined; } const checkResult = this._checkTouchMapSizeMoreThanMax(touchID); if (checkResult) { - // eslint-disable-next-line no-console - console.log('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 + ccLog('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 return undefined; } const touch = new Touch(x, y, touchID); @@ -158,8 +157,7 @@ class TouchManager { const now = performance.now(); this._touchMap.forEach((touch) => { if (now - touch.lastModified > macro.TOUCH_TIMEOUT) { - // eslint-disable-next-line no-console - console.log(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); + ccLog(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); // TODO: need to handle touch cancel event when exceed the max number of touches ? this.releaseTouch(touch.getID()); } From 4704c9864ea6ad71f159a35b9ae469fb6f88a0fb Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 28 Aug 2023 22:27:08 +0800 Subject: [PATCH 05/28] Update input.ts Add some proxy methods of touchManager for getting touche infomation --- cocos/input/input.ts | 47 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 3cc5c2d3899..12177d4cf3b 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -25,10 +25,10 @@ */ import { EDITOR_NOT_IN_PREVIEW, NATIVE } from 'internal:constants'; -import { TouchInputSource, MouseInputSource, KeyboardInputSource, AccelerometerInputSource, GamepadInputDevice, HandleInputDevice, HMDInputDevice, HandheldInputDevice } from 'pal/input'; +import { AccelerometerInputSource, GamepadInputDevice, HMDInputDevice, HandheldInputDevice, HandleInputDevice, KeyboardInputSource, MouseInputSource, TouchInputSource } from 'pal/input'; import { touchManager } from '../../pal/input/touch-manager'; -import { sys, EventTarget, error } from '../core'; -import { Event, EventAcceleration, EventGamepad, EventHandle, EventHandheld, EventHMD, EventKeyboard, EventMouse, EventTouch, Touch } from './types'; +import { EventTarget, error, sys } from '../core'; +import { Event, EventAcceleration, EventGamepad, EventHMD, EventHandheld, EventHandle, EventKeyboard, EventMouse, EventTouch, Touch } from './types'; import { InputEventType } from './types/event-enum'; export enum EventDispatcherPriority { @@ -63,9 +63,9 @@ class InputEventDispatcher implements IEventDispatcher { } const pointerEventTypeMap: Record = { - [InputEventType.MOUSE_DOWN]: InputEventType.TOUCH_START, - [InputEventType.MOUSE_MOVE]: InputEventType.TOUCH_MOVE, - [InputEventType.MOUSE_UP]: InputEventType.TOUCH_END, + [InputEventType.MOUSE_DOWN] : InputEventType.TOUCH_START, + [InputEventType.MOUSE_MOVE] : InputEventType.TOUCH_MOVE, + [InputEventType.MOUSE_UP] : InputEventType.TOUCH_END, }; export declare namespace Input { @@ -229,6 +229,41 @@ export class Input { } this._eventTarget.off(eventType, callback, target); } + + /** + * @en + * Get touch object by touch ID. + * @zh + * 通过 touch ID 获取 touch对象 + * @param touchID + * @returns + */ + public getTouch (touchID: number, x: number, y: number): Touch | undefined { + return touchManager.getTouch(touchID, x, y); + } + + /** + * @en + * Get all the current touches objects. + * @zh + * 获取当前所有的 touch对象. + * @returns + */ + public getAllTouches (): Touch[] { + return touchManager.getAllTouches(); + } + + /** + * @en + * Get the number of touches. + * @zh + * 获取当前touch对象的数量. + * @returns + */ + public getTouchCount (): number { + return touchManager.getTouchCount(); + } + /** * @en * Sets whether to enable the accelerometer event listener or not. From d71d01a1b6baf7a39463a689fcc383e827db0219 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:24:11 +0800 Subject: [PATCH 06/28] Update cocos/input/input.ts Co-authored-by: PP --- cocos/input/input.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 12177d4cf3b..1d3ae0063f8 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -247,7 +247,6 @@ export class Input { * Get all the current touches objects. * @zh * 获取当前所有的 touch对象. - * @returns */ public getAllTouches (): Touch[] { return touchManager.getAllTouches(); From d065abd8c5f34105fa9e2a4c8a28507cb7aeb54f Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:24:27 +0800 Subject: [PATCH 07/28] Update pal/input/touch-manager.ts Co-authored-by: PP --- pal/input/touch-manager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 4b06b0effb2..d77c04e65d4 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -127,7 +127,6 @@ class TouchManager { /** * Get the number of touches. - * @returns */ public getTouchCount (): number { return this._touchMap.size; From 5257833bc2591edc5a543a0bf2721f8c5f181656 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:24:40 +0800 Subject: [PATCH 08/28] Update cocos/input/input.ts Co-authored-by: PP --- cocos/input/input.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 1d3ae0063f8..05f0c80d294 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -257,7 +257,6 @@ export class Input { * Get the number of touches. * @zh * 获取当前touch对象的数量. - * @returns */ public getTouchCount (): number { return touchManager.getTouchCount(); From e6353794331fce9e40b043f586ea99503a424ff4 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:24:50 +0800 Subject: [PATCH 09/28] Update cocos/input/input.ts Co-authored-by: PP --- cocos/input/input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 05f0c80d294..8d1c4e9f853 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -246,7 +246,7 @@ export class Input { * @en * Get all the current touches objects. * @zh - * 获取当前所有的 touch对象. + * 获取当前所有的 touch 对象。 */ public getAllTouches (): Touch[] { return touchManager.getAllTouches(); From f82b924fcb45c6f36bf04348d5c82ad40378722a Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:25:05 +0800 Subject: [PATCH 10/28] Update cocos/input/input.ts Co-authored-by: PP --- cocos/input/input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 8d1c4e9f853..610400fe93a 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -256,7 +256,7 @@ export class Input { * @en * Get the number of touches. * @zh - * 获取当前touch对象的数量. + * 获取当前 touch 对象的数量。 */ public getTouchCount (): number { return touchManager.getTouchCount(); From 01ebb5914f0605f52b5bb3b8bbad3adca71b1100 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:31:12 +0800 Subject: [PATCH 11/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 直接通过 touchManager._touchMap 获取数据 --- cocos/input/input.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 610400fe93a..6f50153f83c 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -238,8 +238,8 @@ export class Input { * @param touchID * @returns */ - public getTouch (touchID: number, x: number, y: number): Touch | undefined { - return touchManager.getTouch(touchID, x, y); + public getTouch (touchID: number): Touch | undefined { + return touchManager._touchMap.get(touchID); } /** @@ -259,7 +259,7 @@ export class Input { * 获取当前 touch 对象的数量。 */ public getTouchCount (): number { - return touchManager.getTouchCount(); + return touchManager._touchMap.size; } /** From 2d38c7c7295517fa5aed516776636c5882d36149 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:32:27 +0800 Subject: [PATCH 12/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 _touchMap 暴露出去. 并且移除之前添加的 getTouchCount()方法 --- pal/input/touch-manager.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index d77c04e65d4..87bbd81a400 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -33,7 +33,7 @@ class TouchManager { /** * A map from touch ID to touch object. */ - private _touchMap: Map; + public _touchMap: Map; private readonly _maxTouches = 8; constructor () { @@ -125,13 +125,6 @@ class TouchManager { return touches; } - /** - * Get the number of touches. - */ - public getTouchCount (): number { - return this._touchMap.size; - } - /** * Update the location and previous location of current touch ID. * @param touchID From 2ab264e6a00a059a31ba1ef46d66e6e21769684f Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:34:33 +0800 Subject: [PATCH 13/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 直接使用 log() --- pal/input/touch-manager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 87bbd81a400..a003108b1c8 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -23,7 +23,7 @@ */ import { Vec2 } from '../../cocos/core/math/vec2'; -import { log as ccLog } from '../../cocos/core/platform/debug'; +import { log } from '../../cocos/core/platform/debug'; import { macro } from '../../cocos/core/platform/macro'; import { Touch } from '../../cocos/input/types'; @@ -69,12 +69,12 @@ class TouchManager { */ private _createTouch (touchID: number, x: number, y: number): Touch | undefined { if (this._touchMap.has(touchID)) { - ccLog('Cannot create the same touch object.'); + log('Cannot create the same touch object.'); return undefined; } const checkResult = this._checkTouchMapSizeMoreThanMax(touchID); if (checkResult) { - ccLog('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 + log('The touches is more than MAX_TOUCHES.'); // TODO: logID 2300 return undefined; } const touch = new Touch(x, y, touchID); @@ -149,7 +149,7 @@ class TouchManager { const now = performance.now(); this._touchMap.forEach((touch) => { if (now - touch.lastModified > macro.TOUCH_TIMEOUT) { - ccLog(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); + log(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); // TODO: need to handle touch cancel event when exceed the max number of touches ? this.releaseTouch(touch.getID()); } From ce3533f412e8bcfefcb997909fd0964f44c4dc1b Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 15:37:54 +0800 Subject: [PATCH 14/28] Update input.ts --- cocos/input/input.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 6f50153f83c..36bc82e77f4 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -63,9 +63,9 @@ class InputEventDispatcher implements IEventDispatcher { } const pointerEventTypeMap: Record = { - [InputEventType.MOUSE_DOWN] : InputEventType.TOUCH_START, - [InputEventType.MOUSE_MOVE] : InputEventType.TOUCH_MOVE, - [InputEventType.MOUSE_UP] : InputEventType.TOUCH_END, + [InputEventType.MOUSE_DOWN]: InputEventType.TOUCH_START, + [InputEventType.MOUSE_MOVE]: InputEventType.TOUCH_MOVE, + [InputEventType.MOUSE_UP]: InputEventType.TOUCH_END, }; export declare namespace Input { From 314026c31a7f5a972e03b199366544d68b6b8170 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 18:30:13 +0800 Subject: [PATCH 15/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 获得 touch对象时, 不克隆. --- cocos/input/input.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 36bc82e77f4..f48fbfefd4a 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -63,9 +63,9 @@ class InputEventDispatcher implements IEventDispatcher { } const pointerEventTypeMap: Record = { - [InputEventType.MOUSE_DOWN]: InputEventType.TOUCH_START, - [InputEventType.MOUSE_MOVE]: InputEventType.TOUCH_MOVE, - [InputEventType.MOUSE_UP]: InputEventType.TOUCH_END, + [InputEventType.MOUSE_DOWN] : InputEventType.TOUCH_START, + [InputEventType.MOUSE_MOVE] : InputEventType.TOUCH_MOVE, + [InputEventType.MOUSE_UP] : InputEventType.TOUCH_END, }; export declare namespace Input { @@ -244,12 +244,12 @@ export class Input { /** * @en - * Get all the current touches objects. + * Get all the current touches objects as array. * @zh - * 获取当前所有的 touch 对象。 + * 获取当前所有的 touch对象 的数组。 */ public getAllTouches (): Touch[] { - return touchManager.getAllTouches(); + return touchManager.getAllTouches(false); } /** From b02852904c4c498ef91a2d1c419e3926d11f019d Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 18:32:13 +0800 Subject: [PATCH 16/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增是否 克隆 touch对象的 参数. 不指定值时, 默认克隆 --- pal/input/touch-manager.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index a003108b1c8..260396e297e 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -100,26 +100,26 @@ class TouchManager { * @param touchID * @returns */ - public getTouch (touchID: number, x: number, y: number): Touch | undefined { + public getTouch (touchID: number, x: number, y: number, clone?: boolean): Touch | undefined { let touch = this._touchMap.get(touchID); if (!touch) { touch = this._createTouch(touchID, x, y); } else { this._updateTouch(touch, x, y); } - return touch ? this._cloneTouch(touch) : undefined; + return touch ? (clone === false ? touch : this._cloneTouch(touch)) : undefined; } /** * Get all the current touches objects. * @returns */ - public getAllTouches (): Touch[] { + public getAllTouches (clone?: boolean): Touch[] { const touches: Touch[] = []; this._touchMap.forEach((touch) => { if (touch) { - const clonedTouch = this._cloneTouch(touch); - touches.push(clonedTouch); + const _touch = clone === false ? touch : this._cloneTouch(touch); + touches.push(_touch); } }); return touches; From 13a659431e0488cc6ff99827093994d46382eac0 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 18:33:08 +0800 Subject: [PATCH 17/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 微调注释, 避免歧义 --- cocos/input/input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index f48fbfefd4a..25cb6d3c7bd 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -246,7 +246,7 @@ export class Input { * @en * Get all the current touches objects as array. * @zh - * 获取当前所有的 touch对象 的数组。 + * 获取当前 所有touch对象 的数组。 */ public getAllTouches (): Touch[] { return touchManager.getAllTouches(false); From 4e89fb9c3b8ca0d3dcf4ac18d5c8a7c03cac0838 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 18:35:56 +0800 Subject: [PATCH 18/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 格式化 --- cocos/input/input.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 25cb6d3c7bd..cd741e8a050 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -63,9 +63,9 @@ class InputEventDispatcher implements IEventDispatcher { } const pointerEventTypeMap: Record = { - [InputEventType.MOUSE_DOWN] : InputEventType.TOUCH_START, - [InputEventType.MOUSE_MOVE] : InputEventType.TOUCH_MOVE, - [InputEventType.MOUSE_UP] : InputEventType.TOUCH_END, + [InputEventType.MOUSE_DOWN]: InputEventType.TOUCH_START, + [InputEventType.MOUSE_MOVE]: InputEventType.TOUCH_MOVE, + [InputEventType.MOUSE_UP]: InputEventType.TOUCH_END, }; export declare namespace Input { From 048d80937e814058e1ff91d4b991d78f224fef92 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 18:38:22 +0800 Subject: [PATCH 19/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除多余的赋值操作 --- pal/input/touch-manager.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 260396e297e..2c3604572b3 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -118,8 +118,7 @@ class TouchManager { const touches: Touch[] = []; this._touchMap.forEach((touch) => { if (touch) { - const _touch = clone === false ? touch : this._cloneTouch(touch); - touches.push(_touch); + touches.push(clone === false ? touch : this._cloneTouch(touch)); } }); return touches; From 51bb57c178eee44e269bd4c15ff9bbcab6f6a732 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 18:58:26 +0800 Subject: [PATCH 20/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除无用的clone --- pal/input/touch-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 2c3604572b3..4e7a55a6e19 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -80,7 +80,7 @@ class TouchManager { const touch = new Touch(x, y, touchID); this._touchMap.set(touchID, touch); this._updateTouch(touch, x, y); - return this._cloneTouch(touch); + return touch; } /** From 0d0f1e743a22cfae6223897c2402e4cb2e2e7beb Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 19:18:45 +0800 Subject: [PATCH 21/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 `_cloneTouch()` 设置为public, 暴露给 input 使用. --- pal/input/touch-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 4e7a55a6e19..d237b274c81 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -45,7 +45,7 @@ class TouchManager { * @param touch * @returns */ - private _cloneTouch (touch: Touch): Touch { + public _cloneTouch (touch: Touch): Touch { const touchID = touch.getID(); touch.getStartLocation(tempVec2); const clonedTouch = new Touch(tempVec2.x, tempVec2.y, touchID); From f655b3a455f5304d637f5ec36b1834244eabd002 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 19:20:45 +0800 Subject: [PATCH 22/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在获取 touch 对象时, 可通过参数决定是否clone. --- cocos/input/input.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index cd741e8a050..0455a1ec9e2 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -234,12 +234,14 @@ export class Input { * @en * Get touch object by touch ID. * @zh - * 通过 touch ID 获取 touch对象 + * 通过 touch ID 获取 touch对象。 * @param touchID + * @param toucclonehID * @returns */ - public getTouch (touchID: number): Touch | undefined { - return touchManager._touchMap.get(touchID); + public getTouch (touchID: number, clone?: boolean): Touch | undefined { + const touch = touchManager._touchMap.get(touchID); + return touch ? (clone === false ? touch : touchManager._cloneTouch(touch)) : undefined; } /** @@ -248,8 +250,8 @@ export class Input { * @zh * 获取当前 所有touch对象 的数组。 */ - public getAllTouches (): Touch[] { - return touchManager.getAllTouches(false); + public getAllTouches (clone?: boolean): Touch[] { + return touchManager.getAllTouches(clone); } /** From fa6f9ac10d73de947ecf5f675fb426f71c0da931 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 29 Aug 2023 19:29:28 +0800 Subject: [PATCH 23/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新注释 --- cocos/input/input.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 0455a1ec9e2..daab5777f98 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -236,7 +236,7 @@ export class Input { * @zh * 通过 touch ID 获取 touch对象。 * @param touchID - * @param toucclonehID + * @param clone - Whether to clone touch object * @returns */ public getTouch (touchID: number, clone?: boolean): Touch | undefined { @@ -249,6 +249,7 @@ export class Input { * Get all the current touches objects as array. * @zh * 获取当前 所有touch对象 的数组。 + * @param clone - Whether to clone touch object */ public getAllTouches (clone?: boolean): Touch[] { return touchManager.getAllTouches(clone); From 0af10d2864f591f4d2b47ae8a571efdc157591ca Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 13:20:10 +0800 Subject: [PATCH 24/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化格式和类型定义. --- cocos/input/input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index daab5777f98..ff3dbaaa03a 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -62,7 +62,7 @@ class InputEventDispatcher implements IEventDispatcher { } } -const pointerEventTypeMap: Record = { +const pointerEventTypeMap: Record = { [InputEventType.MOUSE_DOWN]: InputEventType.TOUCH_START, [InputEventType.MOUSE_MOVE]: InputEventType.TOUCH_MOVE, [InputEventType.MOUSE_UP]: InputEventType.TOUCH_END, From 0084158df972670321eb60f2b9a8e141f1863e4f Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 20:32:41 +0800 Subject: [PATCH 25/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化格式 --- cocos/input/input.ts | 124 +++++++++++++++++++++++++++++-------------- 1 file changed, 84 insertions(+), 40 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index ff3dbaaa03a..ed235d195a0 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -73,24 +73,24 @@ export declare namespace Input { } interface InputEventMap { - [Input.EventType.MOUSE_DOWN]: (event: EventMouse) => void, - [Input.EventType.MOUSE_MOVE]: (event: EventMouse) => void, - [Input.EventType.MOUSE_UP]: (event: EventMouse) => void, - [Input.EventType.MOUSE_WHEEL]: (event: EventMouse) => void, - [Input.EventType.TOUCH_START]: (event: EventTouch) => void, - [Input.EventType.TOUCH_MOVE]: (event: EventTouch) => void, - [Input.EventType.TOUCH_END]: (event: EventTouch) => void, - [Input.EventType.TOUCH_CANCEL]: (event: EventTouch) => void, - [Input.EventType.KEY_DOWN]: (event: EventKeyboard) => void, - [Input.EventType.KEY_PRESSING]: (event: EventKeyboard) => void, - [Input.EventType.KEY_UP]: (event: EventKeyboard) => void, - [Input.EventType.DEVICEMOTION]: (event: EventAcceleration) => void, - [Input.EventType.GAMEPAD_CHANGE]: (event: EventGamepad) => void, - [Input.EventType.GAMEPAD_INPUT]: (event: EventGamepad) => void, - [Input.EventType.HANDLE_INPUT]: (event: EventHandle) => void, - [Input.EventType.HANDLE_POSE_INPUT]: (event: EventHandle) => void, - [Input.EventType.HMD_POSE_INPUT]: (event: EventHMD) => void, - [Input.EventType.HANDHELD_POSE_INPUT]: (event: EventHandheld) => void, + [Input.EventType.MOUSE_DOWN]: (event: EventMouse)=> void, + [Input.EventType.MOUSE_MOVE]: (event: EventMouse)=> void, + [Input.EventType.MOUSE_UP]: (event: EventMouse)=> void, + [Input.EventType.MOUSE_WHEEL]: (event: EventMouse)=> void, + [Input.EventType.TOUCH_START]: (event: EventTouch)=> void, + [Input.EventType.TOUCH_MOVE]: (event: EventTouch)=> void, + [Input.EventType.TOUCH_END]: (event: EventTouch)=> void, + [Input.EventType.TOUCH_CANCEL]: (event: EventTouch)=> void, + [Input.EventType.KEY_DOWN]: (event: EventKeyboard)=> void, + [Input.EventType.KEY_PRESSING]: (event: EventKeyboard)=> void, + [Input.EventType.KEY_UP]: (event: EventKeyboard)=> void, + [Input.EventType.DEVICEMOTION]: (event: EventAcceleration)=> void, + [Input.EventType.GAMEPAD_CHANGE]: (event: EventGamepad)=> void, + [Input.EventType.GAMEPAD_INPUT]: (event: EventGamepad)=> void, + [Input.EventType.HANDLE_INPUT]: (event: EventHandle)=> void, + [Input.EventType.HANDLE_POSE_INPUT]: (event: EventHandle)=> void, + [Input.EventType.HMD_POSE_INPUT]: (event: EventHMD)=> void, + [Input.EventType.HANDHELD_POSE_INPUT]: (event: EventHandheld)=> void, } /** @@ -160,28 +160,40 @@ export class Input { /** * This should be a private method, but it's exposed for Editor Only. */ - private _dispatchMouseDownEvent (nativeMouseEvent: any): void { this._mouseInput.dispatchMouseDownEvent?.(nativeMouseEvent); } + private _dispatchMouseDownEvent (nativeMouseEvent: any): void { + this._mouseInput.dispatchMouseDownEvent?.(nativeMouseEvent); + } /** * This should be a private method, but it's exposed for Editor Only. */ - private _dispatchMouseMoveEvent (nativeMouseEvent: any): void { this._mouseInput.dispatchMouseMoveEvent?.(nativeMouseEvent); } + private _dispatchMouseMoveEvent (nativeMouseEvent: any): void { + this._mouseInput.dispatchMouseMoveEvent?.(nativeMouseEvent); + } /** * This should be a private method, but it's exposed for Editor Only. */ - private _dispatchMouseUpEvent (nativeMouseEvent: any): void { this._mouseInput.dispatchMouseUpEvent?.(nativeMouseEvent); } + private _dispatchMouseUpEvent (nativeMouseEvent: any): void { + this._mouseInput.dispatchMouseUpEvent?.(nativeMouseEvent); + } /** * This should be a private method, but it's exposed for Editor Only. */ - private _dispatchMouseScrollEvent (nativeMouseEvent: any): void { this._mouseInput.dispatchScrollEvent?.(nativeMouseEvent); } + private _dispatchMouseScrollEvent (nativeMouseEvent: any): void { + this._mouseInput.dispatchScrollEvent?.(nativeMouseEvent); + } /** * This should be a private method, but it's exposed for Editor Only. */ - private _dispatchKeyboardDownEvent (nativeKeyboardEvent: any): void { this._keyboardInput.dispatchKeyboardDownEvent?.(nativeKeyboardEvent); } + private _dispatchKeyboardDownEvent (nativeKeyboardEvent: any): void { + this._keyboardInput.dispatchKeyboardDownEvent?.(nativeKeyboardEvent); + } /** * This should be a private method, but it's exposed for Editor Only. */ - private _dispatchKeyboardUpEvent (nativeKeyboardEvent: any): void { this._keyboardInput.dispatchKeyboardUpEvent?.(nativeKeyboardEvent); } + private _dispatchKeyboardUpEvent (nativeKeyboardEvent: any): void { + this._keyboardInput.dispatchKeyboardUpEvent?.(nativeKeyboardEvent); + } /** * @en @@ -340,10 +352,18 @@ export class Input { private _registerEvent (): void { if (sys.hasFeature(sys.Feature.INPUT_TOUCH)) { const eventTouchList = this._eventTouchList; - this._touchInput.on(InputEventType.TOUCH_START, (event): void => { this._dispatchOrPushEventTouch(event, eventTouchList); }); - this._touchInput.on(InputEventType.TOUCH_MOVE, (event): void => { this._dispatchOrPushEventTouch(event, eventTouchList); }); - this._touchInput.on(InputEventType.TOUCH_END, (event): void => { this._dispatchOrPushEventTouch(event, eventTouchList); }); - this._touchInput.on(InputEventType.TOUCH_CANCEL, (event): void => { this._dispatchOrPushEventTouch(event, eventTouchList); }); + this._touchInput.on(InputEventType.TOUCH_START, (event): void => { + this._dispatchOrPushEventTouch(event, eventTouchList); + }); + this._touchInput.on(InputEventType.TOUCH_MOVE, (event): void => { + this._dispatchOrPushEventTouch(event, eventTouchList); + }); + this._touchInput.on(InputEventType.TOUCH_END, (event): void => { + this._dispatchOrPushEventTouch(event, eventTouchList); + }); + this._touchInput.on(InputEventType.TOUCH_CANCEL, (event): void => { + this._dispatchOrPushEventTouch(event, eventTouchList); + }); } if (sys.hasFeature(sys.Feature.EVENT_MOUSE)) { @@ -364,42 +384,66 @@ export class Input { this._simulateEventTouch(event); this._dispatchOrPushEvent(event, eventMouseList); }); - this._mouseInput.on(InputEventType.MOUSE_WHEEL, (event): void => { this._dispatchOrPushEvent(event, eventMouseList); }); + this._mouseInput.on(InputEventType.MOUSE_WHEEL, (event): void => { + this._dispatchOrPushEvent(event, eventMouseList); + }); } if (sys.hasFeature(sys.Feature.EVENT_KEYBOARD)) { const eventKeyboardList = this._eventKeyboardList; - this._keyboardInput.on(InputEventType.KEY_DOWN, (event): void => { this._dispatchOrPushEvent(event, eventKeyboardList); }); - this._keyboardInput.on(InputEventType.KEY_PRESSING, (event): void => { this._dispatchOrPushEvent(event, eventKeyboardList); }); - this._keyboardInput.on(InputEventType.KEY_UP, (event): void => { this._dispatchOrPushEvent(event, eventKeyboardList); }); + this._keyboardInput.on(InputEventType.KEY_DOWN, (event): void => { + this._dispatchOrPushEvent(event, eventKeyboardList); + }); + this._keyboardInput.on(InputEventType.KEY_PRESSING, (event): void => { + this._dispatchOrPushEvent(event, eventKeyboardList); + }); + this._keyboardInput.on(InputEventType.KEY_UP, (event): void => { + this._dispatchOrPushEvent(event, eventKeyboardList); + }); } if (sys.hasFeature(sys.Feature.EVENT_ACCELEROMETER)) { const eventAccelerationList = this._eventAccelerationList; - this._accelerometerInput.on(InputEventType.DEVICEMOTION, (event): void => { this._dispatchOrPushEvent(event, eventAccelerationList); }); + this._accelerometerInput.on(InputEventType.DEVICEMOTION, (event): void => { + this._dispatchOrPushEvent(event, eventAccelerationList); + }); } if (sys.hasFeature(sys.Feature.EVENT_GAMEPAD)) { const eventGamepadList = this._eventGamepadList; - GamepadInputDevice._on(InputEventType.GAMEPAD_CHANGE, (event): void => { this._dispatchOrPushEvent(event, eventGamepadList); }); - GamepadInputDevice._on(InputEventType.GAMEPAD_INPUT, (event): void => { this._dispatchOrPushEvent(event, eventGamepadList); }); - GamepadInputDevice._on(InputEventType.HANDLE_POSE_INPUT, (event): void => { this._dispatchOrPushEvent(event, eventGamepadList); }); + GamepadInputDevice._on(InputEventType.GAMEPAD_CHANGE, (event): void => { + this._dispatchOrPushEvent(event, eventGamepadList); + }); + GamepadInputDevice._on(InputEventType.GAMEPAD_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventGamepadList); + }); + GamepadInputDevice._on(InputEventType.HANDLE_POSE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventGamepadList); + }); } if (sys.hasFeature(sys.Feature.EVENT_HANDLE)) { const eventHandleList = this._eventHandleList; - this._handleInput._on(InputEventType.HANDLE_INPUT, (event): void => { this._dispatchOrPushEvent(event, eventHandleList); }); - this._handleInput._on(InputEventType.HANDLE_POSE_INPUT, (event): void => { this._dispatchOrPushEvent(event, eventHandleList); }); + this._handleInput._on(InputEventType.HANDLE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHandleList); + }); + this._handleInput._on(InputEventType.HANDLE_POSE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHandleList); + }); } if (sys.hasFeature(sys.Feature.EVENT_HMD)) { const eventHMDList = this._eventHMDList; - this._hmdInput._on(InputEventType.HMD_POSE_INPUT, (event): void => { this._dispatchOrPushEvent(event, eventHMDList); }); + this._hmdInput._on(InputEventType.HMD_POSE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHMDList); + }); } if (sys.hasFeature(sys.Feature.EVENT_HANDHELD)) { const eventHandheldList = this._eventHandheldList; - this._handheldInput._on(InputEventType.HANDHELD_POSE_INPUT, (event): void => { this._dispatchOrPushEvent(event, eventHandheldList); }); + this._handheldInput._on(InputEventType.HANDHELD_POSE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHandheldList); + }); } } From a1796e69bc5041ab4ab0aa784521b930cdea40c6 Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 20:40:24 +0800 Subject: [PATCH 26/28] Update input.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 格式化 --- cocos/input/input.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cocos/input/input.ts b/cocos/input/input.ts index ed235d195a0..adf42999aea 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -73,24 +73,24 @@ export declare namespace Input { } interface InputEventMap { - [Input.EventType.MOUSE_DOWN]: (event: EventMouse)=> void, - [Input.EventType.MOUSE_MOVE]: (event: EventMouse)=> void, - [Input.EventType.MOUSE_UP]: (event: EventMouse)=> void, - [Input.EventType.MOUSE_WHEEL]: (event: EventMouse)=> void, - [Input.EventType.TOUCH_START]: (event: EventTouch)=> void, - [Input.EventType.TOUCH_MOVE]: (event: EventTouch)=> void, - [Input.EventType.TOUCH_END]: (event: EventTouch)=> void, - [Input.EventType.TOUCH_CANCEL]: (event: EventTouch)=> void, - [Input.EventType.KEY_DOWN]: (event: EventKeyboard)=> void, - [Input.EventType.KEY_PRESSING]: (event: EventKeyboard)=> void, - [Input.EventType.KEY_UP]: (event: EventKeyboard)=> void, - [Input.EventType.DEVICEMOTION]: (event: EventAcceleration)=> void, - [Input.EventType.GAMEPAD_CHANGE]: (event: EventGamepad)=> void, - [Input.EventType.GAMEPAD_INPUT]: (event: EventGamepad)=> void, - [Input.EventType.HANDLE_INPUT]: (event: EventHandle)=> void, - [Input.EventType.HANDLE_POSE_INPUT]: (event: EventHandle)=> void, - [Input.EventType.HMD_POSE_INPUT]: (event: EventHMD)=> void, - [Input.EventType.HANDHELD_POSE_INPUT]: (event: EventHandheld)=> void, + [Input.EventType.MOUSE_DOWN]: (event: EventMouse) => void, + [Input.EventType.MOUSE_MOVE]: (event: EventMouse) => void, + [Input.EventType.MOUSE_UP]: (event: EventMouse) => void, + [Input.EventType.MOUSE_WHEEL]: (event: EventMouse) => void, + [Input.EventType.TOUCH_START]: (event: EventTouch) => void, + [Input.EventType.TOUCH_MOVE]: (event: EventTouch) => void, + [Input.EventType.TOUCH_END]: (event: EventTouch) => void, + [Input.EventType.TOUCH_CANCEL]: (event: EventTouch) => void, + [Input.EventType.KEY_DOWN]: (event: EventKeyboard) => void, + [Input.EventType.KEY_PRESSING]: (event: EventKeyboard) => void, + [Input.EventType.KEY_UP]: (event: EventKeyboard) => void, + [Input.EventType.DEVICEMOTION]: (event: EventAcceleration) => void, + [Input.EventType.GAMEPAD_CHANGE]: (event: EventGamepad) => void, + [Input.EventType.GAMEPAD_INPUT]: (event: EventGamepad) => void, + [Input.EventType.HANDLE_INPUT]: (event: EventHandle) => void, + [Input.EventType.HANDLE_POSE_INPUT]: (event: EventHandle) => void, + [Input.EventType.HMD_POSE_INPUT]: (event: EventHMD) => void, + [Input.EventType.HANDHELD_POSE_INPUT]: (event: EventHandheld) => void, } /** From d083b1ff8a5633bf423f61b47495d8baf1acc68b Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 11:17:23 +0800 Subject: [PATCH 27/28] Update touch-manager.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化格式 --- pal/input/touch-manager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index d237b274c81..d536f056e73 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -116,7 +116,7 @@ class TouchManager { */ public getAllTouches (clone?: boolean): Touch[] { const touches: Touch[] = []; - this._touchMap.forEach((touch) => { + this._touchMap.forEach(touch => { if (touch) { touches.push(clone === false ? touch : this._cloneTouch(touch)); } @@ -146,7 +146,7 @@ class TouchManager { } // Handle when exceed the max number of touches const now = performance.now(); - this._touchMap.forEach((touch) => { + this._touchMap.forEach(touch => { if (now - touch.lastModified > macro.TOUCH_TIMEOUT) { log(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); // TODO: need to handle touch cancel event when exceed the max number of touches ? From 8547feac013f745ee07d137bc6b1c404488ae186 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 15:36:14 +0800 Subject: [PATCH 28/28] Update touch-manager.ts --- pal/input/touch-manager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index d536f056e73..d237b274c81 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -116,7 +116,7 @@ class TouchManager { */ public getAllTouches (clone?: boolean): Touch[] { const touches: Touch[] = []; - this._touchMap.forEach(touch => { + this._touchMap.forEach((touch) => { if (touch) { touches.push(clone === false ? touch : this._cloneTouch(touch)); } @@ -146,7 +146,7 @@ class TouchManager { } // Handle when exceed the max number of touches const now = performance.now(); - this._touchMap.forEach(touch => { + this._touchMap.forEach((touch) => { if (now - touch.lastModified > macro.TOUCH_TIMEOUT) { log(`The touches is more than MAX_TOUCHES, release touch id ${touch.getID()}.`); // TODO: need to handle touch cancel event when exceed the max number of touches ?