diff options
author | jy910.yun <jy910.yun@samsung.com> | 2013-06-10 10:29:52 +0900 |
---|---|---|
committer | Jacek Pielaszkiewicz <j.pielaszkie@samsung.com> | 2013-10-23 12:37:44 +0200 |
commit | 634a91181010e48c6b92ba9155fb3044d2e9b9a2 (patch) | |
tree | 5c40ffe4f918d1c781cf01bd025c400ce5e88f35 | |
parent | f231283973654cf74742eb4f27e9baca5cb575ac (diff) | |
download | libhaptic-634a91181010e48c6b92ba9155fb3044d2e9b9a2.tar.gz libhaptic-634a91181010e48c6b92ba9155fb3044d2e9b9a2.tar.bz2 libhaptic-634a91181010e48c6b92ba9155fb3044d2e9b9a2.zip |
add new buffer api (buffers apis)
before changing, it couldn't know the buffer size
because the buffer includes null value
so we have to pass by argument how long the buffer is
Signed-off-by: jy910.yun <jy910.yun@samsung.com>
Change-Id: Ie97e0bcbc91ee3445a9f050c9f08663410a326e2
Signed-off-by: Jacek Pielaszkiewicz <j.pielaszkie@samsung.com>
-rw-r--r-- | include/haptic.h | 92 | ||||
-rw-r--r-- | src/haptic.c | 75 |
2 files changed, 136 insertions, 31 deletions
diff --git a/include/haptic.h b/include/haptic.h index 4d2d268..adad7a2 100644 --- a/include/haptic.h +++ b/include/haptic.h @@ -148,7 +148,6 @@ int haptic_get_count(int *device_number); */ int haptic_open(haptic_device_e device, haptic_device_h *device_handle); - /** * @brief Closes a haptic-vibration device. * @@ -353,6 +352,75 @@ int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle, haptic_effect_h *effect_handle); /** + * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer. + * @details + * This function can be used to play a haptic-vibration pattern buffer. + * + * @remark + * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n + * And default value of feedback and priority is used.\n + * feedback level is reserved for auto chaning to save variable in the settings.\n + * priority level uses HAPTIC_PRIORITY_MIN. + * + * @param[in] device_handle The device handle from haptic_open() + * @param[in] vibe_buffer Pointer to the vibration pattern + * @param[in] size Size to the vibration pattern + * @param[out] effect_handle [DEPRECATED] Pointer to the variable that will receive a handle to the playing effect + * + * @return 0 on success, otherwise a negative error value. + * @retval #HAPTIC_ERROR_NONE Successful + * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #HAPTIC_ERROR_NOT_INITIALIZED Not initialized + * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed + * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE Not supported device + * + * @see haptic_vibrate_buffer_with_detail() + * @see haptic_vibrate_monotone() + * @see haptic_vibrate_file() + * @see haptic_get_count() + */ +int haptic_vibrate_buffers(haptic_device_h device_handle, + const unsigned char *vibe_buffer, + int size, + haptic_effect_h *effect_handle); + +/** + * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer. + * @details + * This function can be used to play a haptic-vibration pattern buffer. + * + * @remark + * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter. + * + * @param[in] device_handle The device handle from haptic_open() + * @param[in] vibe_buffer Pointer to the vibration pattern + * @param[in] size Size to the vibration pattern + * @param[in] iteration The number of times to repeat the effect + * @param[in] feedback The amount of the intensity variation + * @param[in] priority The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH + * @param[out] effect_handle [DEPRECATED] Pointer to the variable that will receive a handle to the playing effect + * + * @return 0 on success, otherwise a negative error value. + * @retval #HAPTIC_ERROR_NONE Successful + * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #HAPTIC_ERROR_NOT_INITIALIZED Not initialized + * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed + * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE Not supported device + * + * @see haptic_vibrate_buffer() + * @see haptic_vibrate_monotone_with_detail() + * @see haptic_vibrate_file_with_detail() + * @see haptic_get_count() + */ +int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle, + const unsigned char *vibe_buffer, + int size, + haptic_iteration_e iteration, + haptic_feedback_e feedback, + haptic_priority_e priority, + haptic_effect_h *effect_handle); + +/** * @brief Stops the current vibration effect which is being played. * @details This function can be used to stop each effect started by haptic_vibrate_xxx(). * @@ -526,6 +594,28 @@ int haptic_get_file_duration(haptic_device_h device_handle, const char *file_pat int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *duration); /** + * @brief Gets a duration time value from buffer. + * @details This function can be used to get a duration time value from the buffer using second parameter. + * + * @remark + * + * @param[in] device_handle The device handle from haptic_open() + * @param[in] vibe_buffer Pointer to the vibration pattern buffer + * @param[in] size Size to the vibration pattern buffer + * @param[out] duration The pointer to the duration time value + * + * @return 0 on success, otherwise a negative error value. + * @retval #HAPTIC_ERROR_NONE Successful + * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #HAPTIC_ERROR_NOT_INITIALIZED Not initialized + * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed + * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE Not supported device + * + * @see haptic_get_file_duration() + */ +int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration); + +/** * @brief Save an effect buffer to the led file. * @details This function can be used to save an effect buffer to the led file which name is third parameter. * diff --git a/src/haptic.c b/src/haptic.c index e8b48d8..560ccef 100644 --- a/src/haptic.c +++ b/src/haptic.c @@ -380,8 +380,9 @@ int haptic_vibrate_file_with_detail(haptic_device_h device_handle, API int haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, haptic_effect_h *effect_handle) { - return haptic_vibrate_buffer_with_detail(device_handle, + return haptic_vibrate_buffers_with_detail(device_handle, vibe_buffer, + 0, HAPTIC_ITERATION_ONCE, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, @@ -396,6 +397,39 @@ int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle, haptic_priority_e priority, haptic_effect_h *effect_handle) { + return haptic_vibrate_buffers_with_detail(device_handle, + vibe_buffer, + 0, + iteration, + feedback, + priority, + effect_handle); +} + +API +int haptic_vibrate_buffers(haptic_device_h device_handle, + const unsigned char *vibe_buffer, + int size, + haptic_effect_h *effect_handle) +{ + return haptic_vibrate_buffers_with_detail(device_handle, + vibe_buffer, + size, + HAPTIC_ITERATION_ONCE, + HAPTIC_FEEDBACK_AUTO, + HAPTIC_PRIORITY_MIN, + effect_handle); +} + +API +int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle, + const unsigned char *vibe_buffer, + int size, + haptic_iteration_e iteration, + haptic_feedback_e feedback, + haptic_priority_e priority, + haptic_effect_h *effect_handle) +{ int ret; int handle; @@ -456,35 +490,7 @@ int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle, API int haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle) { - int ret; - - if (__handle_cnt == 0) { - HAPTIC_ERROR("Not initialized"); - return HAPTIC_ERROR_NOT_INITIALIZED; - } - - if (device_handle < 0) { - HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle); - return HAPTIC_ERROR_INVALID_PARAMETER; - } - - if (effect_handle < 0) { - HAPTIC_ERROR("Invalid parameter : effect_handle(%d)", effect_handle); - return HAPTIC_ERROR_INVALID_PARAMETER; - } - - if (!plugin_intf || !plugin_intf->haptic_internal_stop_effect) { - HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_stop_effect == NULL"); - return HAPTIC_ERROR_OPERATION_FAILED; - } - - ret = plugin_intf->haptic_internal_stop_effect((int)device_handle, (int)effect_handle); - if (ret != HAPTIC_MODULE_ERROR_NONE) { - HAPTIC_ERROR("haptic_internal_stop_effect is failed : %d", ret); - return HAPTIC_ERROR_OPERATION_FAILED; - } - - return HAPTIC_ERROR_NONE; + return haptic_stop_all_effects(device_handle); } API @@ -710,6 +716,15 @@ int haptic_get_file_duration(haptic_device_h device_handle, const char *file_pat API int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *buffer_duration) { + return haptic_get_buffers_duration(device_handle, + vibe_buffer, + 0, + buffer_duration); +} + +API +API int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration) +{ int ret; int duration; |