From 05abe65130316d600dbfbb37e8ca5a4995161bf9 Mon Sep 17 00:00:00 2001 From: zouxing23899 Date: Mon, 22 Jan 2024 09:47:22 +0800 Subject: [PATCH 1/2] add joystick event that Signed-off-by: zouxing23899 Signed-off-by: zouxing23899 --- ...ohos.multimodalInput.inputEventClient.d.ts | 34 ++ api/@ohos.multimodalInput.inputMonitor.d.ts | 33 +- api/@ohos.multimodalInput.joystickEvent.d.ts | 466 ++++++++++++++++++ 3 files changed, 532 insertions(+), 1 deletion(-) create mode 100755 api/@ohos.multimodalInput.joystickEvent.d.ts diff --git a/api/@ohos.multimodalInput.inputEventClient.d.ts b/api/@ohos.multimodalInput.inputEventClient.d.ts index b69bbb3e86..98e06151bb 100644 --- a/api/@ohos.multimodalInput.inputEventClient.d.ts +++ b/api/@ohos.multimodalInput.inputEventClient.d.ts @@ -20,6 +20,8 @@ import { MouseEvent } from './@ohos.multimodalInput.mouseEvent'; import { TouchEvent } from './@ohos.multimodalInput.touchEvent'; +import { JoystickEvent } from './@ohos.multimodalInput.joystickEvent'; + /** * Global Key Event Injection * @@ -135,6 +137,26 @@ declare namespace inputEventClient { keyEvent: KeyEvent; } + /** + * Defines event of joystick that user want to inject. + * + * @interface JoystickEventData + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 12 + */ + interface JoystickEventData { + /** + * Inject joystick event. + * + * @type { KeyEvent } + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 12 + */ + joystickEvent: JoystickEvent; + } + /** * Inject system keys. * @@ -181,6 +203,18 @@ declare namespace inputEventClient { * @since 11 */ function injectTouchEvent(touchEvent: TouchEventData): void; + + /** + * Inject joystick event. + * + * @param { JoystickEventData } joystickEvent - the joystick event to be injected. + * @throws { BusinessError } 202 - SystemAPI permission error. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 12 + */ + function injectJoystickEvent(joystickEvent: JoystickEventData): void; } export default inputEventClient; diff --git a/api/@ohos.multimodalInput.inputMonitor.d.ts b/api/@ohos.multimodalInput.inputMonitor.d.ts index 56634785b4..f092cb0b73 100644 --- a/api/@ohos.multimodalInput.inputMonitor.d.ts +++ b/api/@ohos.multimodalInput.inputMonitor.d.ts @@ -24,7 +24,7 @@ import type display from './@ohos.display'; import type { TouchEvent } from './@ohos.multimodalInput.touchEvent'; import type { Rotate, Pinch, ThreeFingersSwipe, FourFingersSwipe } from './@ohos.multimodalInput.gestureEvent'; import type { ThreeFingersTap } from './@ohos.multimodalInput.gestureEvent'; - +import { JoystickEvent } from './@ohos.multimodalInput.joystickEvent'; /** * Global input event listener * System API, available only to system processes @@ -315,5 +315,36 @@ declare namespace inputMonitor { */ function off(type: 'threeFingersTap', receiver?: Callback): void; + /** + * Listens for joystick events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param { 'joystick' } type - Event type, which is **joystick**. + * @param { Callback } receiver - Callback used to receive the reported data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - SystemAPI permit error. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.MultimodalInput.Input.InputMonitor + * @systemapi hide for inner use + * @since 12 + */ + function on(type: 'joystick', receiver: Callback): void; + + /** + * Cancel listening for touchPad pinch events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param { 'joystick' } type - Event type, which is **joystick**. + * @param { Callback } receiver - Callback used to receive the reported data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - SystemAPI permit error. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.MultimodalInput.Input.InputMonitor + * @systemapi hide for inner use + * @since 12 + */ + function off(type: 'joystick', receiver?: Callback): void; + + } export default inputMonitor; diff --git a/api/@ohos.multimodalInput.joystickEvent.d.ts b/api/@ohos.multimodalInput.joystickEvent.d.ts new file mode 100755 index 0000000000..c3abc0596c --- /dev/null +++ b/api/@ohos.multimodalInput.joystickEvent.d.ts @@ -0,0 +1,466 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit InputKit + */ + +import type { InputEvent } from './@ohos.multimodalInput.inputEvent'; + +/** + * Action + * + * @enum { number } + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +export declare enum Action { + /** + * Cancel + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + CANCEL = 0, + + /** + * Pressing down of the joystick buttom + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BUTTON_DOWN = 1, + + /** + * Lifting of the joystick button + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BUTTON_UP = 2, + + /** + * Beginning of the axis event associated with the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + AXIS_BEGIN = 3, + + /** + * Updating of the axis event associated with the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + AXIS_UPDATE = 4, + + /** + * Ending of the axis event associated with the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + AXIS_END = 5 +} + +/** + * joystick button + * + * @enum { number } + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +export declare enum Button { + /** + * TL2 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + TL2 = 0, + + /** + * TR2 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + TR2 = 1, + + /** + * TL button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + TL = 2, + + /** + * TR button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + TR = 3, + + /** + * West button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + WEST = 4, + + /** + * South button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + SOUTH = 5, + + /** + * North button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + NORTH = 6, + + /** + * East button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + EAST = 7, + + /** + * Start button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + START = 8, + + /** + * Select button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + SELECT = 9, + + /** + * HomePage button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + HOMEPAGE = 10, + + /** + * Thumbl button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + THUMBL = 11, + + /** + * Thumbr button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + THUMBR = 12, + + /** + * Trigger button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + TRIGGER = 13, + + /** + * Thumb button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + THUMB = 14, + + /** + * Thumb2 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + THUMB2 = 15, + + /** + * Top button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + TOP = 16, + + /** + * Top2 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + TOP2 = 17, + + /** + * Pinkie button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + PINKIE = 18, + + /** + * Base button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BASE = 19, + + /** + * Base2 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BASE2 = 20, + + /** + * Base3 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BASE3 = 21, + + /** + * Base4 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BASE4 = 22, + + /** + * Base5 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BASE5 = 23, + + /** + * Base6 button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + BASE6 = 24, + + /** + * Dead button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + DEAD = 25, + + /** + * C button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + C = 26, + + /** + * Z button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + Z = 27, + + /** + * Mode button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + MODE = 28 +} + +/** + * Axis + * + * @enum { number } + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +export declare enum Axis { + /** + * X axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_X = 0, + + /** + * Y axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_Y = 1, + + /** + * Z axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_Z = 2, + + /** + * Rz axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_RZ = 3, + + /** + * Gas axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_GAS = 4, + + /** + * Brake axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_BRAKE = 5, + + /** + * Hat0x axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_HAT0X = 6, + + /** + * Hat0y axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_HAT0Y = 7, + + /** + * Throttle axis + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + ABS_THROTTLE = 8, +} + +/** + * AxisValue + * + * @interface AxisValue + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +export declare interface AxisValue { + /** + * Axis type + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + axis: Axis; + + /** + * Axis value + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + value: number; +} + +/** + * joystickEvent + * + * @interface joystickEvent + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +export declare interface JoystickEvent extends InputEvent { + /** + * joystick event action + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + action: Action; + + /** + * Button that is currently pressed or released + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + button: Button; + + /** + * Button that is being pressed + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + pressedButtons: Button[]; + + /** + * All axis data contained in the event + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + axes: AxisValue[]; +} \ No newline at end of file -- Gitee From dbaec1372d28b8564f96e7993bdb07233bb85234 Mon Sep 17 00:00:00 2001 From: zouxing23899 Date: Mon, 22 Jan 2024 10:19:45 +0800 Subject: [PATCH 2/2] add joystick event that Signed-off-by: zouxing23899 Signed-off-by: zouxing23899 --- api/@ohos.multimodalInput.joystickEvent.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/@ohos.multimodalInput.joystickEvent.d.ts b/api/@ohos.multimodalInput.joystickEvent.d.ts index c3abc0596c..32b588cfab 100755 --- a/api/@ohos.multimodalInput.joystickEvent.d.ts +++ b/api/@ohos.multimodalInput.joystickEvent.d.ts @@ -37,7 +37,7 @@ export declare enum Action { CANCEL = 0, /** - * Pressing down of the joystick buttom + * Pressing down of the joystick button * * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 @@ -174,20 +174,20 @@ export declare enum Button { HOMEPAGE = 10, /** - * Thumbl button on the joystick + * Thumb_L button on the joystick * * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ - THUMBL = 11, + THUMB_L = 11, /** - * Thumbr button on the joystick + * Thumb_R button on the joystick * * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ - THUMBR = 12, + THUMB_R = 12, /** * Trigger button on the joystick @@ -425,9 +425,9 @@ export declare interface AxisValue { } /** - * joystickEvent + * JoystickEvent * - * @interface joystickEvent + * @interface JoystickEvent * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ -- Gitee