openharmony 鸿蒙 capi-game-pad-event

2026-08-25 浏览 (1)

game_pad_event.h

Overview

Defines APIs for game controller events.

File to include: <GameControllerKit/game_pad_event.h>

Library: libohgame_controller.z.so

System capability: SystemCapability.Game.GameController

Since: 21

Related module: GameController

Summary

Types

NameDescription
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 listening registration API. The callback is triggered when a player presses a button.
typedef void(*GamePad_AxisInputMonitorCallback) (const struct GamePad_AxisEvent *axisEvent)Defines the callback function used in the axis event listening registration API. Called when a player operates a joystick.

Enumeration

NameDescription
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_GamePad_ButtonEvent_GetDeviceId (const struct GamePad_ButtonEvent *buttonEvent, char **deviceId)Obtains the 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 buttons that are pressed 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 a GamePad_PressedButton instance when it is no longer used.
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 time when the button action is performed from GamePad_ButtonEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetDeviceId (const struct GamePad_AxisEvent *axisEvent, char **deviceId)Obtains the device ID from GamePad_AxisEvent.
GameController_ErrorCode OH_GamePad_AxisEvent_GetAxisSourceType (const struct GamePad_AxisEvent *axisEvent, GamePad_AxisSourceType *axisSourceType)Obtains source type of the 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.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-game-pad

openharmony 鸿蒙 capi-game-device-event

openharmony 鸿蒙 Readme-EN

openharmony 鸿蒙 capi-game-device

openharmony 鸿蒙 capi-game-controller

openharmony 鸿蒙 capi-game-controller-type

openharmony 鸿蒙 gamecontroller-c-error-code

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