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 #ifndef VIBRATOR_TYPE_H
34 #define VIBRATOR_TYPE_H
35 
36 #ifdef __cplusplus
37 #include <cstdint>
38 #else
39 #include <stdint.h>
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47 * @brief Defines an enum that enumerates the error codes.
48 *
49 * @since 11
50 */
51 typedef enum Vibrator_ErrorCode : int32_t {
52     /**< Permission verification failed. */
53     PERMISSION_DENIED = 201,
54     /**< Parameter check failed. For example, a mandatory parameter is not passed in,
55      * or the parameter type passed in is incorrect. */
56     PARAMETER_ERROR = 401,
57     /**< The API is not supported on the device. The device supports the corresponding SysCap,
58      * but does not support certain APIs in this SysCap. */
59     UNSUPPORTED = 801,
60     /**< The operation on the device failed. */
61     DEVICE_OPERATION_FAILED = 14600101,
62 } Vibrator_ErrorCode;
63 
64 /**
65  * @brief Enumerates vibration usages scenarios.
66  *
67  * @since 11
68  */
69 typedef enum Vibrator_Usage {
70     VIBRATOR_USAGE_UNKNOWN = 0,            /**< Vibration is used for unknown, lowest priority */
71     VIBRATOR_USAGE_ALARM = 1,              /**< Vibration is used for alarm */
72     VIBRATOR_USAGE_RING = 2,               /**< Vibration is used for ring */
73     VIBRATOR_USAGE_NOTIFICATION = 3,       /**< Vibration is used for notification */
74     VIBRATOR_USAGE_COMMUNICATION = 4,      /**< Vibration is used for communication */
75     VIBRATOR_USAGE_TOUCH = 5,              /**< Vibration is used for touch */
76     VIBRATOR_USAGE_MEDIA = 6,              /**< Vibration is used for media */
77     VIBRATOR_USAGE_PHYSICAL_FEEDBACK = 7,  /**< Vibration is used for physical feedback */
78     VIBRATOR_USAGE_SIMULATED_REALITY = 8,   /**< Vibration is used for simulate reality */
79     VIBRATOR_USAGE_MAX
80 } Vibrator_Usage;
81 
82 /**
83  * @brief Defines the vibrator attribute.
84  *
85  * @since 11
86  */
87 typedef struct Vibrator_Attribute {
88     /**< Vibrator ID. */
89     int32_t vibratorId = -1;
90     /**< Vibration scenario. */
91     Vibrator_Usage usage = VIBRATOR_USAGE_MAX;
92 } Vibrator_Attribute;
93 
94 /**
95  * @brief Defines the vibration file description.
96  *
97  * @since 11
98  */
99 typedef struct Vibrator_FileDescription {
100     /**< File handle of the custom vibration sequence. */
101     int32_t fd = -1;
102     /**< Offset address of the custom vibration sequence. */
103     int64_t offset = -1;
104     /**< Total length of the custom vibration sequence. */
105     int64_t length = -1;
106 } Vibrator_FileDescription;
107 #ifdef __cplusplus
108 }
109 #endif
110 /** @} */
111 #endif  // endif VIBRATOR_TYPE_H