tizen 2.3 release
[framework/system/deviced.git] / src / deviced / dd-haptic.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19
20 #ifndef __DD_HAPTIC_H__
21 #define __DD_HAPTIC_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /**
28  * @file        dd-haptic.h
29  * @defgroup    CAPI_SYSTEM_DEVICED_HAPTIC_MODULE Haptic
30  * @ingroup     CAPI_SYSTEM_DEVICED
31  * @brief       This file provides the API for control of haptic
32  * @section CAPI_SYSTEM_DEVICED_HAPTI_MODULE_HEADER Required Header
33  *   \#include <dd-haptic.h>
34  */
35
36 /**
37  * @addtogroup CAPI_SYSTEM_DEVICED_HAPTIC_MODULE
38  * @{
39  */
40
41 /**
42  * @brief The handle of haptic device
43  */
44 typedef void* haptic_device_h;
45
46 /**
47  * @brief The handle of haptic effect
48  */
49 typedef void* haptic_effect_h;
50
51 /**
52  * @brief Enumerations of device id for the Haptic API.
53  * @details We support two motors now.
54  */
55 typedef enum {
56         HAPTIC_DEVICE_0 = 0x0,                  /**< 1st motor */
57         HAPTIC_DEVICE_1 = 0x1,                  /**< 2nd motor */
58         HAPTIC_DEVICE_ALL = 0x4,                /**< both of them */
59 } haptic_device_e;
60
61 /**
62  * @brief Enumerations of priority level for the Haptic API.
63  */
64 typedef enum
65 {
66         HAPTIC_PRIORITY_MIN = 0,                /**< Minimum effect priority for developers (default) */
67         HAPTIC_PRIORITY_MIDDLE,                 /**< Maximum effect priority for developers */
68         HAPTIC_PRIORITY_HIGH,                   /**< Maximum effect priority for OEMs */
69 } haptic_priority_e;
70
71 /**
72  * @brief Enumerations of feedback level for the Haptic API.
73  * @details Haptic level means vibration power (intensity).
74  */
75 typedef enum
76 {
77         HAPTIC_FEEDBACK_0 = 0,                          /**< feedback level 0 */
78         HAPTIC_FEEDBACK_1 = 20,                         /**< feedback level 1 */
79         HAPTIC_FEEDBACK_2 = 40,                         /**< feedback level 2 */
80         HAPTIC_FEEDBACK_3 = 60,                         /**< feedback level 3 */
81         HAPTIC_FEEDBACK_4 = 80,                         /**< feedback level 4 */
82         HAPTIC_FEEDBACK_5 = 100,                        /**< feedback level 5 */
83         HAPTIC_FEEDBACK_AUTO,                           /**< feedback level auto */
84 } haptic_feedback_e;
85
86 /**
87  * @brief Enumerations of unlimited duration for the Haptic API.
88  */
89 typedef enum {
90         HAPTIC_DURATION_UNLIMITED = 0x7FFFFFFF,
91 } haptic_duration_e;
92
93 /**
94  * @brief Enumerations of iteration count for the Haptic API.
95  */
96 typedef enum
97 {
98         HAPTIC_ITERATION_ONCE = 1,
99         HAPTIC_ITERATION_INFINITE = 256,
100 } haptic_iteration_e;
101
102 /**
103  * @brief Enumerations of effect or device state for the Haptic API.
104  */
105 typedef enum
106 {
107         HAPTIC_STATE_STOP = 0,
108         HAPTIC_STATE_PLAYING,
109 } haptic_state_e;
110
111 /**
112  * @brief Enumerations of error codes for the Haptic API.
113  */
114 typedef enum
115 {
116         HAPTIC_ERROR_NONE                 = 0, //TIZEN_ERROR_NONE,                      /**< Successful */
117         HAPTIC_ERROR_INVALID_PARAMETER    = -1, //TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
118         HAPTIC_ERROR_FILE_EXISTS          = -2, //TIZEN_ERROR_FILE_EXISTS,              /**< File exists */
119         HAPTIC_ERROR_NOT_INITIALIZED      = -3, //TIZEN_ERROR_SYSTEM_CLASS | 0x26,      /**< Not initialized */
120         HAPTIC_ERROR_OPERATION_FAILED     = -4, //TIZEN_ERROR_SYSTEM_CLASS | 0x28,      /**< Operation failed */
121         HAPTIC_ERROR_NOT_SUPPORTED_DEVICE = -5, //TIZEN_ERROR_SYSTEM_CLASS | 0x30,      /**< Not supported device */
122 } haptic_error_e;
123
124 /**
125  * @brief Gets the number of the vibrators.
126  *
127  * @remarks The index HAPTIC_DEVICE_ALL is reserved meaning for all vibrators at a time.
128  *
129  * @param[in] device_number A number of vibrators
130  *
131  * @return 0 on success, otherwise a negative error value.
132  * @retval #HAPTIC_ERROR_NONE                    Successful
133  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
134  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
135  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
136  */
137 int haptic_get_count(int *device_number);
138
139 /**
140  * @brief Opens a haptic-vibration device.
141  *
142  * @details Internally, it makes a connection to the vibrator.
143  *
144  * @remarks If this function is not called in advance, other functions will return #HAPTIC_ERROR_NOT_INITIALIZED.
145  * @remarks Haptic API must be closed by haptic_close().
146  *
147  * @return 0 on success, otherwise a negative error value.
148  * @retval #HAPTIC_ERROR_NONE                   Successful
149  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
150  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
151  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
152  *
153  * @see haptic_close()
154  */
155 int haptic_open(haptic_device_e device, haptic_device_h *device_handle);
156
157 /**
158  * @brief Closes a haptic-vibration device.
159  *
160  * @details Internally, it disconnects the connection to vibrator.
161  *
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_NOT_INITIALIZED        Not initialized
166  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
167  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
168  *
169  * @see haptic_open()
170  */
171 int haptic_close(haptic_device_h device_handle);
172
173 /**
174  * @brief Vibrates during the specified time with a constant intensity.
175  * @details
176  * This function can be used to start monotonous vibration for specified time.
177  *
178  * @remark
179  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
180  * And default value of feedback and priority is used.\n
181  * feedback level is reserved for auto chaning to save variable in the settings.\n
182  * priority level uses HAPTIC_PRIORITY_MIN.
183  *
184  * @param[in] device_handle     The device handle from haptic_open()
185  * @param[in] duration          The play duration in milliseconds
186  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
187  *
188  * @return 0 on success, otherwise a negative error value.
189  * @retval #HAPTIC_ERROR_NONE                   Successful
190  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
191  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
192  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
193  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
194  *
195  * @see haptic_vibrate_monotone_with_detail()
196  * @see haptic_vibrate_file()
197  * @see haptic_vibrate_buffer()
198  * @see haptic_get_count()
199  */
200 int haptic_vibrate_monotone(haptic_device_h device_handle, int duration, haptic_effect_h *effect_handle);
201
202 /**
203  * @brief Vibrates during the specified time with a constant intensity.
204  * @details
205  * This function can be used to start monotonous vibration for specified time.
206  *
207  * @remark
208  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
209  *
210  * @param[in] device_handle     The device handle from haptic_open()
211  * @param[in] duration          The play duration in milliseconds
212  * @param[in] feedback          The amount of the intensity variation
213  * @param[in] priority          The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
214  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
215  *
216  * @return 0 on success, otherwise a negative error value.
217  * @retval #HAPTIC_ERROR_NONE                   Successful
218  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
219  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
220  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
221  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
222  *
223  * @see haptic_vibrate_monotone()
224  * @see haptic_vibrate_file_with_detail()
225  * @see haptic_vibrate_buffer_with_detail()
226  * @see haptic_get_count()
227  */
228 int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle,
229                                                                                 int duration,
230                                                                                 haptic_feedback_e feedback,
231                                                                                 haptic_priority_e priority,
232                                                                                 haptic_effect_h *effect_handle);
233
234 /**
235  * @brief Vibrates a predefined rhythmic haptic-vibration pattern file.
236  * @details
237  * This function can be used to play a haptic-vibration pattern file.
238  *
239  * @remark
240  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
241  * And default value of feedback and priority is used.\n
242  * feedback level is reserved for auto chaning to save variable in the settings.\n
243  * priority level uses HAPTIC_PRIORITY_MIN.
244  *
245  * @param[in] device_handle     The device handle from haptic_open()
246  * @param[in] file_path         Vibration pattern file with path
247  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
248  *
249  * @return 0 on success, otherwise a negative error value.
250  * @retval #HAPTIC_ERROR_NONE                   Successful
251  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
252  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
253  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
254  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
255  *
256  * @see haptic_vibrate_file_with_detail()
257  * @see haptic_vibrate_monotone()
258  * @see haptic_vibrate_buffer()
259  * @see haptic_get_count()
260  */
261 int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path, haptic_effect_h *effect_handle);
262
263 /**
264  * @brief Vibrates a predefined rhythmic haptic-vibration pattern file.
265  * @details
266  * This function can be used to play a haptic-vibration pattern file.
267  *
268  * @remark
269  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
270  *
271  * @param[in] device_handle     The device handle from haptic_open()
272  * @param[in] file_path         Vibration pattern file with path
273  * @param[in] iteration         The number of times to repeat the effect
274  * @param[in] feedback          The amount of the intensity variation
275  * @param[in] priority          The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
276  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
277  *
278  * @return 0 on success, otherwise a negative error value.
279  * @retval #HAPTIC_ERROR_NONE                   Successful
280  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
281  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
282  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
283  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
284  *
285  * @see haptic_vibrate_file()
286  * @see haptic_vibrate_monotone_with_detail()
287  * @see haptic_vibrate_buffer_with_detail()
288  * @see haptic_get_count()
289  */
290 int haptic_vibrate_file_with_detail(haptic_device_h device_handle,
291                                                                         const char *file_path,
292                                                                         haptic_iteration_e iteration,
293                                                                         haptic_feedback_e feedback,
294                                                                         haptic_priority_e priority,
295                                                                         haptic_effect_h *effect_handle);
296
297 /**
298  * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
299  * @details
300  * This function can be used to play a haptic-vibration pattern buffer.
301  *
302  * @remark
303  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
304  * And default value of feedback and priority is used.\n
305  * feedback level is reserved for auto chaning to save variable in the settings.\n
306  * priority level uses HAPTIC_PRIORITY_MIN.
307  *
308  * @param[in] device_handle     The device handle from haptic_open()
309  * @param[in] vibe_buffer               Pointer to the vibration pattern
310  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
311  *
312  * @return 0 on success, otherwise a negative error value.
313  * @retval #HAPTIC_ERROR_NONE                   Successful
314  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
315  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
316  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
317  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
318  *
319  * @see haptic_vibrate_buffer_with_detail()
320  * @see haptic_vibrate_monotone()
321  * @see haptic_vibrate_file()
322  * @see haptic_get_count()
323  */
324 int haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, haptic_effect_h *effect_handle);
325
326 /**
327  * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
328  * @details
329  * This function can be used to play a haptic-vibration pattern buffer.
330  *
331  * @remark
332  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
333  *
334  * @param[in] device_handle     The device handle from haptic_open()
335  * @param[in] vibe_buffer       Pointer to the vibration pattern
336  * @param[in] iteration         The number of times to repeat the effect
337  * @param[in] feedback          The amount of the intensity variation
338  * @param[in] priority          The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
339  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
340  *
341  * @return 0 on success, otherwise a negative error value.
342  * @retval #HAPTIC_ERROR_NONE                   Successful
343  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
344  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
345  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
346  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
347  *
348  * @see haptic_vibrate_buffer()
349  * @see haptic_vibrate_monotone_with_detail()
350  * @see haptic_vibrate_file_with_detail()
351  * @see haptic_get_count()
352  */
353 int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle,
354                                                                           const unsigned char *vibe_buffer,
355                                                                           haptic_iteration_e iteration,
356                                                                           haptic_feedback_e feedback,
357                                                                           haptic_priority_e priority,
358                                                                           haptic_effect_h *effect_handle);
359
360 /**
361  * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
362  * @details
363  * This function can be used to play a haptic-vibration pattern buffer.
364  *
365  * @remark
366  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
367  * And default value of feedback and priority is used.\n
368  * feedback level is reserved for auto chaning to save variable in the settings.\n
369  * priority level uses HAPTIC_PRIORITY_MIN.
370  *
371  * @param[in] device_handle     The device handle from haptic_open()
372  * @param[in] vibe_buffer               Pointer to the vibration pattern
373  * @param[in] size                      Size to the vibration pattern
374  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
375  *
376  * @return 0 on success, otherwise a negative error value.
377  * @retval #HAPTIC_ERROR_NONE                   Successful
378  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
379  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
380  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
381  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
382  *
383  * @see haptic_vibrate_buffer_with_detail()
384  * @see haptic_vibrate_monotone()
385  * @see haptic_vibrate_file()
386  * @see haptic_get_count()
387  */
388 int haptic_vibrate_buffers(haptic_device_h device_handle,
389                                                         const unsigned char *vibe_buffer,
390                                                         int size,
391                                                         haptic_effect_h *effect_handle);
392
393 /**
394  * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
395  * @details
396  * This function can be used to play a haptic-vibration pattern buffer.
397  *
398  * @remark
399  * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
400  *
401  * @param[in] device_handle     The device handle from haptic_open()
402  * @param[in] vibe_buffer       Pointer to the vibration pattern
403  * @param[in] size              Size to the vibration pattern
404  * @param[in] iteration         The number of times to repeat the effect
405  * @param[in] feedback          The amount of the intensity variation
406  * @param[in] priority          The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
407  * @param[out] effect_handle    Pointer to the variable that will receive a handle to the playing effect
408  *
409  * @return 0 on success, otherwise a negative error value.
410  * @retval #HAPTIC_ERROR_NONE                   Successful
411  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
412  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
413  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
414  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
415  *
416  * @see haptic_vibrate_buffer()
417  * @see haptic_vibrate_monotone_with_detail()
418  * @see haptic_vibrate_file_with_detail()
419  * @see haptic_get_count()
420  */
421 int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle,
422                                       const unsigned char *vibe_buffer,
423                                                                           int size,
424                                       haptic_iteration_e iteration,
425                                       haptic_feedback_e feedback,
426                                       haptic_priority_e priority,
427                                       haptic_effect_h *effect_handle);
428
429 /**
430  * @brief Stops the current vibration effect which is being played.
431  * @details This function can be used to stop each effect started by haptic_vibrate_xxx().
432  *
433  * @remark
434  *
435  * @param[in] device_handle     The device handle from haptic_open()
436  * @param[in] effect_handle     The effect handle from haptic_vibrate_xxx()
437  *
438  * @return 0 on success, otherwise a negative error value.
439  * @retval #HAPTIC_ERROR_NONE                   Successful
440  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
441  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
442  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
443  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
444  *
445  * @see haptic_vibrate_buffer()
446  * @see haptic_vibrate_monotone()
447  * @see haptic_vibrate_file()
448  * @see haptic_get_count()
449  * @see haptic_stop_all_effects()
450  */
451 int haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle);
452
453 /**
454  * @brief Stops all vibration effects which are being played.
455  * @details This function can be used to stop all effects started by haptic_vibrate_xxx().
456  *
457  * @remark
458  *
459  * @param[in] device_handle     The device handle from haptic_open()
460  *
461  * @return 0 on success, otherwise a negative error value.
462  * @retval #HAPTIC_ERROR_NONE                   Successful
463  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
464  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
465  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
466  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
467  *
468  * @see haptic_vibrate_buffer()
469  * @see haptic_vibrate_monotone()
470  * @see haptic_vibrate_file()
471  * @see haptic_get_count()
472  * @see haptic_stop_effect()
473  */
474 int haptic_stop_all_effects(haptic_device_h device_handle);
475
476 /**
477  * @brief Gets the status of the effect.
478  * @details This function can be used to get the status of the effect wheter the effect are playing or not.
479  *
480  * @remark
481  *
482  * @param[in] device_handle     The device handle from haptic_open()
483  * @param[in] effect_handle     The effect handle from haptic_vibrate_xxx()
484  * @param[out] state            The pointer to variable that will receive the status of the effect.
485  *
486  * @return 0 on success, otherwise a negative error value.
487  * @retval #HAPTIC_ERROR_NONE                   Successful
488  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
489  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
490  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
491  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
492  *
493  * @see haptic_vibrate_buffer()
494  * @see haptic_vibrate_monotone()
495  * @see haptic_vibrate_file()
496  * @see haptic_get_count()
497  * @see haptic_stop_effect()
498  * @see haptic_stop_all_effects()
499  */
500 int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *state);
501
502 /**
503  * @par Description:
504  *      effect element for haptic.
505  */
506 typedef struct {
507         int haptic_duration;    /**< Start time of the effect element in millisecond */
508         int haptic_level;       /**< Duration of the effect element in millisecond */
509 } haptic_effect_element_s;
510
511 /**
512  * @brief Creates an effect buffer.
513  * @details This function can be used to create an effect buffer using effeclt_element variable.
514  *
515  * @remark
516  *
517  * @param[out] vibe_buffer      Pointer to the vibration pattern
518  * @param[in] max_bufsize               The size of the buffer pointed to by vibe_buffer
519  * @param[in] elem_arr                  Pointer to an haptic_effect_element_s structure
520  * @param[in] max_elemcnt               The size fo the buffer pointed to by elem_arr
521  *
522  * @return 0 on success, otherwise a negative error value.
523  * @retval #HAPTIC_ERROR_NONE                   Successful
524  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
525  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
526  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
527  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
528  *
529  * @see haptic_save_effect()
530  */
531 int haptic_create_effect(unsigned char *vibe_buffer,
532                                                  int max_bufsize,
533                                                  haptic_effect_element_s *elem_arr,
534                                                  int max_elemcnt);
535
536 /**
537  * @brief Save an effect buffer to the file.
538  * @details This function can be used to save an effect buffer to the file using third parameter.
539  *
540  * @remark
541  *
542  * @param[in] vibe_buffer       Pointer to the vibration pattern
543  * @param[in] max_bufsize               The size of the buffer pointed to by vibe_buffer
544  * @param[in] file_path                 The pointer to the character buffer containing the path to save
545  *
546  * @return 0 on success, otherwise a negative error value.
547  * @retval #HAPTIC_ERROR_NONE                   Successful
548  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
549  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
550  * @retval #HAPTIC_ERROR_FILE_EXISTS            File exists
551  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
552  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
553  *
554  * @see haptic_create_effect()
555  */
556 int haptic_save_effect(const unsigned char *vibe_buffer,
557                                            int max_bufsize,
558                                            const char *file_path);
559
560 /**
561  * @brief Gets a duration time value from file.
562  * @details This function can be used to get a duration time value from the file using second parameter.
563  *
564  * @remark
565  *
566  * @param[in] device_handle     The device handle from haptic_open()
567  * @param[in] file_path                 The pointer to the character buffer containing the path to save
568  * @param[out] duration                 The pointer to the duration time value
569  *
570  * @return 0 on success, otherwise a negative error value.
571  * @retval #HAPTIC_ERROR_NONE                   Successful
572  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
573  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
574  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
575  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
576  *
577  * @see haptic_get_buffer_duration()
578  */
579 int haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *duration);
580
581 /**
582  * @brief Gets a duration time value from buffer.
583  * @details This function can be used to get a duration time value from the buffer using second parameter.
584  *
585  * @remark
586  *
587  * @param[in] device_handle     The device handle from haptic_open()
588  * @param[in] vibe_buffer               Pointer to the vibration pattern buffer
589  * @param[out] duration                 The pointer to the duration time value
590  *
591  * @return 0 on success, otherwise a negative error value.
592  * @retval #HAPTIC_ERROR_NONE                   Successful
593  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
594  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
595  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
596  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
597  *
598  * @see haptic_get_file_duration()
599  */
600 int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *duration);
601
602 /**
603  * @brief Gets a duration time value from buffer.
604  * @details This function can be used to get a duration time value from the buffer using second parameter.
605  *
606  * @remark
607  *
608  * @param[in] device_handle     The device handle from haptic_open()
609  * @param[in] vibe_buffer               Pointer to the vibration pattern buffer
610  * @param[in] size                      Size to the vibration pattern buffer
611  * @param[out] buffer_duration                  The pointer to the duration time value
612  *
613  * @return 0 on success, otherwise a negative error value.
614  * @retval #HAPTIC_ERROR_NONE                   Successful
615  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
616  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
617  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
618  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
619  *
620  * @see haptic_get_file_duration()
621  */
622 int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration);
623
624 /**
625  * @brief Save an effect buffer to the led file.
626  * @details This function can be used to save an effect buffer to the led file which name is third parameter.
627  *
628  * @remark
629  * Third parameter should be compatible with ledplayer file.
630  *
631  * @param[in] vibe_buffer               Pointer to the vibration pattern
632  * @param[in] max_bufsize               The size of the buffer pointed to by vibe_buffer
633  * @param[in] file_path                 The pointer to the character buffer containing the path to save
634  *
635  * @return 0 on success, otherwise a negative error value.
636  * @retval #HAPTIC_ERROR_NONE                   Successful
637  * @retval #HAPTIC_ERROR_INVALID_PARAMETER      Invalid parameter
638  * @retval #HAPTIC_ERROR_NOT_INITIALIZED        Not initialized
639  * @retval #HAPTIC_ERROR_FILE_EXISTS            File exists
640  * @retval #HAPTIC_ERROR_OPERATION_FAILED       Operation failed
641  * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE   Not supported device
642  *
643  * @see haptic_save_effect()
644  */
645 int haptic_save_led(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path);
646
647 /**
648  * @} end of CAPI_SYSTEM_DEVICED_HAPTIC_MODULE
649  */
650
651 #ifdef __cplusplus
652 }
653 #endif
654 #endif