1 /* 2 * Copyright (c) 2021-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 #ifndef VIBRATOR_AGENT_TYPE_H 17 #define VIBRATOR_AGENT_TYPE_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * @brief Describes the vibration effect of the vibrator when a user adjusts the timer. 25 * 26 * @since 1 27 */ 28 const char *VIBRATOR_TYPE_CLOCK_TIMER = "haptic.clock.timer"; 29 30 /** 31 * @brief Describes the vibration effect of the vibrator when authentication fails. 32 * 33 * @since 11 34 */ 35 const char *VIBRATOR_TYPE_FAIL = "haptic.fail"; 36 37 /** 38 * @brief Describes the vibration effect of the vibrator when charging. 39 * 40 * @since 11 41 */ 42 const char *VIBRATOR_TYPE_CHARGING = "haptic.charging"; 43 44 /** 45 * @brief Describes the vibration effect of the vibrator when long pressed. 46 * 47 * @since 11 48 */ 49 const char *VIBRATOR_TYPE_LONG_PRESS_LIGHT = "haptic.long_press.light"; 50 51 /** 52 * @brief Describes the vibration effect of the vibrator when long pressed. 53 * 54 * @since 11 55 */ 56 const char *VIBRATOR_TYPE_LONG_PRESS_MEDIUM = "haptic.long_press.medium"; 57 58 /** 59 * @brief Describes the vibration effect of the vibrator when long pressed. 60 * 61 * @since 11 62 */ 63 const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press.heavy"; 64 65 /** 66 * @brief Describes the vibration effect of the vibrator when slide. 67 * 68 * @since 11 69 */ 70 const char *VIBRATOR_TYPE_SLIDE_LIGHT = "haptic.slide.light"; 71 72 /** 73 * @brief Describes the vibration effect of the vibrator when the threshold is reached. 74 * 75 * @since 11 76 */ 77 const char *VIBRATOR_TYPE_THRESHOID = "haptic.threshold"; 78 79 /** 80 * @brief Enumerates vibration usages. 81 * 82 * @since 9 83 */ 84 typedef enum VibratorUsage { 85 USAGE_UNKNOWN = 0, /**< Vibration is used for unknown, lowest priority */ 86 USAGE_ALARM = 1, /**< Vibration is used for alarm */ 87 USAGE_RING = 2, /**< Vibration is used for ring */ 88 USAGE_NOTIFICATION = 3, /**< Vibration is used for notification */ 89 USAGE_COMMUNICATION = 4, /**< Vibration is used for communication */ 90 USAGE_TOUCH = 5, /**< Vibration is used for touch */ 91 USAGE_MEDIA = 6, /**< Vibration is used for media */ 92 USAGE_PHYSICAL_FEEDBACK = 7, /**< Vibration is used for physical feedback */ 93 USAGE_SIMULATE_REALITY = 8, /**< Vibration is used for simulate reality */ 94 USAGE_MAX 95 } VibratorUsage; 96 97 /** 98 * @brief Vibration effect description file. 99 * 100 * @since 11 101 */ 102 typedef struct VibratorFileDescription { 103 int32_t fd = -1; 104 int64_t offset = -1; 105 int64_t length = -1; 106 } VibratorFileDescription; 107 108 /** 109 * @brief The type of vibration event. 110 * 111 * @since 11 112 */ 113 typedef enum VibratorEventType { 114 EVENT_TYPE_UNKNOWN = -1, /**< Unknown vibration event type */ 115 EVENT_TYPE_CONTINUOUS = 0, /**< Continuous vibration event type */ 116 EVENT_TYPE_TRANSIENT = 1, /**< Transient vibration event type */ 117 } VibratorEventType; 118 119 /** 120 * @brief Vibration curve adjustment point. 121 * 122 * @since 11 123 */ 124 typedef struct VibratorCurvePoint { 125 int32_t time = -1; 126 int32_t intensity = -1; 127 int32_t frequency = -1; 128 } VibratorCurvePoint; 129 130 /** 131 * @brief The vibration event. 132 * 133 * @since 11 134 */ 135 typedef struct VibratorEvent { 136 VibratorEventType type = EVENT_TYPE_UNKNOWN; 137 int32_t time = -1; 138 int32_t duration = -1; 139 int32_t intensity = -1; 140 int32_t frequency = -1; 141 int32_t index = 0; // 0:both 1:left 2:right 142 int32_t pointNum = 0; 143 VibratorCurvePoint *points = nullptr; 144 } VibratorEvent; 145 146 /** 147 * @brief Describe the vibration pattern, including the vibration event sequence. 148 * 149 * @since 11 150 */ 151 typedef struct VibratorPattern { 152 int32_t time = -1; 153 int32_t eventNum = 0; 154 VibratorEvent *events = nullptr; 155 } VibratorPattern; 156 157 /** 158 * @brief Describes the vibration package structure, including the vibration pattern sequence. 159 * 160 * @since 11 161 */ 162 typedef struct VibratorPackage { 163 int32_t patternNum = 0; // pattern 164 VibratorPattern *patterns = nullptr; 165 } VibratorPackage; 166 167 /** 168 * @brief Vibration effect adjustment parameters. 169 * 170 * @since 11 171 */ 172 typedef struct VibratorParameter { 173 int32_t intensity = 100; // from 0 to 100 174 int32_t frequency = 0; // from -100 to 100 175 int32_t reserved = 0; 176 } VibratorParameter; 177 /** @} */ 178 #ifdef __cplusplus 179 }; 180 #endif 181 182 #endif // endif VIBRATOR_AGENT_TYPE_H