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