2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #ifndef __TIZEN_SYSTEM_HAPTIC_H__
21 #define __TIZEN_SYSTEM_HAPTIC_H__
23 #include <tizen_error.h>
30 * @addtogroup CAPI_SYSTEM_HAPTIC_MODULE
33 * This is a Haptic API of the System Service.
38 * @addtogroup CAPI_SYSTEM_HAPTIC_MODULE
43 * @brief Enumerations of feedback level for haptic.
44 * @details Haptic level means vibration power (intensity).
48 HAPTIC_LEVEL_AUTO = -1, /**< vibration level from settings */
49 HAPTIC_LEVEL_0 = 0, /**< vibration level 0 (silence) */
50 HAPTIC_LEVEL_1 = 20, /**< vibration level 1 (the lowest) */
51 HAPTIC_LEVEL_2 = 40, /**< vibration level 2 (low)*/
52 HAPTIC_LEVEL_3 = 60, /**< vibration level 3 (middle) */
53 HAPTIC_LEVEL_4 = 80, /**< vibration level 4 (high) */
54 HAPTIC_LEVEL_5 = 100, /**< vibration level 5 (the highest) */
58 * @brief Enumerations of error codes for the Haptic API.
62 HAPTIC_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
63 HAPTIC_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
64 HAPTIC_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file */
65 HAPTIC_ERROR_NOT_SUPPORTED_FORMAT = TIZEN_ERROR_SYSTEM_CLASS | 0x23, /**< Not supported file format */
66 HAPTIC_ERROR_NOT_INITIALIZED = TIZEN_ERROR_SYSTEM_CLASS | 0x26, /**< Not initialized */
67 HAPTIC_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x28, /**< Operation failed */
72 * @brief The structure type to contain the set of vibration data
73 * that used for generate a iteration of vibration.
75 * @see haptic_play_pattern()
79 int vibrator_index; /**< Index of the vibrator */
80 int time; /**< Duration of the vibration in a iteration */
81 } haptic_vibration_iter_s;
84 * @brief Gets the number of the vibrators.
86 * @remarks The index zero is reserved meaning for all vibrators at a time.
88 * @param[out] vibrator_number A number of vibrators
90 * @return 0 on success, otherwise a negative error value.
91 * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
93 int haptic_get_count(int* vibrator_number);
96 * @brief Initializes haptic API.
98 * @details Internally, it makes a connection to the vibrator.
100 * @remarks If this function is not called in advance, other functions will return #HAPTIC_ERROR_NOT_INITIALIZED.
101 * @remarks Haptic API must be deinitialized by haptic_deinitialize().
103 * @return 0 on success, otherwise a negative error value.
104 * @retval #HAPTIC_ERROR_NONE Successful
105 * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
107 * @see haptic_deinitialize()
109 int haptic_initialize(void);
112 * @brief Deinitializes haptic API.
114 * @details Internally, it disconnects the connection to vibrator.
116 * @return 0 on success, otherwise a negative error value.
117 * @retval #HAPTIC_ERROR_NONE Successful
118 * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
120 * @see haptic_initialize()
122 int haptic_deinitialize(void);
125 * @brief Vibrates during the specified time with a constant intensity.
127 * This function can be used to start monotonous vibration for specified time.\n
128 * Default value of intensity is used.\n
131 * level is intensity variation of vibration. it has a value from 0 to 100.\n
132 * level -1 is reserved for auto changing to saved variable in the settings.
134 * @param[in] vibrator_index The index of the vibrator.\n
135 * The index of the first vibrator is 1.\n
136 * 0 is reserved for every vibrators at once.
137 * @param[in] duration_ms The play duration in milliseconds
138 * @param[in] level The amount of the intensity variation
140 * @return 0 on success, otherwise a negative error value.
141 * @retval #HAPTIC_ERROR_NONE Successful
142 * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter
143 * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
144 * @retval #HAPTIC_ERROR_NOT_INITIALIZED Not initialized
146 * @see haptic_stop_device()
147 * @see haptic_vibrate_file()
148 * @see haptic_get_count()
150 int haptic_vibrate_monotone(int vibrator_index, int duration_ms, int level);
153 * @brief Stops the current vibration which is being played.
154 * @details This function can be used to stop vibration started by haptic_vibrate_file(), or haptic_vibrate_monotone().
156 * @remarks You must use haptic_stop_pattern() to stop the vibration pattern from haptic_play_pattern();
158 * @param[in] vibrator_index The index of the vibrator.\n
159 * The index of the first vibrator is 1.\n
160 * 0 is reserved for every vibrators at once.
162 * @return 0 on success, otherwise a negative error value.
163 * @retval #HAPTIC_ERROR_NONE Successful
164 * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter
165 * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
166 * @retval #HAPTIC_ERROR_NOT_INITIALIZED Not initialized
168 * @see haptic_vibrate_file()
169 * @see haptic_vibrate_monotone()
170 * @see haptic_get_count()
172 int haptic_stop_device(int vibrator_index);
175 * @brief Starts playing the pattern of continuous vibration data.
177 * Each vibration data has index of vibrator and duration time. \n
178 * Vibration data plays continuously in order of specific array. \n
179 * This function returns the ID of playing session if it succeeds.
180 * This ID can be used to stop playing iterations.
183 * level is intensity variation of vibration. it has a value from 0 to 100.\n
184 * level -1 is reserved for auto changing to saved variable in the settings.
186 * @param[in] pattern The array of the vibration data
187 * @param[in] pattern_size The number of the vibration data
188 * @param[in] count The number of the Iteration that include playing every vibrations
189 * @param[in] level The amount of the intensity variation in every vibrations
190 * @param[out] id The ID of the vibration pattern
192 * @return 0 on success, otherwise a negative error value.
193 * @retval #HAPTIC_ERROR_NONE Successful
194 * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter
195 * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
196 * @retval #HAPTIC_ERROR_NOT_INITIALIZED Not initialized
198 * @see haptic_stop_pattern()
200 int haptic_play_pattern(haptic_vibration_iter_s* pattern, int pattern_size, int count, int level, int* id);
203 * @brief Stops playing the pattern which is being played.
205 * @remarks haptic_stop_device() can not stop pattern,
206 * because playing process calls the vibration procedure in each vibration data.
208 * @param[in] id The ID of playing session from haptic_play_pattern()
210 * @return 0 on success, otherwise a negative error value.
211 * @retval #HAPTIC_ERROR_NONE Successful
212 * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter
214 * @see haptic_play_pattern()
216 int haptic_stop_pattern(int id);
225 #endif // __TIZEN_SYSTEM_HAPTIC_H__