From 364c5e715118ace37e90b392aa7a17a2d0338035 Mon Sep 17 00:00:00 2001 From: jinsitao Date: Fri, 21 Mar 2025 09:20:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9EGameControllerKit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinsitao --- GameControllerKit/BUILD.gn | 41 ++ GameControllerKit/game_controller_type.h | 73 +++ GameControllerKit/game_device.h | 122 +++++ GameControllerKit/game_device_event.h | 220 +++++++++ GameControllerKit/game_pad.h | 445 ++++++++++++++++++ GameControllerKit/game_pad_event.h | 402 ++++++++++++++++ .../libohgame_controller.ndk.json | 334 +++++++++++++ ndk_targets.gni | 2 + 8 files changed, 1639 insertions(+) create mode 100644 GameControllerKit/BUILD.gn create mode 100644 GameControllerKit/game_controller_type.h create mode 100644 GameControllerKit/game_device.h create mode 100644 GameControllerKit/game_device_event.h create mode 100644 GameControllerKit/game_pad.h create mode 100644 GameControllerKit/game_pad_event.h create mode 100644 GameControllerKit/libohgame_controller.ndk.json diff --git a/GameControllerKit/BUILD.gn b/GameControllerKit/BUILD.gn new file mode 100644 index 00000000000..73278e0ce61 --- /dev/null +++ b/GameControllerKit/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (C) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos_var.gni") + +ohos_ndk_headers("ohgame_controller_header") { + dest_dir = "$ndk_headers_out_dir/GameControllerKit/" + sources = [ + "game_controller_type.h", + "game_device.h", + "game_device_event.h", + "game_pad.h", + "game_pad_event.h", + ] +} + +ohos_ndk_library("libohgame_controller") { + output_name = "ohgame_controller" + output_extension = "z.so" + system_capability = "SystemCapability.Game.GameController" + ndk_description_file = "libohgame_controller.ndk.json" + min_compact_version = "18" + system_capability_headers = [ + "game_controller_type.h", + "game_device_event.h", + "game_device.h", + "game_pad_event.h", + "game_pad.h", + ] +} \ No newline at end of file diff --git a/GameControllerKit/game_controller_type.h b/GameControllerKit/game_controller_type.h new file mode 100644 index 00000000000..4d5edd292b4 --- /dev/null +++ b/GameControllerKit/game_controller_type.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup GameController + * @{ + * + * @brief Provides APIs for game controller capability. + * + * @since 18 + */ + +/** + * @file game_controller_type.h + * @kit GameControllerKit + * @brief Defines the common types for the native module. + * @library libohgame_controller.z.so + * @syscap SystemCapability.Game.GameController + * @since 18 + */ + +#ifndef GAME_CONTROLLER_TYPE_H +#define GAME_CONTROLLER_TYPE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + /** + * @brief Defines ErrorCode. + * @since 18 + */ + typedef enum GameController_ErrorCode { + /** + * Success. + */ + GAME_CONTROLLER_SUCCESS = 0, + + /** + * @error Invalid parameter. + */ + GAME_CONTROLLER_PARAM_ERROR = 401, + + /** + * @error Failed to query device information from the multi-mode input. + */ + GAME_CONTROLLER_MULTIMODAL_INPUT_ERROR = 32200001, + + /** + * @error There is no sufficient memory. + */ + GAME_CONTROLLER_NO_MEMORY = 32200002, +} GameController_ErrorCode; + +#ifdef __cplusplus +} +#endif + +#endif //GAME_CONTROLLER_TYPE_H +/** @} */ \ No newline at end of file diff --git a/GameControllerKit/game_device.h b/GameControllerKit/game_device.h new file mode 100644 index 00000000000..e8f05701c4f --- /dev/null +++ b/GameControllerKit/game_device.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup GameController + * @{ + * + * @brief Provides APIs for game controller capability. + * + * @since 18 + */ + +/** + * @file game_device.h + * @kit GameControllerKit + * @brief Defines game device capabilities APIs for game app. + * @library libohgame_controller.z.so + * @syscap SystemCapability.Game.GameController + * @since 18 + */ + +#ifndef GAME_DEVICE_H +#define GAME_DEVICE_H + +#include +#include "game_device_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines a struct for the calling result of {@link OH_GameDevice_GetAllDeviceInfos}. + * @since 18 + */ +typedef struct GameDevice_AllDeviceInfos GameDevice_AllDeviceInfos; + +/** + * @brief Obtains all online devices. + * @param allDeviceInfos Double pointer to the {@link GameDevice_AllDeviceInfos} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_MULTIMODALINPUT_ERROR} if the multimodal input is abnormal. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_GetAllDeviceInfos(GameDevice_AllDeviceInfos** allDeviceInfos); + +/** + * @brief Registers a monitor for the game device. + * @param deviceMonitorCallback Callback function, which is {@link GameDevice_DeviceMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_RegisterDeviceMonitor( + GameDevice_DeviceMonitorCallback deviceMonitorCallback); + +/** + * @brief Unregisters the monitor for the game device. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_UnregisterDeviceMonitor(void); + +/** + * @brief Destroys an {@link GameDevice_AllDeviceInfos} instance when it is no longer used. + * @param allDeviceInfos Double pointer to the {@link GameDevice_AllDeviceInfos} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of allDeviceInfos is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DestroyAllDeviceInfos(GameDevice_AllDeviceInfos** allDeviceInfos); + +/** + * @brief Obtains the number of devices. + * @param allDeviceInfos Pointer to the {@link GameDevice_AllDeviceInfos} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param count Pointer to the number of devices. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of allDeviceInfos is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_AllDeviceInfos_GetCount( + const struct GameDevice_AllDeviceInfos* allDeviceInfos, + int32_t* count); + +/** + * @brief Obtains information about a device with a specified index. + * @param allDeviceInfos Pointer to the {@link GameDevice_AllDeviceInfos} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param index Specified device index. + * @param deviceInfo Double pointer to the device information. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of allDeviceInfos is null, + * or the value of index is less than 0 or greater than or equal to the total number of devices. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_AllDeviceInfos_GetDeviceInfo( + const struct GameDevice_AllDeviceInfos* allDeviceInfos, + const int32_t index, + GameDevice_DeviceInfo** deviceInfo); + +#ifdef __cplusplus +} +#endif + +#endif //GAME_DEVICE_H +/** @} */ \ No newline at end of file diff --git a/GameControllerKit/game_device_event.h b/GameControllerKit/game_device_event.h new file mode 100644 index 00000000000..be5ab856883 --- /dev/null +++ b/GameControllerKit/game_device_event.h @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup GameController + * @{ + * + * @brief Provides APIs for game controller capability. + * + * @since 18 + */ + +/** + * @file game_device_event.h + * @kit GameControllerKit + * @brief Defines game device event APIs for game app. + * @library libohgame_controller.z.so + * @syscap SystemCapability.Game.GameController + * @since 18 + */ + +#ifndef GAME_DEVICE_EVENT_H +#define GAME_DEVICE_EVENT_H + +#include +#include "game_controller_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines device event changed type. + * @since 18 + */ +typedef enum GameDevice_StatusChangedType { + /** + * Indicates that the device is offline. + */ + OFFLINE = 0, + + /** + * Indicates that the device is online. + */ + ONLINE = 1, +} GameDevice_StatusChangedType; + +/** + * @brief Defines device type. + * @since 18 + */ +typedef enum GameDevice_DeviceType { + /** + * unknown + */ + UNKNOWN = 0, + + /** + * GamePad + */ + GAME_PAD = 1, +} GameDevice_DeviceType; + +/** + * @brief Defines a struct for the device information. + * @since 18 + */ +typedef struct GameDevice_DeviceInfo GameDevice_DeviceInfo; + +/** + * @brief Defines a struct for the device event. + * @since 18 + */ +typedef struct GameDevice_DeviceEvent GameDevice_DeviceEvent; + +/** + * @brief Defines a callback used in {@link OH_GameDevice_AddDeviceMonitor}. + * This function is called when a device goes online or offline. + * @param deviceEvent Pointer to the {@link GameDevice_DeviceEvent} instance. + * @since 18 + */ +typedef void(* GameDevice_DeviceMonitorCallback)(const struct GameDevice_DeviceEvent* deviceEvent); + +/** + * @brief Obtains the device event change type. + * @param deviceEvent Pointer to the {@link GameDevice_DeviceEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param statusChangedType Pointer to the device event change type. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} of the value of deviceEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceEvent_GetChangedType( + const struct GameDevice_DeviceEvent* deviceEvent, + GameDevice_StatusChangedType* statusChangedType); + +/** + * @brief Obtains device information from a device event. + * @param deviceEvent Pointer to the {@link GameDevice_DeviceEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param deviceInfo Double pointer to the device information. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} of the value of deviceEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceEvent_GetDeviceInfo( + const struct GameDevice_DeviceEvent* deviceEvent, + GameDevice_DeviceInfo** deviceInfo); + +/** + * @brief Destroys a {@link GameDevice_DeviceEvent} instance when it is no longer used. + * @param deviceEvent Double pointer to the {@link GameDevice_DeviceEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} of the value of deviceEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DestroyDeviceEvent(GameDevice_DeviceEvent** deviceEvent); + +/** + * @brief Destroys a {@link GameDevice_DeviceInfo} instance when it is no longer used. + * @param deviceInfo Double pointer to the {@link GameDevice_DeviceInfo} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceInfo is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DestroyDeviceInfo(GameDevice_DeviceInfo** deviceInfo); + +/** + * @brief Obtains the device ID from {@link GameDevice_DeviceInfo}. + * @param deviceInfo Pointer to the {@link GameDevice_DeviceInfo} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param deviceId Double pointer to the device ID. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceInfo is null. + * Returns {@link GAME_CONTROLLER_NO_MEMORY} if there is no sufficient memory. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceInfo_GetDeviceId(const struct GameDevice_DeviceInfo* deviceInfo, + char** deviceId); +/** + * @brief Obtains the device name from {@link GameDevice_DeviceInfo}. + * @param deviceInfo Pointer to the {@link GameDevice_DeviceInfo} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param name Double pointer to the device name. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceInfo is null. + * Returns {@link GAME_CONTROLLER_NO_MEMORY} if there is no sufficient memory. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceInfo_GetName(const struct GameDevice_DeviceInfo* deviceInfo, + char** name); +/** + * @brief Obtains product information from {@link GameDevice_DeviceInfo}. + * @param deviceInfo Pointer to the {@link GameDevice_DeviceInfo} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param product Pointer to the product information. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceInfo is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceInfo_GetProduct(const struct GameDevice_DeviceInfo* deviceInfo, + int32_t* product); + +/** + * @brief Obtains the version information from {@link GameDevice_DeviceInfo}. + * @param deviceInfo Pointer to the {@link GameDevice_DeviceInfo} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param version Pointer to the version information. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceInfo is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceInfo_GetVersion(const struct GameDevice_DeviceInfo* deviceInfo, + int32_t* version); + +/** + * @brief Obtains the physical address from {@link GameDevice_DeviceInfo}. + * @param deviceInfo Pointer to the {@link GameDevice_DeviceInfo} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param physicalAddress Double pointer to the physical address. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceInfo is null. + * Returns {@link GAME_CONTROLLER_NO_MEMORY} if there is no sufficient memory. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceInfo_GetPhysicalAddress(const struct GameDevice_DeviceInfo* deviceInfo, + char** physicalAddress); + +/** + * @brief Obtains the device type from {@link GameDevice_DeviceInfo}. + * @param deviceInfo Pointer to the {@link GameDevice_DeviceInfo} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param deviceType Pointer to the device type. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of deviceInfo is null. + * @since 18 + */ +GameController_ErrorCode OH_GameDevice_DeviceInfo_GetDeviceType(const struct GameDevice_DeviceInfo* deviceInfo, + GameDevice_DeviceType* deviceType); + +#ifdef __cplusplus +} +#endif + +#endif //GAME_DEVICE_EVENT_H +/** @} */ \ No newline at end of file diff --git a/GameControllerKit/game_pad.h b/GameControllerKit/game_pad.h new file mode 100644 index 00000000000..843ea95b2d4 --- /dev/null +++ b/GameControllerKit/game_pad.h @@ -0,0 +1,445 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup GameController + * @{ + * + * @brief Provides APIs for game controller capability. + * + * @since 18 + */ + +/** + * @file game_pad.h + * @kit GameControllerKit + * @brief Defines game pad capabilities APIs for game app. + * @library libohgame_controller.z.so + * @syscap SystemCapability.Game.GameController + * @since 18 + */ + +#ifndef GAME_PAD_H +#define GAME_PAD_H + +#include +#include "game_pad_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Registers a monitor for the left shoulder. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftShoulder_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the left shoulder. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftShoulder_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the right shoulder. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightShoulder_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the right shoulder. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightShoulder_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the left trigger. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return {@link GAME_CONTROLLER_SUCCESS}-The operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftTrigger_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the left trigger. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftTrigger_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the axis events of the left trigger. + * @param inputMonitorCallback Callback function, which is {@link GamePad_AxisInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftTrigger_RegisterAxisInputMonitor( + GamePad_AxisInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the axis events of the left trigger. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftTrigger_UnregisterAxisInputMonitor(void); + +/** + * @brief Registers a monitor for the right trigger. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightTrigger_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the right trigger. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightTrigger_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the axis events of the right trigger. + * @param inputMonitorCallback Callback function, which is {@link GamePad_AxisInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightTrigger_RegisterAxisInputMonitor( + GamePad_AxisInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the axis events of the right trigger. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightTrigger_UnregisterAxisInputMonitor(void); + +/** + * @brief Registers a monitor for the menu button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonMenu_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the menu button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonMenu_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the Home button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonHome_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the Home button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonHome_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the A button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonA_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the A button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonA_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the B button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonB_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the B button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonB_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the X button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonX_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the X button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonX_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the Y button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonY_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the Y button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonY_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the C button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonC_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the C button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonC_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the left button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_LeftButton_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the left button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_LeftButton_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the right button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_RightButton_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the right button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_RightButton_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the up button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_UpButton_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the up button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_UpButton_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the down button. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_DownButton_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the down button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_DownButton_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the axis events of directional buttons. + * @param inputMonitorCallback Callback function, which is {@link GamePad_AxisInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_RegisterAxisInputMonitor( + GamePad_AxisInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the axis events of directional buttons. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_Dpad_UnregisterAxisInputMonitor(void); + +/** + * @brief Registers a monitor for the button event of the left thumbstick. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftThumbstick_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the button event of the left thumbstick. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftThumbstick_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the axis events of the left thumbstick. + * @param inputMonitorCallback Callback function, which is {@link GamePad_AxisInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftThumbstick_RegisterAxisInputMonitor( + GamePad_AxisInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the axis events of the left thumbstick. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_LeftThumbstick_UnregisterAxisInputMonitor(void); + +/** + * @brief Registers a monitor for the button event of the right thumbstick. + * @param inputMonitorCallback Callback function, which is {@link GamePad_ButtonInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightThumbstick_RegisterButtonInputMonitor( + GamePad_ButtonInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the button event of the right thumbstick. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightThumbstick_UnregisterButtonInputMonitor(void); + +/** + * @brief Registers a monitor for the axis events of the right thumbstick. + * @param inputMonitorCallback Callback function, which is {@link GamePad_AxisInputMonitorCallback}. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of inputMonitorCallback is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightThumbstick_RegisterAxisInputMonitor( + GamePad_AxisInputMonitorCallback inputMonitorCallback); + +/** + * @brief Unregisters the monitor for the axis events of the right thumbstick. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_RightThumbstick_UnregisterAxisInputMonitor(void); + +#ifdef __cplusplus +} +#endif + +#endif //GAME_PAD_H +/** @} */ \ No newline at end of file diff --git a/GameControllerKit/game_pad_event.h b/GameControllerKit/game_pad_event.h new file mode 100644 index 00000000000..4a670b02c0a --- /dev/null +++ b/GameControllerKit/game_pad_event.h @@ -0,0 +1,402 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup GameController + * @{ + * + * @brief Provides APIs for game controller capability. + * + * @since 18 + */ + +/** + * @file game_pad_event.h + * @kit GameControllerKit + * @brief Defines game pad event APIs for game app. + * @library libohgame_controller.z.so + * @syscap SystemCapability.Game.GameController + * @since 18 + */ + +#ifndef GAME_PAD_EVENT_H +#define GAME_PAD_EVENT_H + +#include +#include "game_controller_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the source of axis event. + * @since 18 + */ +typedef enum GamePad_AxisSourceType { + /** + * Indicates the axis event from directional pad. + */ + DPAD = 0, + + /** + * Indicates the axis event from left thumbstick. + */ + LEFT_THUMBSTICK = 1, + + /** + * Indicates the axis event from right thumbstick. + */ + RIGHT_THUMBSTICK = 2, + + /** + * Indicates the axis event from left trigger. + */ + LEFT_TRIGGER = 3, + + /** + * Indicates the axis event from rihgt trigger.. + */ + RIGHT_TRIGGER = 4, +} GamePad_AxisSourceType; + +/** + * @brief Defines action type of button. + * @since 18 + */ +typedef enum GamePad_Button_ActionType { + /** + * Pressing of a key + */ + DOWN = 0, + + /** + * Release of a key + */ + UP = 1, +} GamePad_Button_ActionType; + +/** + * @brief Defines a struct for the button event of a game pad. + * @since 18 + */ +typedef struct GamePad_ButtonEvent GamePad_ButtonEvent; + +/** + * @brief Defines a struct for the axis events of a game pad. + * @since 18 + */ +typedef struct GamePad_AxisEvent GamePad_AxisEvent; + +/** + * @brief Defines a struct for the pressed button of a game pad. + * @since 18 + */ +typedef struct GamePad_PressedButton GamePad_PressedButton; + +/** + * @brief Defines a callback used in the monitor for the game pad button event. + * This function is called when a game pad button is pressed. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * @since 18 + */ +typedef void(* GamePad_ButtonInputMonitorCallback)(const struct GamePad_ButtonEvent* buttonEvent); + +/** + * @brief Defines a callback used in {@link OH_GamePad_AddAxisInputMonitor}. + * This function is called when the game pad axis is operated. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * @since 18 + */ +typedef void(* GamePad_AxisInputMonitorCallback)(const struct GamePad_AxisEvent* axisEvent); + +/** + * @brief Destroys a {@link GamePad_ButtonEvent} instance when it is no longer used. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_DestroyButtonEvent(GamePad_ButtonEvent** buttonEvent); + +/** + * @brief Obtains the device ID from {@link GamePad_ButtonEvent}. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param deviceId Double pointer to the device ID. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null. + * Returns {@link GAME_CONTROLLER_NO_MEMORY} if there is no sufficient memory. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonEvent_GetDeviceId(const struct GamePad_ButtonEvent* buttonEvent, + char** deviceId); + +/** + * @brief Obtains the button action type from {@link GamePad_ButtonEvent}. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param actionType Pointer to the action type. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonAction(const struct GamePad_ButtonEvent* buttonEvent, + GamePad_Button_ActionType* actionType); +/** + * @brief Obtains the button code from {@link GamePad_ButtonEvent}. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param code Pointer to the button code. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonCode(const struct GamePad_ButtonEvent* buttonEvent, + int32_t* code); +/** + * @brief Obtains the button name from {@link GamePad_ButtonEvent}. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param codeName Double pointer to the button name. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null. + * Returns {@link GAME_CONTROLLER_NO_MEMORY} if there is no sufficient memory. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonEvent_GetButtonCodeName(const struct GamePad_ButtonEvent* buttonEvent, + char** codeName); + +/** + * @brief Obtains the number of pressed buttons from {@link GamePad_ButtonEvent}. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param count Pointer to the number of pressed buttons. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_PressedButtons_GetCount(const struct GamePad_ButtonEvent* buttonEvent, + int32_t* count); + +/** + * @brief Obtains the button with a specified index from {@link GamePad_ButtonEvent}. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param index Specified button index. + * @param pressedButton Double pointer to the pressed button. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null, + * or if the value of index is less than 0 or greater than or equal to the total number of buttons. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_PressedButtons_GetButtonInfo(const struct GamePad_ButtonEvent* buttonEvent, + const int32_t index, + GamePad_PressedButton** pressedButton); + +/** + * @brief Destroys a {@link GamePad_PressedButton} instance when it is no longer used. + * @param pressedButton Double pointer to the {@link GamePad_PressedButton} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of pressedButton is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_DestroyPressedButton(GamePad_PressedButton** pressedButton); + +/** + * @brief Obtains the button code from {@link GamePad_PressedButton}. + * @param pressedButton Pointer to the {@link GamePad_PressedButton} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param code Pointer to the button code. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of pressedButton is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_PressedButton_GetButtonCode(const struct GamePad_PressedButton* pressedButton, + int32_t* code); + +/** + * @brief Obtains the button name from {@link GamePad_PressedButton}. + * @param pressedButton Pointer to the {@link GamePad_PressedButton} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param codeName Double pointer to the button name. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of pressedButton is null. + * Returns {@link GAME_CONTROLLER_NO_MEMORY} if there is no sufficient memory. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_PressedButton_GetButtonCodeName(const struct GamePad_PressedButton* pressedButton, + char** codeName); +/** + * @brief Obtains the action time from {@link GamePad_ButtonEvent}. + * @param buttonEvent Pointer to the {@link GamePad_ButtonEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param actionTime Pointer to the action time. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of buttonEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_ButtonEvent_GetActionTime(const struct GamePad_ButtonEvent* buttonEvent, + int64_t* actionTime); + +/** + * @brief Destroys a {@link GamePad_AxisEvent} instance when it is no longer used. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_DestroyAxisEvent(GamePad_AxisEvent** axisEvent); + +/** + * @brief Obtains the device ID from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param deviceId Double pointer to the device ID. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * Returns {@link GAME_CONTROLLER_NO_MEMORY} if there is no sufficient memory. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetDeviceId(const struct GamePad_AxisEvent* axisEvent, + char** deviceId); + +/** + * @brief Obtains the axis type from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisSourceType Pointer to the {@link GamePad_AxisSourceType} instance. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetAxisSourceType(const struct GamePad_AxisEvent* axisEvent, + GamePad_AxisSourceType* axisSourceType); + +/** + * @brief Obtains the value of the X axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetXAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); +/** + * @brief Obtains the value of the Y axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetYAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); + +/** + * @brief Obtains the value of the Z axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetZAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); + +/** + * @brief Obtains the value of the RZ axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetRZAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); + +/** + * @brief Obtains the value of the HatX axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetHatXAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); + +/** + * @brief Obtains the value of the HatY axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetHatYAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); + +/** + * @brief Obtains the value of the Brake axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetBrakeAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); + +/** + * @brief Obtains the value of the Gas axis from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param axisValue Pointer to the axis value. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetGasAxisValue(const struct GamePad_AxisEvent* axisEvent, + double* axisValue); +/** + * @brief Obtains the action time from {@link GamePad_AxisEvent}. + * @param axisEvent Pointer to the {@link GamePad_AxisEvent} instance. + * The value cannot be null. Otherwise, an error code is returned. + * @param actionTime Pointer to the action time. + * @return Returns {@link GAME_CONTROLLER_SUCCESS} if the operation is successful. + * Returns {@link GAME_CONTROLLER_PARAM_ERROR} if the value of axisEvent is null. + * @since 18 + */ +GameController_ErrorCode OH_GamePad_AxisEvent_GetActionTime(const struct GamePad_AxisEvent* axisEvent, + int64_t* actionTime); + +#ifdef __cplusplus +} +#endif + +#endif //GAME_PAD_EVENT_H +/** @} */ \ No newline at end of file diff --git a/GameControllerKit/libohgame_controller.ndk.json b/GameControllerKit/libohgame_controller.ndk.json new file mode 100644 index 00000000000..b01bc69350b --- /dev/null +++ b/GameControllerKit/libohgame_controller.ndk.json @@ -0,0 +1,334 @@ +[ + { + "first_introduced": "18", + "name": "OH_GamePad_DestroyButtonEvent" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonEvent_GetDeviceId" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonEvent_GetButtonAction" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonEvent_GetButtonCode" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonEvent_GetButtonCodeName" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_PressedButtons_GetCount" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_PressedButtons_GetButtonInfo" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_DestroyPressedButton" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_PressedButton_GetButtonCode" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_PressedButton_GetButtonCodeName" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonEvent_GetActionTime" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_DestroyAxisEvent" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetDeviceId" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetAxisSourceType" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetXAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetYAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetZAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetRZAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetHatXAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetHatYAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetBrakeAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetGasAxisValue" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_AxisEvent_GetActionTime" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftShoulder_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftShoulder_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightShoulder_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightShoulder_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftTrigger_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftTrigger_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftTrigger_RegisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftTrigger_UnregisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightTrigger_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightTrigger_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightTrigger_RegisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightTrigger_UnregisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonMenu_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonMenu_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonHome_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonHome_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonA_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonA_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonB_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonB_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonC_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonC_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonX_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonX_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonY_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_ButtonY_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_LeftButton_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_LeftButton_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_RightButton_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_RightButton_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_UpButton_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_UpButton_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_DownButton_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_DownButton_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_RegisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_Dpad_UnregisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftThumbstick_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftThumbstick_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftThumbstick_RegisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_LeftThumbstick_UnregisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightThumbstick_RegisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightThumbstick_UnregisterButtonInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightThumbstick_RegisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GamePad_RightThumbstick_UnregisterAxisInputMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_GetAllDeviceInfos" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_RegisterDeviceMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_UnregisterDeviceMonitor" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DestroyAllDeviceInfos" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_AllDeviceInfos_GetCount" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_AllDeviceInfos_GetDeviceInfo" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceEvent_GetChangedType" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceEvent_GetDeviceInfo" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DestroyDeviceEvent" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DestroyDeviceInfo" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceInfo_GetDeviceId" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceInfo_GetName" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceInfo_GetProduct" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceInfo_GetVersion" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceInfo_GetPhysicalAddress" + }, + { + "first_introduced": "18", + "name": "OH_GameDevice_DeviceInfo_GetDeviceType" + } +] \ No newline at end of file diff --git a/ndk_targets.gni b/ndk_targets.gni index 25da4956f0e..6319be27470 100644 --- a/ndk_targets.gni +++ b/ndk_targets.gni @@ -254,6 +254,8 @@ _ndk_library_targets = [ "//interface/sdk_c/telephony/core_service:telephony_radio_header", "//interface/sdk_c/ConnectivityKit/wifi:libwifi_ndk", "//interface/sdk_c/ConnectivityKit/wifi:wifi_ndk_header", + "//interface/sdk_c/GameControllerKit/wifi:ohgame_controller_header", + "//interface/sdk_c/GameControllerKit/wifi:libohgame_controller", ] _ndk_base_libs = [ -- Gitee From 7a8ba3beaede6b30213bed0f65452e76cf8a371d Mon Sep 17 00:00:00 2001 From: jinsitao Date: Fri, 21 Mar 2025 09:26:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9EGameControllerKit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinsitao --- ndk_targets.gni | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndk_targets.gni b/ndk_targets.gni index 6319be27470..e6f3218e21e 100644 --- a/ndk_targets.gni +++ b/ndk_targets.gni @@ -254,8 +254,8 @@ _ndk_library_targets = [ "//interface/sdk_c/telephony/core_service:telephony_radio_header", "//interface/sdk_c/ConnectivityKit/wifi:libwifi_ndk", "//interface/sdk_c/ConnectivityKit/wifi:wifi_ndk_header", - "//interface/sdk_c/GameControllerKit/wifi:ohgame_controller_header", - "//interface/sdk_c/GameControllerKit/wifi:libohgame_controller", + "//interface/sdk_c/GameControllerKit:ohgame_controller_header", + "//interface/sdk_c/GameControllerKit:libohgame_controller", ] _ndk_base_libs = [ -- Gitee From f23a7c9b3f72476c378992f3bc389877366b1644 Mon Sep 17 00:00:00 2001 From: jinsitao Date: Fri, 21 Mar 2025 09:59:48 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=A2=9EGameControllerKit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinsitao --- GameControllerKit/BUILD.gn | 2 +- GameControllerKit/game_controller_type.h | 5 +++-- GameControllerKit/game_device.h | 1 + GameControllerKit/game_device_event.h | 5 +++-- GameControllerKit/game_pad.h | 1 + GameControllerKit/game_pad_event.h | 5 +++-- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/GameControllerKit/BUILD.gn b/GameControllerKit/BUILD.gn index 73278e0ce61..3206e1b39d5 100644 --- a/GameControllerKit/BUILD.gn +++ b/GameControllerKit/BUILD.gn @@ -38,4 +38,4 @@ ohos_ndk_library("libohgame_controller") { "game_pad_event.h", "game_pad.h", ] -} \ No newline at end of file +} diff --git a/GameControllerKit/game_controller_type.h b/GameControllerKit/game_controller_type.h index 4d5edd292b4..046b054b05b 100644 --- a/GameControllerKit/game_controller_type.h +++ b/GameControllerKit/game_controller_type.h @@ -35,12 +35,13 @@ #define GAME_CONTROLLER_TYPE_H #include +#include #ifdef __cplusplus extern "C" { #endif /** - * @brief Defines ErrorCode. + * @brief Defines an enum for the error codes of GameController. * @since 18 */ typedef enum GameController_ErrorCode { @@ -60,7 +61,7 @@ extern "C" { GAME_CONTROLLER_MULTIMODAL_INPUT_ERROR = 32200001, /** - * @error There is no sufficient memory. + * @error No memory. */ GAME_CONTROLLER_NO_MEMORY = 32200002, } GameController_ErrorCode; diff --git a/GameControllerKit/game_device.h b/GameControllerKit/game_device.h index e8f05701c4f..90481b4de08 100644 --- a/GameControllerKit/game_device.h +++ b/GameControllerKit/game_device.h @@ -35,6 +35,7 @@ #define GAME_DEVICE_H #include +#include #include "game_device_event.h" #ifdef __cplusplus diff --git a/GameControllerKit/game_device_event.h b/GameControllerKit/game_device_event.h index be5ab856883..b7720155027 100644 --- a/GameControllerKit/game_device_event.h +++ b/GameControllerKit/game_device_event.h @@ -35,6 +35,7 @@ #define GAME_DEVICE_EVENT_H #include +#include #include "game_controller_type.h" #ifdef __cplusplus @@ -42,7 +43,7 @@ extern "C" { #endif /** - * @brief Defines device event changed type. + * @brief Defines an enum for the device status change types. * @since 18 */ typedef enum GameDevice_StatusChangedType { @@ -58,7 +59,7 @@ typedef enum GameDevice_StatusChangedType { } GameDevice_StatusChangedType; /** - * @brief Defines device type. + * @brief Defines an enum for the device types. * @since 18 */ typedef enum GameDevice_DeviceType { diff --git a/GameControllerKit/game_pad.h b/GameControllerKit/game_pad.h index 843ea95b2d4..f373313dcc5 100644 --- a/GameControllerKit/game_pad.h +++ b/GameControllerKit/game_pad.h @@ -35,6 +35,7 @@ #define GAME_PAD_H #include +#include #include "game_pad_event.h" #ifdef __cplusplus diff --git a/GameControllerKit/game_pad_event.h b/GameControllerKit/game_pad_event.h index 4a670b02c0a..25144becf44 100644 --- a/GameControllerKit/game_pad_event.h +++ b/GameControllerKit/game_pad_event.h @@ -35,6 +35,7 @@ #define GAME_PAD_EVENT_H #include +#include #include "game_controller_type.h" #ifdef __cplusplus @@ -42,7 +43,7 @@ extern "C" { #endif /** - * @brief Defines the source of axis event. + * @brief Defines an enum for the axis events sources. * @since 18 */ typedef enum GamePad_AxisSourceType { @@ -73,7 +74,7 @@ typedef enum GamePad_AxisSourceType { } GamePad_AxisSourceType; /** - * @brief Defines action type of button. + * @brief Defines an enum for the button action types. * @since 18 */ typedef enum GamePad_Button_ActionType { -- Gitee From 9bf68368f7ba1aad29bc5f5dd1cb2c635a7595fb Mon Sep 17 00:00:00 2001 From: jinsitao Date: Fri, 21 Mar 2025 13:44:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=96=B0=E5=A2=9EGameControllerKit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinsitao --- GameControllerKit/game_controller_type.h | 35 ++++++++++++------------ GameControllerKit/game_device.h | 1 - GameControllerKit/game_device_event.h | 1 - GameControllerKit/game_pad.h | 1 - GameControllerKit/game_pad_event.h | 1 - 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/GameControllerKit/game_controller_type.h b/GameControllerKit/game_controller_type.h index 046b054b05b..1856c7c1c3a 100644 --- a/GameControllerKit/game_controller_type.h +++ b/GameControllerKit/game_controller_type.h @@ -35,7 +35,6 @@ #define GAME_CONTROLLER_TYPE_H #include -#include #ifdef __cplusplus extern "C" { @@ -44,26 +43,26 @@ extern "C" { * @brief Defines an enum for the error codes of GameController. * @since 18 */ - typedef enum GameController_ErrorCode { - /** - * Success. - */ - GAME_CONTROLLER_SUCCESS = 0, +typedef enum GameController_ErrorCode { + /** + * Success. + */ + GAME_CONTROLLER_SUCCESS = 0, - /** - * @error Invalid parameter. - */ - GAME_CONTROLLER_PARAM_ERROR = 401, + /** + * @error Invalid parameter. + */ + GAME_CONTROLLER_PARAM_ERROR = 401, - /** - * @error Failed to query device information from the multi-mode input. - */ - GAME_CONTROLLER_MULTIMODAL_INPUT_ERROR = 32200001, + /** + * @error Failed to query device information from the multi-mode input. + */ + GAME_CONTROLLER_MULTIMODAL_INPUT_ERROR = 32200001, - /** - * @error No memory. - */ - GAME_CONTROLLER_NO_MEMORY = 32200002, + /** + * @error No memory + */ + GAME_CONTROLLER_NO_MEMORY = 32200002, } GameController_ErrorCode; #ifdef __cplusplus diff --git a/GameControllerKit/game_device.h b/GameControllerKit/game_device.h index 90481b4de08..e8f05701c4f 100644 --- a/GameControllerKit/game_device.h +++ b/GameControllerKit/game_device.h @@ -35,7 +35,6 @@ #define GAME_DEVICE_H #include -#include #include "game_device_event.h" #ifdef __cplusplus diff --git a/GameControllerKit/game_device_event.h b/GameControllerKit/game_device_event.h index b7720155027..129243dd43a 100644 --- a/GameControllerKit/game_device_event.h +++ b/GameControllerKit/game_device_event.h @@ -35,7 +35,6 @@ #define GAME_DEVICE_EVENT_H #include -#include #include "game_controller_type.h" #ifdef __cplusplus diff --git a/GameControllerKit/game_pad.h b/GameControllerKit/game_pad.h index f373313dcc5..843ea95b2d4 100644 --- a/GameControllerKit/game_pad.h +++ b/GameControllerKit/game_pad.h @@ -35,7 +35,6 @@ #define GAME_PAD_H #include -#include #include "game_pad_event.h" #ifdef __cplusplus diff --git a/GameControllerKit/game_pad_event.h b/GameControllerKit/game_pad_event.h index 25144becf44..879f45adb4e 100644 --- a/GameControllerKit/game_pad_event.h +++ b/GameControllerKit/game_pad_event.h @@ -35,7 +35,6 @@ #define GAME_PAD_EVENT_H #include -#include #include "game_controller_type.h" #ifdef __cplusplus -- Gitee