diff --git a/api/@ohos.multimodalInput.inputEventClient.d.ts b/api/@ohos.multimodalInput.inputEventClient.d.ts index b69bbb3e86d967c6bef82e0ad1064abda8e46068..98e06151bbdfbacb18439caef4aed54800bf9e50 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 56634785b429003b7d14ea3564c43c6113652e55..f092cb0b73f9cfc35823cd0e8d6a76a472cee5c2 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 0000000000000000000000000000000000000000..32b588cfab0887fc4783a3026d662f9d8e5ee906 --- /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 button + * + * @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, + + /** + * Thumb_L button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + THUMB_L = 11, + + /** + * Thumb_R button on the joystick + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ + THUMB_R = 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