From a079fd198c271a8e9598fe13474418a02726734d Mon Sep 17 00:00:00 2001 From: oahc09 Date: Thu, 21 Sep 2023 09:31:41 +0800 Subject: [PATCH] fix:eslint problem --- pal/input/native/handle-input.ts | 38 ++++++++++++++++++-------------- pal/input/web/handle-input.ts | 12 +++++----- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/pal/input/native/handle-input.ts b/pal/input/native/handle-input.ts index f253fa00fd0..2cb0b063e9c 100644 --- a/pal/input/native/handle-input.ts +++ b/pal/input/native/handle-input.ts @@ -78,7 +78,7 @@ enum StickKeyCode { START, TRIGGER_LEFT, TRIGGER_RIGHT, -}; +} enum StickAxisCode { UNDEFINE = 0, @@ -98,7 +98,7 @@ enum StickAxisCode { RIGHT_TRIGGER, LEFT_THUMBSTICK, RIGHT_THUMBSTICK, -}; +} interface IPoseValue { position: Vec3; @@ -246,7 +246,7 @@ export class HandleInputDevice { [Pose.HAND_RIGHT]: { position: Vec3.ZERO, orientation: Quat.IDENTITY }, [Pose.AIM_LEFT]: { position: Vec3.ZERO, orientation: Quat.IDENTITY }, [Pose.AIM_RIGHT]: { position: Vec3.ZERO, orientation: Quat.IDENTITY }, - } + }; constructor () { this._initInputSource(); @@ -357,20 +357,24 @@ export class HandleInputDevice { private _updateNativePoseState (info: jsb.PoseInfo): void { switch (info.code) { - case 1: - this._nativePoseState[Pose.HAND_LEFT] = { position: new Vec3(info.x, info.y, info.z), orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; - break; - case 2: - this._nativePoseState[Pose.AIM_LEFT] = { position: new Vec3(info.x, info.y, info.z), orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; - break; - case 4: - this._nativePoseState[Pose.HAND_RIGHT] = { position: new Vec3(info.x, info.y, info.z), orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; - break; - case 5: - this._nativePoseState[Pose.AIM_RIGHT] = { position: new Vec3(info.x, info.y, info.z), orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; - break; - default: - break; + case 1: + this._nativePoseState[Pose.HAND_LEFT] = { position: new Vec3(info.x, info.y, info.z), + orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; + break; + case 2: + this._nativePoseState[Pose.AIM_LEFT] = { position: new Vec3(info.x, info.y, info.z), + orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; + break; + case 4: + this._nativePoseState[Pose.HAND_RIGHT] = { position: new Vec3(info.x, info.y, info.z), + orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; + break; + case 5: + this._nativePoseState[Pose.AIM_RIGHT] = { position: new Vec3(info.x, info.y, info.z), + orientation: new Quat(info.quaternionX, info.quaternionY, info.quaternionZ, info.quaternionW) }; + break; + default: + break; } } diff --git a/pal/input/web/handle-input.ts b/pal/input/web/handle-input.ts index 278a77ca5d8..875c644975a 100644 --- a/pal/input/web/handle-input.ts +++ b/pal/input/web/handle-input.ts @@ -76,7 +76,7 @@ enum StickKeyCode { START, TRIGGER_LEFT, TRIGGER_RIGHT, -}; +} enum StickAxisCode { UNDEFINE = 0, @@ -96,7 +96,7 @@ enum StickAxisCode { RIGHT_TRIGGER, LEFT_THUMBSTICK, RIGHT_THUMBSTICK, -}; +} const _nativeButtonMap = { 1: Button.BUTTON_EAST, @@ -238,9 +238,9 @@ export class HandleInputDevice { window.addEventListener('xr-remote-input', (evt: Event): void => { const remoteInputEvent: CustomEvent = evt as CustomEvent; const keyEventType: KeyEventType = remoteInputEvent.detail.keyEventType; - const stickAxisCode = remoteInputEvent.detail.stickAxisCode; - const stickAxisValue = remoteInputEvent.detail.stickAxisValue; - const stickKeyCode = remoteInputEvent.detail.stickKeyCode; + const stickAxisCode = remoteInputEvent.detail.stickAxisCode as StickAxisCode; + const stickAxisValue = remoteInputEvent.detail.stickAxisValue as number; + const stickKeyCode = remoteInputEvent.detail.stickKeyCode as number; const isButtonPressed = remoteInputEvent.detail.isButtonPressed; if (keyEventType === KeyEventType.KET_CLICK) { @@ -293,7 +293,7 @@ export class HandleInputDevice { case StickAxisCode.LEFT_THUMBSTICK: case StickAxisCode.RIGHT_THUMBSTICK: this._nativeTouchState[stickAxisCode] = stickAxisValue; - break; + break; default: break; }