GameController
Overview
Provides APIs for game controller functionality.
System capability: SystemCapability.Game.GameController
Since: 21
Summary
Files
| Name | Description |
|---|---|
| game_controller_type.h | Defines common enumeration types for the GameController module. |
| game_device.h | Defines APIs for game devices. |
| game_device_event.h | Defines APIs for game device events. |
| game_pad.h | Defines APIs for game controllers. |
| game_pad_event.h | Defines APIs for game controller events. |
Types
| Name | Description |
|---|---|
| typedef enum GameController_ErrorCode GameController_ErrorCode | Defines error codes of the game controller. |
| typedef struct GameDevice_AllDeviceInfos GameDevice_AllDeviceInfos | Defines the calling result of OH_GameDevice_GetAllDeviceInfos. |
| typedef enum GameDevice_StatusChangedType GameDevice_StatusChangedType | Defines status change types of game devices. |
| typedef enum GameDevice_DeviceType GameDevice_DeviceType | Defines game device types. |
| typedef struct GameDevice_DeviceInfo GameDevice_DeviceInfo | Defines the game device information. |
| typedef struct GameDevice_DeviceEvent GameDevice_DeviceEvent | Defines 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_AxisSourceType | Defines source types of game controller axis events. |
| typedef enum GamePad_Button_ActionType GamePad_Button_ActionType | Defines button action types of the game controller. |
| typedef struct GamePad_ButtonEvent GamePad_ButtonEvent | Defines game controller button events. |
| typedef struct GamePad_AxisEvent GamePad_AxisEvent | Defines game controller axis events. |
| typedef struct GamePad_PressedButton GamePad_PressedButton | Defines 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
| Name | Description |
|---|---|
| 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
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
| Name | Description |
|---|---|
| deviceEvent | Output 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
| Name | Description |
|---|---|
| axisEvent | Output 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
| Name | Description |
|---|---|
| buttonEvent | Output 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
| Value | Description |
|---|---|
| GAME_CONTROLLER_SUCCESS | Success. |
| GAME_CONTROLLER_PARAM_ERROR | Invalid parameter. |
| GAME_CONTROLLER_MULTIMODAL_INPUT_ERROR | Failed to query all game device information in multimodal input. |
| GAME_CONTROLLER_NO_MEMORY | Insufficient game device memory. |
GameDevice_DeviceType
enum GameDevice_DeviceType
Description
Defines game device types.
Since: 21
| Value | Description |
|---|---|
| UNKNOWN | Unknown. |
| GAME_PAD | Game controller. |
GameDevice_StatusChangedType
enum GameDevice_StatusChangedType
Description
Defines status change types of game devices.
Since: 21
| Value | Description |
|---|---|
| OFFLINE | The game device is offline. |
| ONLINE | The game device is online. |
GamePad_AxisSourceType
enum GamePad_AxisSourceType
Description
Defines source types of game controller axis events.
Since: 21
| Value | Description |
|---|---|
| DPAD | The axis event comes from the directional pad (D-pad). |
| LEFT_THUMBSTICK | The axis event comes from the left thumbstick. |
| RIGHT_THUMBSTICK | The axis event comes from the right thumbstick. |
| LEFT_TRIGGER | The axis event comes from the left trigger. |
| RIGHT_TRIGGER | The 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
| Value | Description |
|---|---|
| DOWN | The button is pressed. |
| UP | The 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
| Name | Description |
|---|---|
| allDeviceInfos | Pointer to the GameDevice_AllDeviceInfos instance. The pointer cannot be null. Otherwise, an error code is returned. |
| count | Output 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
| Name | Description |
|---|---|
| allDeviceInfos | Pointer to the GameDevice_AllDeviceInfos instance. The pointer cannot be null. Otherwise, an error code is returned. |
| index | Index of the game device to be queried. |
| deviceInfo | Output 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
| Name | Description |
|---|---|
| allDeviceInfos | 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_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
| Name | Description |
|---|---|
| deviceInfo | Level-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
| Name | Description |
|---|---|
| deviceEvent | Pointer to the GameDevice_DeviceEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| statusChangedType | Output 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
| Name | Description |
|---|---|
| deviceEvent | Pointer to the GameDevice_DeviceEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| deviceInfo | Output 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
| Name | Description |
|---|---|
| deviceInfo | Pointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned. |
| deviceId | Output 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
| Name | Description |
|---|---|
| deviceInfo | Pointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned. |
| deviceType | Output 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
| Name | Description |
|---|---|
| deviceInfo | Pointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned. |
| name | Output 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
| Name | Description |
|---|---|
| deviceInfo | Pointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned. |
| physicalAddress | Output 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
| Name | Description |
|---|---|
| deviceInfo | Pointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned. |
| product | Output 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
| Name | Description |
|---|---|
| deviceInfo | Pointer to the GameDevice_DeviceInfo instance. The pointer cannot be null. Otherwise, an error code is returned. |
| version | Output 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
| Name | Description |
|---|---|
| allDeviceInfos | Output 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
| Name | Description |
|---|---|
| deviceMonitorCallback | Callback 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| actionTime | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisSourceType | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| deviceId | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| axisEvent | Pointer to the GamePad_AxisEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| axisValue | Output 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | Output 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
| Name | Description |
|---|---|
| inputMonitorCallback | Output 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
| Name | Description |
|---|---|
| buttonEvent | Pointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| actionTime | Output 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
| Name | Description |
|---|---|
| buttonEvent | Pointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| actionType | Output 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
| Name | Description |
|---|---|
| buttonEvent | Pointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| code | Output 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
| Name | Description |
|---|---|
| buttonEvent | Pointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| codeName | Output 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
| Name | Description |
|---|---|
| buttonEvent | Pointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| deviceId | Output 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | Output 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
| Name | Description |
|---|---|
| inputMonitorCallback | Output 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
| Name | Description |
|---|---|
| pressedButton | Level-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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | Callback 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | Callback 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | Callback 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| pressedButton | Pointer to the GamePad_PressedButton instance. The pointer cannot be null. Otherwise, an error code is returned. |
| code | Output 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
| Name | Description |
|---|---|
| pressedButton | Pointer to the GamePad_PressedButton instance. The pointer cannot be null. Otherwise, an error code is returned. |
| codeName | Output 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
| Name | Description |
|---|---|
| buttonEvent | Pointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| index | Button index. |
| pressedButton | Output 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
| Name | Description |
|---|---|
| buttonEvent | Pointer to the GamePad_ButtonEvent instance. The pointer cannot be null. Otherwise, an error code is returned. |
| count | Output 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | Callback 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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
| Name | Description |
|---|---|
| inputMonitorCallback | Callback 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
| Name | Description |
|---|---|
| inputMonitorCallback | 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_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-device-event
openharmony 鸿蒙 capi-game-device
openharmony 鸿蒙 capi-game-pad-event