openharmony 鸿蒙 capi-game-controller

2026-08-25 浏览 (1)

GameController

Overview

Provides APIs for game controller functionality.

System capability: SystemCapability.Game.GameController

Since: 21

Summary

Files

NameDescription
game_controller_type.hDefines common enumeration types for the GameController module.
game_device.hDefines APIs for game devices.
game_device_event.hDefines APIs for game device events.
game_pad.hDefines APIs for game controllers.
game_pad_event.hDefines APIs for game controller events.

Types

NameDescription
typedef enum GameController_ErrorCode GameController_ErrorCodeDefines error codes of the game controller.
typedef struct GameDevice_AllDeviceInfos GameDevice_AllDeviceInfosDefines the calling result of OH_GameDevice_GetAllDeviceInfos.
typedef enum GameDevice_StatusChangedType GameDevice_StatusChangedTypeDefines status change types of game devices.
typedef enum GameDevice_DeviceType GameDevice_DeviceTypeDefines game device types.
typedef struct GameDevice_DeviceInfo GameDevice_DeviceInfoDefines the game device information.
typedef struct GameDevice_DeviceEvent GameDevice_DeviceEventDefines game device status change events.
typedef void(*GameDevice_DeviceMonitorCallback) (const struct GameDevice_DeviceEvent *deviceEvent)Defines the callback function used in OH_GameDevice_RegisterDeviceMonitor. Called when the game device goes online or offline.
typedef enum GamePad_AxisSourceType GamePad_AxisSourceTypeDefines source types of game controller axis events.
typedef enum GamePad_Button_ActionType GamePad_Button_ActionTypeDefines button action types of the game controller.
typedef struct GamePad_ButtonEvent GamePad_ButtonEventDefines game controller button events.
typedef struct GamePad_AxisEvent GamePad_AxisEventDefines game controller axis events.
typedef struct GamePad_PressedButton GamePad_PressedButtonDefines pressed buttons.
typedef void(*GamePad_ButtonInputMonitorCallback) (const struct GamePad_ButtonEvent *buttonEvent)Defines the callback function used in the button event registration listening API. Called when a player presses a button.
typedef void(*GamePad_AxisInputMonitorCallback) (const struct GamePad_AxisEvent *axisEvent)Defines the callback function used in the axis event registration listening API. Called when a player operates a joystick.

Enums

NameDescription
GameController_ErrorCode {
GAME_CONTROLLER_SUCCESS = 0,
GAME_CONTROLLER_PARAM_ERROR = 401,
GAME_CONTROLLER_MULTIMODAL_INPUT_ERROR = 32200001,
GAME_CONTROLLER_NO_MEMORY = 32200002
}
Game controller error codes.
GameDevice_StatusChangedType {
OFFLINE = 0,
ONLINE = 1
}
Game device status change types.
GameDevice_DeviceType {
UNKNOWN = 0,
GAME_PAD = 1
}
Game device types.
GamePad_AxisSourceType {
DPAD = 0,
LEFT_THUMBSTICK = 1,
RIGHT_THUMBSTICK = 2,
LEFT_TRIGGER = 3,
RIGHT_TRIGGER = 4
}
Source types of game controller axis events.
GamePad_Button_ActionType {
DOWN = 0,
UP = 1
}
Button action types of the game controller.

Functions

NameDescription
GameController_ErrorCode OH_GameDevice_GetAllDeviceInfos (GameDevice_AllDeviceInfos **allDeviceInfos)Obtains information about all online controllers.
GameController_ErrorCode OH_GameDevice_RegisterDeviceMonitor (GameDevice_DeviceMonitorCallback deviceMonitorCallback)Registers the listening callback for game device status change events.
GameController_ErrorCode OH_GameDevice_UnregisterDeviceMonitor (void)Unregisters the listening callback for game device status change events.
GameController_ErrorCode OH_GameDevice_DestroyAllDeviceInfos (GameDevice_AllDeviceInfos **allDeviceInfos)Destroys the GameDevice_AllDeviceInfos instance when it is no longer in use.
GameController_ErrorCode OH_GameDevice_AllDeviceInfos_GetCount (const struct GameDevice_AllDeviceInfos *allDeviceInfos, int32_t *count)Obtains the number of game devices.
GameController_ErrorCode OH_GameDevice_AllDeviceInfos_GetDeviceInfo (const struct GameDevice_AllDeviceInfos *allDeviceInfos, const int32_t index, GameDevice_DeviceInfo **deviceInfo)Obtains information about a game device with a specified index.
GameController_ErrorCode OH_GameDevice_DeviceEvent_GetChangedType (const struct GameDevice_DeviceEvent *deviceEvent, GameDevice_StatusChangedType *statusChangedType)Obtains the status change type from a game device status change event.
GameController_ErrorCode OH_GameDevice_DeviceEvent_GetDeviceInfo (const struct GameDevice_DeviceEvent *deviceEvent, GameDevice_DeviceInfo **deviceInfo)Obtains the game device information from a device status change event.
GameController_ErrorCode OH_GameDevice_DestroyDeviceInfo (GameDevice_DeviceInfo **deviceInfo)Destroys the GameDevice_DeviceInfo instance when it is no longer in use.
GameController_ErrorCode OH_GameDevice_DeviceInfo_GetDeviceId (const struct GameDevice_DeviceInfo *deviceInfo, char **deviceId)Obtains the game device ID from GameDevice_DeviceInfo.
GameController_ErrorCode OH_GameDevice_DeviceInfo_GetName (const struct GameDevice_DeviceInfo *deviceInfo, char **name)Obtains the game device name from GameDevice_DeviceInfo.
GameController_ErrorCode OH_GameDevice_DeviceInfo_GetProduct (const struct GameDevice_DeviceInfo *deviceInfo, int32_t *product)Obtains the product information from GameDevice_DeviceInfo.
GameController_ErrorCode OH_GameDevice_DeviceInfo_GetVersion (const struct GameDevice_DeviceInfo *deviceInfo, int32_t *version)Obtains the version information from GameDevice_DeviceInfo.
GameController_ErrorCode OH_GameDevice_DeviceInfo_GetPhysicalAddress (const struct GameDevice_DeviceInfo *deviceInfo, char **physicalAddress)Obtains the physical address from GameDevice_DeviceInfo.
GameController_ErrorCode OH_GameDevice_DeviceInfo_GetDeviceType (const struct GameDevice_DeviceInfo *deviceInfo, GameDevice_DeviceType *deviceType)Obtains the game device type from GameDevice_DeviceInfo.
GameController_ErrorCode OH_GamePad_LeftShoulder_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Left Shoulder button event.
GameController_ErrorCode OH_GamePad_LeftShoulder_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Left Shoulder button event.
GameController_ErrorCode OH_GamePad_RightShoulder_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Right Shoulder button event.
GameController_ErrorCode OH_GamePad_RightShoulder_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Right Shoulder button event.
GameController_ErrorCode OH_GamePad_LeftTrigger_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Left Trigger button event.
GameController_ErrorCode OH_GamePad_LeftTrigger_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Left Trigger button event.
GameController_ErrorCode OH_GamePad_LeftTrigger_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Left Trigger axis event.
GameController_ErrorCode OH_GamePad_LeftTrigger_UnregisterAxisInputMonitor (void)Unregisters the listening callback for the Left Trigger axis event.
GameController_ErrorCode OH_GamePad_RightTrigger_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Right Trigger button event.
GameController_ErrorCode OH_GamePad_RightTrigger_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Right Trigger button event.
GameController_ErrorCode OH_GamePad_RightTrigger_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Right Trigger axis event.
GameController_ErrorCode OH_GamePad_RightTrigger_UnregisterAxisInputMonitor (void)Unregisters the listening callback for the Right Trigger axis event.
GameController_ErrorCode OH_GamePad_ButtonMenu_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Menu button event.
GameController_ErrorCode OH_GamePad_ButtonMenu_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Menu button event.
GameController_ErrorCode OH_GamePad_ButtonHome_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Home button event.
GameController_ErrorCode OH_GamePad_ButtonHome_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Home button event.
GameController_ErrorCode OH_GamePad_ButtonA_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the A button event.
GameController_ErrorCode OH_GamePad_ButtonA_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the A button event.
GameController_ErrorCode OH_GamePad_ButtonB_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the B button event.
GameController_ErrorCode OH_GamePad_ButtonB_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the B button event.
GameController_ErrorCode OH_GamePad_ButtonX_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the X button event.
GameController_ErrorCode OH_GamePad_ButtonX_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the X button event.
GameController_ErrorCode OH_GamePad_ButtonY_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Y button event.
GameController_ErrorCode OH_GamePad_ButtonY_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Y button event.
GameController_ErrorCode OH_GamePad_ButtonC_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the C button event.
GameController_ErrorCode OH_GamePad_ButtonC_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the C button event.
GameController_ErrorCode OH_GamePad_Dpad_LeftButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Left Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_LeftButton_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Left Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_RightButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Right Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_RightButton_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Right Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_UpButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Up Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_UpButton_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Up Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_DownButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Down Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_DownButton_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Down Directional button event.
GameController_ErrorCode OH_GamePad_Dpad_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Directional Pad button axis event.
GameController_ErrorCode OH_GamePad_Dpad_UnregisterAxisInputMonitor (void)Unregisters the listening callback for the Directional Pad button axis event.
GameController_ErrorCode OH_GamePad_LeftThumbstick_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Left Thumbstick button event.
GameController_ErrorCode OH_GamePad_LeftThumbstick_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Left Thumbstick button event.
GameController_ErrorCode OH_GamePad_LeftThumbstick_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Left Thumbstick axis event.
GameController_ErrorCode OH_GamePad_LeftThumbstick_UnregisterAxisInputMonitor (void)Unregisters the listening callback for the Left Thumbstick axis event.
GameController_ErrorCode OH_GamePad_RightThumbstick_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Right Thumbstick button event.
GameController_ErrorCode OH_GamePad_RightThumbstick_UnregisterButtonInputMonitor (void)Unregisters the listening callback for the Right Thumbstick button event.
GameController_ErrorCode OH_GamePad_RightThumbstick_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)Registers the listening callback for the Right Thumbstick axis event.
GameController_ErrorCode OH_GamePad_RightThumbstick_UnregisterAxisInputMonitor (void)Unregisters the listening callback for the Right Thumbstick axis event.
GameController_ErrorCode OH_GamePad_ButtonEvent_GetDeviceId (const struct GamePad_ButtonEvent *buttonEvent, char **deviceId)Obtains the game device ID from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonAction (const struct GamePad_ButtonEvent *buttonEvent, GamePad_Button_ActionType *actionType)Obtains the button action type from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonCode (const struct GamePad_ButtonEvent *buttonEvent, int32_t *code)Obtains the button code from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonCodeName (const struct GamePad_ButtonEvent *buttonEvent, char **codeName)Obtains the button name from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_PressedButtons_GetCount (const struct GamePad_ButtonEvent *buttonEvent, int32_t *count)Obtains the number of pressed buttons from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_PressedButtons_GetButtonInfo (const struct GamePad_ButtonEvent *buttonEvent, const int32_t index, GamePad_PressedButton **pressedButton)Obtains the pressed button with a given index from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_DestroyPressedButton (GamePad_PressedButton **pressedButton)Destroys the GamePad_PressedButton instance when it is no longer in use.
GameController_ErrorCode OH_GamePad_PressedButton_GetButtonCode (const struct GamePad_PressedButton *pressedButton, int32_t *code)Obtains the button code from GamePad_PressedButton.
GameController_ErrorCode OH_GamePad_PressedButton_GetButtonCodeName (const struct GamePad_PressedButton *pressedButton, char **codeName)Obtains the button name from GamePad_PressedButton.
GameController_ErrorCode OH_GamePad_ButtonEvent_GetActionTime (const struct GamePad_ButtonEvent *buttonEvent, int64_t *actionTime)Obtains the button action time from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetDeviceId (const struct GamePad_AxisEvent *axisEvent, char **deviceId)Obtains the game device ID from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetAxisSourceType (const struct GamePad_AxisEvent *axisEvent, GamePad_AxisSourceType *axisSourceType)Obtains the source type of axis event from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetXAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the X-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetYAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the Y-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetZAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the Z-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetRZAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the RZ-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetHatXAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the HatX-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetHatYAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the HatY-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetBrakeAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the Brake-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetGasAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)Obtains the Gas-axis value from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetActionTime (const struct GamePad_AxisEvent *axisEvent, int64_t *actionTime)Obtains the action time from GamePad_AxisEvent.

Type Description

GameController_ErrorCode

typedef enum GameController_ErrorCode GameController_ErrorCode

Description

Defines error codes of the game controller.

Since: 21

GameDevice_AllDeviceInfos

typedef struct GameDevice_AllDeviceInfos GameDevice_AllDeviceInfos

Description

Defines the calling result of OH_GameDevice_GetAllDeviceInfos.

Since: 21

GameDevice_DeviceEvent

typedef struct GameDevice_DeviceEvent GameDevice_DeviceEvent

Description

Defines game device status change events.

Since: 21

GameDevice_DeviceInfo

typedef struct GameDevice_DeviceInfo GameDevice_DeviceInfo

Description

Defines the game device information.

Since: 21

GameDevice_DeviceMonitorCallback

typedef void(*GameDevice_DeviceMonitorCallback) (const struct GameDevice_DeviceEvent *deviceEvent)

Description

Defines the callback function used in OH_GameDevice_RegisterDeviceMonitor. Called when the game device goes online or offline.

Since: 21

Parameters

NameDescription
deviceEventOutput parameter. Game device status change event GameDevice_DeviceEvent.

GameDevice_DeviceType

typedef enum GameDevice_DeviceType GameDevice_DeviceType

Description

Defines game device types.

Since: 21

GameDevice_StatusChangedType

typedef enum GameDevice_StatusChangedType GameDevice_StatusChangedType

Description

Defines status change types of game devices.

Since: 21

GamePad_AxisEvent

typedef struct GamePad_AxisEvent GamePad_AxisEvent

Description

Defines game controller axis events.

Since: 21

GamePad_AxisInputMonitorCallback

typedef void(*GamePad_AxisInputMonitorCallback) (const struct GamePad_AxisEvent *axisEvent)

Description

Defines the callback function used in the axis event registration listening API. Called when a player operates a joystick.

Since: 21

Parameters

NameDescription
axisEventOutput parameter. Game controller axis event GamePad_AxisEvent.

GamePad_AxisSourceType

typedef enum GamePad_AxisSourceType GamePad_AxisSourceType

Description

Defines source types of game controller axis events.

Since: 21

GamePad_Button_ActionType

typedef enum GamePad_Button_ActionType GamePad_Button_ActionType

Description

Defines button action types of the game controller.

Since: 21

GamePad_ButtonEvent

typedef struct GamePad_ButtonEvent GamePad_ButtonEvent

Description

Defines game controller button events.

Since: 21

GamePad_ButtonInputMonitorCallback

typedef void(*GamePad_ButtonInputMonitorCallback) (const struct GamePad_ButtonEvent *buttonEvent)

Description

Defines the callback function used in the button event registration listening API. Called when a player presses a button.

Since: 21

Parameters

NameDescription
buttonEventOutput parameter. Game controller button event GamePad_ButtonEvent.

GamePad_PressedButton

typedef struct GamePad_PressedButton GamePad_PressedButton

Description

Defines pressed buttons.

Since: 21

Enum Description

GameController_ErrorCode

enum GameController_ErrorCode

Description

Defines error codes of the game controller.

Since: 21

ValueDescription
GAME_CONTROLLER_SUCCESSSuccess.
GAME_CONTROLLER_PARAM_ERRORInvalid parameter.
GAME_CONTROLLER_MULTIMODAL_INPUT_ERRORFailed to query all game device information in multimodal input.
GAME_CONTROLLER_NO_MEMORYInsufficient game device memory.

GameDevice_DeviceType

enum GameDevice_DeviceType

Description

Defines game device types.

Since: 21

ValueDescription
UNKNOWNUnknown.
GAME_PADGame controller.

GameDevice_StatusChangedType

enum GameDevice_StatusChangedType

Description

Defines status change types of game devices.

Since: 21

ValueDescription
OFFLINEThe game device is offline.
ONLINEThe game device is online.

GamePad_AxisSourceType

enum GamePad_AxisSourceType

Description

Defines source types of game controller axis events.

Since: 21

ValueDescription
DPADThe axis event comes from the directional pad (D-pad).
LEFT_THUMBSTICKThe axis event comes from the left thumbstick.
RIGHT_THUMBSTICKThe axis event comes from the right thumbstick.
LEFT_TRIGGERThe axis event comes from the left trigger.
RIGHT_TRIGGERThe axis event comes from the right trigger.

GamePad_Button_ActionType

enum GamePad_Button_ActionType

Description

Defines button action types of the game controller.

Since: 21

ValueDescription
DOWNThe button is pressed.
UPThe button is released.

Function Description

OH_GameDevice_AllDeviceInfos_GetCount()

GameController_ErrorCode OH_GameDevice_AllDeviceInfos_GetCount (const struct GameDevice_AllDeviceInfos *allDeviceInfos, int32_t *count)

Description

Obtains the number of game devices.

Since: 21

Parameters

NameDescription
allDeviceInfosPointer to the GameDevice_AllDeviceInfos instance. The pointer cannot be null. Otherwise, an error code is returned.
countOutput parameter. Number of game devices.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: allDeviceInfos is null.

OH_GameDevice_AllDeviceInfos_GetDeviceInfo()

GameController_ErrorCode OH_GameDevice_AllDeviceInfos_GetDeviceInfo (const struct GameDevice_AllDeviceInfos *allDeviceInfos, const int32_t index, GameDevice_DeviceInfo **deviceInfo)

Description

Obtains information about a game device with a specified index.

Since: 21

Parameters

NameDescription
allDeviceInfosPointer to the GameDevice_AllDeviceInfos instance. The pointer cannot be null. Otherwise, an error code is returned.
indexIndex of the game device to be queried.
deviceInfoOutput parameter. The level-2 pointer points to the GameDevice_DeviceInfo instance.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: allDeviceInfos is null, or the index is less than 0 or greater than or equal to the total number of game devices.

OH_GameDevice_DestroyAllDeviceInfos()

GameController_ErrorCode OH_GameDevice_DestroyAllDeviceInfos (GameDevice_AllDeviceInfos **allDeviceInfos)

Description

Destroys the GameDevice_AllDeviceInfos instance when it is no longer in use.

Since: 21

Parameters

NameDescription
allDeviceInfosLevel-2 pointer to the GameDevice_AllDeviceInfos instance. The pointer cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: allDeviceInfos is null.

OH_GameDevice_DestroyDeviceInfo()

GameController_ErrorCode OH_GameDevice_DestroyDeviceInfo (GameDevice_DeviceInfo **deviceInfo)

Description

Destroys the GameDevice_DeviceInfo instance when it is no longer in use.

Since: 21

Parameters

NameDescription
deviceInfoLevel-2 pointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceInfo is null.

OH_GameDevice_DeviceEvent_GetChangedType()

GameController_ErrorCode OH_GameDevice_DeviceEvent_GetChangedType (const struct GameDevice_DeviceEvent *deviceEvent, GameDevice_StatusChangedType *statusChangedType)

Description

Obtains the status change type from GameDevice_DeviceEvent.

Since: 21

Parameters

NameDescription
deviceEventPointer to the GameDevice_DeviceEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
statusChangedTypeOutput parameter. Game device status change type.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceEvent is null.

OH_GameDevice_DeviceEvent_GetDeviceInfo()

GameController_ErrorCode OH_GameDevice_DeviceEvent_GetDeviceInfo (const struct GameDevice_DeviceEvent *deviceEvent, GameDevice_DeviceInfo **deviceInfo)

Description

Obtains the game device information from GameDevice_DeviceEvent.

Since: 21

Parameters

NameDescription
deviceEventPointer to the GameDevice_DeviceEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
deviceInfoOutput parameter. The level-2 pointer points to the GameDevice_DeviceInfo instance.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceEvent is null.

OH_GameDevice_DeviceInfo_GetDeviceId()

GameController_ErrorCode OH_GameDevice_DeviceInfo_GetDeviceId (const struct GameDevice_DeviceInfo *deviceInfo, char **deviceId)

Description

Obtains the device ID from GameDevice_DeviceInfo.

Since: 21

Parameters

NameDescription
deviceInfoPointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned.
deviceIdOutput parameter. The level-2 pointer points to the game device ID.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceInfo or deviceId is null.

  • GAME_CONTROLLER_NO_MEMORY: Insufficient game device memory.

OH_GameDevice_DeviceInfo_GetDeviceType()

GameController_ErrorCode OH_GameDevice_DeviceInfo_GetDeviceType (const struct GameDevice_DeviceInfo *deviceInfo, GameDevice_DeviceType *deviceType)

Description

Obtains the game device type from GameDevice_DeviceInfo.

Since: 21

Parameters

NameDescription
deviceInfoPointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned.
deviceTypeOutput parameter. Game device type.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceInfo is null.

OH_GameDevice_DeviceInfo_GetName()

GameController_ErrorCode OH_GameDevice_DeviceInfo_GetName (const struct GameDevice_DeviceInfo *deviceInfo, char **name)

Description

Obtains the game device name from GameDevice_DeviceInfo.

Since: 21

Parameters

NameDescription
deviceInfoPointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned.
nameOutput parameter. The level-2 pointer points to the game device name.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceInfo or name is null.

  • GAME_CONTROLLER_NO_MEMORY: Insufficient game device memory.

OH_GameDevice_DeviceInfo_GetPhysicalAddress()

GameController_ErrorCode OH_GameDevice_DeviceInfo_GetPhysicalAddress (const struct GameDevice_DeviceInfo *deviceInfo, char **physicalAddress)

Description

Obtains the physical address from GameDevice_DeviceInfo.

Since: 21

Parameters

NameDescription
deviceInfoPointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned.
physicalAddressOutput parameter. The level-2 pointer points to the physical address.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceInfo or physicalAddress is null.

  • GAME_CONTROLLER_NO_MEMORY: Insufficient game device memory.

OH_GameDevice_DeviceInfo_GetProduct()

GameController_ErrorCode OH_GameDevice_DeviceInfo_GetProduct (const struct GameDevice_DeviceInfo *deviceInfo, int32_t *product)

Description

Obtains the product information from GameDevice_DeviceInfo.

Since: 21

Parameters

NameDescription
deviceInfoPointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned.
productOutput parameter. Product information.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceInfo is null.

OH_GameDevice_DeviceInfo_GetVersion()

GameController_ErrorCode OH_GameDevice_DeviceInfo_GetVersion (const struct GameDevice_DeviceInfo *deviceInfo, int32_t *version)

Description

Obtains the version information from GameDevice_DeviceInfo.

Since: 21

Parameters

NameDescription
deviceInfoPointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned.
versionOutput parameter. Version information.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceInfo is null.

OH_GameDevice_GetAllDeviceInfos()

GameController_ErrorCode OH_GameDevice_GetAllDeviceInfos (GameDevice_AllDeviceInfos **allDeviceInfos)

Description

Obtains information about all online game devices.

Since: 21

Parameters

NameDescription
allDeviceInfosOutput parameter. Level-2 pointer to the GameDevice_AllDeviceInfos instance. The pointer cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_MULTIMODAL_INPUT_ERROR: Failed to query all game device information in multimodal input.

OH_GameDevice_RegisterDeviceMonitor()

GameController_ErrorCode OH_GameDevice_RegisterDeviceMonitor (GameDevice_DeviceMonitorCallback deviceMonitorCallback)

Description

Registers the listening callback for game device status change events.

Since: 21

Parameters

NameDescription
deviceMonitorCallbackCallback function GameDevice_DeviceMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: deviceMonitorCallback is null.

OH_GameDevice_UnregisterDeviceMonitor()

GameController_ErrorCode OH_GameDevice_UnregisterDeviceMonitor (void)

Description

Unregisters the listening callback for game device status change events.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_AxisEvent_GetActionTime()

GameController_ErrorCode OH_GamePad_AxisEvent_GetActionTime (const struct GamePad_AxisEvent *axisEvent, int64_t *actionTime)

Description

Obtains the action time from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
actionTimeOutput parameter. Action time.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetAxisSourceType()

GameController_ErrorCode OH_GamePad_AxisEvent_GetAxisSourceType (const struct GamePad_AxisEvent *axisEvent, GamePad_AxisSourceType *axisSourceType)

Description

Obtains the source type of axis event from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisSourceTypeOutput parameter. Source type of the axis event GamePad_AxisSourceType.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetBrakeAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetBrakeAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the Brake-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetDeviceId()

GameController_ErrorCode OH_GamePad_AxisEvent_GetDeviceId (const struct GamePad_AxisEvent *axisEvent, char **deviceId)

Description

Obtains the game device ID from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
deviceIdOutput parameter. The level-2 pointer points to the game device ID.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent or deviceId is null.

  • GAME_CONTROLLER_NO_MEMORY: Insufficient game device memory.

OH_GamePad_AxisEvent_GetGasAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetGasAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the Gas-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetHatXAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetHatXAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the HatX-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetHatYAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetHatYAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the HatY-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetRZAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetRZAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the RZ-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetXAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetXAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the X-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetYAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetYAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the Y-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_AxisEvent_GetZAxisValue()

GameController_ErrorCode OH_GamePad_AxisEvent_GetZAxisValue (const struct GamePad_AxisEvent *axisEvent, double *axisValue)

Description

Obtains the Z-axis value from GamePad_AxisEvent.

Since: 21

Parameters

NameDescription
axisEventPointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
axisValueOutput parameter. Axis value.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: axisEvent is null.

OH_GamePad_ButtonA_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonA_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the A button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_ButtonA_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonA_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the A button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_ButtonB_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonB_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the B button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackOutput parameter. Callback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_ButtonB_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonB_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the B button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_ButtonC_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonC_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the C button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackOutput parameter. Callback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_ButtonC_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonC_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the C button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_ButtonEvent_GetActionTime()

GameController_ErrorCode OH_GamePad_ButtonEvent_GetActionTime (const struct GamePad_ButtonEvent *buttonEvent, int64_t *actionTime)

Description

Obtains the button action time from GamePad_ButtonEvent.

Since: 21

Parameters

NameDescription
buttonEventPointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
actionTimeOutput parameter. Time when the button action is performed.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: buttonEvent is null.

OH_GamePad_ButtonEvent_GetButtonAction()

GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonAction (const struct GamePad_ButtonEvent *buttonEvent, GamePad_Button_ActionType *actionType)

Description

Obtains the button action type from GamePad_ButtonEvent.

Since: 21

Parameters

NameDescription
buttonEventPointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
actionTypeOutput parameter. Button action type.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: buttonEvent is null.

OH_GamePad_ButtonEvent_GetButtonCode()

GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonCode (const struct GamePad_ButtonEvent *buttonEvent, int32_t *code)

Description

Obtains the button code from GamePad_ButtonEvent.

Since: 21

Parameters

NameDescription
buttonEventPointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
codeOutput parameter. Button code.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: buttonEvent is null.

OH_GamePad_ButtonEvent_GetButtonCodeName()

GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonCodeName (const struct GamePad_ButtonEvent *buttonEvent, char **codeName)

Description

Obtains the button name from GamePad_ButtonEvent.

Since: 21

Parameters

NameDescription
buttonEventPointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
codeNameOutput parameter. The level-2 pointer points to the button name.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: buttonEvent or codeName is null.

  • GAME_CONTROLLER_NO_MEMORY: Insufficient game device memory.

OH_GamePad_ButtonEvent_GetDeviceId()

GameController_ErrorCode OH_GamePad_ButtonEvent_GetDeviceId (const struct GamePad_ButtonEvent *buttonEvent, char **deviceId)

Description

Obtains the game device ID from GamePad_ButtonEvent.

Since: 21

Parameters

NameDescription
buttonEventPointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
deviceIdOutput parameter. The level-2 pointer points to the game device ID.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: buttonEvent or deviceId is null.

  • GAME_CONTROLLER_NO_MEMORY: Insufficient game device memory.

OH_GamePad_ButtonHome_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonHome_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Home button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_ButtonHome_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonHome_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Home button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_ButtonMenu_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonMenu_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Menu button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_ButtonMenu_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonMenu_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Menu button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_ButtonX_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonX_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the X button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackOutput parameter. Callback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_ButtonX_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonX_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the X button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_ButtonY_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonY_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Y button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackOutput parameter. Callback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_ButtonY_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_ButtonY_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Y button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_DestroyPressedButton()

GameController_ErrorCode OH_GamePad_DestroyPressedButton (GamePad_PressedButton **pressedButton)

Description

Destroys the GamePad_PressedButton instance when it is no longer in use.

Since: 21

Parameters

NameDescription
pressedButtonLevel-2 pointer to the GamePad_PressedButton instance. The pointer cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: pressedButton is null.

OH_GamePad_Dpad_DownButton_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_DownButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Down Directional button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_Dpad_DownButton_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_DownButton_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Down Directional button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_Dpad_LeftButton_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_LeftButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Left Directional button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_Dpad_LeftButton_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_LeftButton_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Left Directional button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_Dpad_RegisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Directional Pad button axis event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_AxisInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_Dpad_RightButton_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_RightButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Right Directional button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_Dpad_RightButton_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_RightButton_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Right Directional button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_Dpad_UnregisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_UnregisterAxisInputMonitor (void)

Description

Unregisters the listening callback for the Directional Pad button axis event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_Dpad_UpButton_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_UpButton_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Up Directional button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_Dpad_UpButton_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_Dpad_UpButton_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Up Directional button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_LeftShoulder_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_LeftShoulder_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Left Shoulder button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_LeftShoulder_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_LeftShoulder_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Left Shoulder button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_LeftThumbstick_RegisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_LeftThumbstick_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Left Thumbstick axis event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_AxisInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_LeftThumbstick_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_LeftThumbstick_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Left Thumbstick button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_LeftThumbstick_UnregisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_LeftThumbstick_UnregisterAxisInputMonitor (void)

Description

Unregisters the listening callback for the Left Thumbstick axis event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_LeftThumbstick_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_LeftThumbstick_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Left Thumbstick button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_LeftTrigger_RegisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_LeftTrigger_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Left Trigger axis event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_AxisInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_LeftTrigger_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_LeftTrigger_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Left Trigger button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_LeftTrigger_UnregisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_LeftTrigger_UnregisterAxisInputMonitor (void)

Description

Unregisters the listening callback for the Left Trigger axis event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_LeftTrigger_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_LeftTrigger_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Left Trigger button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_PressedButton_GetButtonCode()

GameController_ErrorCode OH_GamePad_PressedButton_GetButtonCode (const struct GamePad_PressedButton *pressedButton, int32_t *code)

Description

Obtains the button code from GamePad_PressedButton.

Since: 21

Parameters

NameDescription
pressedButtonPointer to the GamePad_PressedButton instance. The pointer cannot be null. Otherwise, an error code is returned.
codeOutput parameter. Button code.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: pressedButton is null.

OH_GamePad_PressedButton_GetButtonCodeName()

GameController_ErrorCode OH_GamePad_PressedButton_GetButtonCodeName (const struct GamePad_PressedButton *pressedButton, char **codeName)

Description

Obtains the button name from GamePad_PressedButton.

Since: 21

Parameters

NameDescription
pressedButtonPointer to the GamePad_PressedButton instance. The pointer cannot be null. Otherwise, an error code is returned.
codeNameOutput parameter. The level-2 pointer points to the button name.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: pressedButton or codeName is null.

  • GAME_CONTROLLER_NO_MEMORY: Insufficient game device memory.

OH_GamePad_PressedButtons_GetButtonInfo()

GameController_ErrorCode OH_GamePad_PressedButtons_GetButtonInfo (const struct GamePad_ButtonEvent *buttonEvent, const int32_t index, GamePad_PressedButton **pressedButton)

Description

Obtains the pressed button with a given index from GamePad_ButtonEvent.

Since: 21

Parameters

NameDescription
buttonEventPointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
indexButton index.
pressedButtonOutput parameter. The level-2 pointer points to the pressed button.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: buttonEvent is null, or the index is less than 0 or greater than or equal to the number of all buttons.

OH_GamePad_PressedButtons_GetCount()

GameController_ErrorCode OH_GamePad_PressedButtons_GetCount (const struct GamePad_ButtonEvent *buttonEvent, int32_t *count)

Description

Obtains the number of pressed buttons from GamePad_ButtonEvent.

Since: 21

Parameters

NameDescription
buttonEventPointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned.
countOutput parameter. Number of pressed buttons.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: buttonEvent is null.

OH_GamePad_RightShoulder_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_RightShoulder_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Right Shoulder button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_RightShoulder_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_RightShoulder_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Right Shoulder button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_RightThumbstick_RegisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_RightThumbstick_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Right Thumbstick axis event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_AxisInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_RightThumbstick_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_RightThumbstick_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Right Thumbstick button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_RightThumbstick_UnregisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_RightThumbstick_UnregisterAxisInputMonitor (void)

Description

Unregisters the listening callback for the Right Thumbstick axis event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_RightThumbstick_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_RightThumbstick_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Right Thumbstick button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_RightTrigger_RegisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_RightTrigger_RegisterAxisInputMonitor (GamePad_AxisInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Right Trigger axis event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_AxisInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_RightTrigger_RegisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_RightTrigger_RegisterButtonInputMonitor (GamePad_ButtonInputMonitorCallback inputMonitorCallback)

Description

Registers the listening callback for the Right Trigger button event.

Since: 21

Parameters

NameDescription
inputMonitorCallbackCallback function GamePad_ButtonInputMonitorCallback. The callback function cannot be null. Otherwise, an error code is returned.

Returns

Execution result of the function, with the error code GameController_ErrorCode:

  • GAME_CONTROLLER_SUCCESS: Success.

  • GAME_CONTROLLER_PARAM_ERROR: inputMonitorCallback is null.

OH_GamePad_RightTrigger_UnregisterAxisInputMonitor()

GameController_ErrorCode OH_GamePad_RightTrigger_UnregisterAxisInputMonitor (void)

Description

Unregisters the listening callback for the Right Trigger axis event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

OH_GamePad_RightTrigger_UnregisterButtonInputMonitor()

GameController_ErrorCode OH_GamePad_RightTrigger_UnregisterButtonInputMonitor (void)

Description

Unregisters the listening callback for the Right Trigger button event.

Since: 21

Returns

Execution result of the function. If the execution is successful, GAME_CONTROLLER_SUCCESS is returned.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-game-pad

openharmony 鸿蒙 capi-game-device-event

openharmony 鸿蒙 Readme-EN

openharmony 鸿蒙 capi-game-device

openharmony 鸿蒙 capi-game-pad-event

openharmony 鸿蒙 capi-game-controller-type

openharmony 鸿蒙 gamecontroller-c-error-code

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/gMtztrv3