1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup Vibrator 18 * @{ 19 * 20 * @brief Provides the enums, structs, and error codes used in the vibrator APIs. 21 * @since 11 22 */ 23 24 /** 25 * @file vibrator_type.h 26 * @kit SensorServiceKit 27 * @brief Declares the common vibrator attributes. 28 * @library libohvibrator.z.so 29 * @syscap SystemCapability.Sensors.MiscDevice 30 * @since 11 31 */ 32 33 34 #ifndef VIBRATOR_TYPE_H 35 #define VIBRATOR_TYPE_H 36 37 #ifdef __cplusplus 38 #include <cstdint> 39 #else 40 #include <stdint.h> 41 #endif 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @brief Defines an enum that enumerates the error codes. 49 * 50 * @since 11 51 */ 52 typedef enum Vibrator_ErrorCode : int32_t { 53 /**< @error Permission verification failed. */ 54 PERMISSION_DENIED = 201, 55 /**< @error Parameter check failed. For example, a mandatory parameter is not passed in, 56 * or the parameter type passed in is incorrect. */ 57 PARAMETER_ERROR = 401, 58 /**< @error The API is not supported on the device. The device supports the corresponding SysCap, 59 * but does not support certain APIs in this SysCap. */ 60 UNSUPPORTED = 801, 61 /**< @error The operation on the device failed. */ 62 DEVICE_OPERATION_FAILED = 14600101, 63 } Vibrator_ErrorCode; 64 65 /** 66 * @brief Enumerates vibration usages scenarios. 67 * 68 * @since 11 69 */ 70 typedef enum Vibrator_Usage { 71 VIBRATOR_USAGE_UNKNOWN = 0, /**< Vibration is used for unknown, lowest priority */ 72 VIBRATOR_USAGE_ALARM = 1, /**< Vibration is used for alarm */ 73 VIBRATOR_USAGE_RING = 2, /**< Vibration is used for ring */ 74 VIBRATOR_USAGE_NOTIFICATION = 3, /**< Vibration is used for notification */ 75 VIBRATOR_USAGE_COMMUNICATION = 4, /**< Vibration is used for communication */ 76 VIBRATOR_USAGE_TOUCH = 5, /**< Vibration is used for touch */ 77 VIBRATOR_USAGE_MEDIA = 6, /**< Vibration is used for media */ 78 VIBRATOR_USAGE_PHYSICAL_FEEDBACK = 7, /**< Vibration is used for physical feedback */ 79 VIBRATOR_USAGE_SIMULATED_REALITY = 8, /**< Vibration is used for simulate reality */ 80 VIBRATOR_USAGE_MAX 81 } Vibrator_Usage; 82 83 /** 84 * @brief Defines the vibrator attribute. 85 * 86 * @since 11 87 */ 88 typedef struct Vibrator_Attribute { 89 /**< Vibrator ID. */ 90 int32_t vibratorId; 91 /**< Vibration scenario. */ 92 Vibrator_Usage usage; 93 } Vibrator_Attribute; 94 95 /** 96 * @brief Defines the vibration file description. 97 * 98 * @since 11 99 */ 100 typedef struct Vibrator_FileDescription { 101 /**< File handle of the custom vibration sequence. */ 102 int32_t fd; 103 /**< Offset address of the custom vibration sequence. */ 104 int64_t offset; 105 /**< Total length of the custom vibration sequence. */ 106 int64_t length; 107 } Vibrator_FileDescription; 108 #ifdef __cplusplus 109 } 110 #endif 111 /** @} */ 112 #endif // endif VIBRATOR_TYPE_H