haptic_effect_h *effect_handle);
/**
+ * @param[out] effect_handle 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 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().
*
if (ret < 0)
_E("fail to stop device : %d", ret);
- _D("haptic close %d", ret);
+ _D("haptic stop %d", ret);
exit:
reply = dbus_message_new_method_return(msg);
goto exit;
}
+ _D("haptic vibrate monotone (h:%d, d:%d, f:%d, p:%d)", handle, duration, feedback, priority);
ret = plugin_intf->vibrate_monotone(handle, duration, feedback, priority, &e_handle);
if (ret < 0)
_E("fail to vibrate monotone : %d", ret);
else
ret = e_handle;
- _D("haptic vibrate monotone %d(h:%d, d:%d, f:%d, p:%d)", ret, handle, duration, feedback, priority);
+ _D("haptic vibrate monotone %d", ret);
exit:
reply = dbus_message_new_method_return(msg);
goto exit;
}
+ _D("haptic vibrate buffer (h:%d, s:%d, i:%d, f:%d, p:%d)", handle, size, iteration, feedback, priority);
ret = plugin_intf->vibrate_buffer(handle, data, iteration, feedback, priority, &e_handle);
if (ret < 0)
_E("fail to vibrate buffer : %d", ret);
else
ret = e_handle;
- _D("haptic vibrate buffer %d(h:%d, s:%d, i:%d, f:%d, p:%d)",
- ret, handle, size, iteration, feedback, priority);
+ _D("haptic vibrate buffer %d", ret);
exit:
reply = dbus_message_new_method_return(msg);
DBusError err;
unsigned int handle;
unsigned char *data;
- int duration, ret;
+ int size, duration, ret;
if (!plugin_intf || !plugin_intf->get_buffer_duration) {
ret = -EFAULT;
dbus_error_init(&err);
if (!dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &handle,
- DBUS_TYPE_STRING, &data, DBUS_TYPE_INVALID)) {
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &data, &size,
+ DBUS_TYPE_INVALID)) {
ret = -EINVAL;
goto exit;
}
{ "VibrateMonotone", "uiii", "i", edbus_vibrate_monotone },
{ "VibrateBuffer", "uayiii", "i", edbus_vibrate_buffer },
{ "GetState", "u", "i", edbus_get_state },
- { "GetDuration", "us", "i", edbus_get_duration },
+ { "GetDuration", "uay", "i", edbus_get_duration },
{ "CreateEffect", "sisi", "i", edbus_create_effect },
{ "SaveBinary", "sis", "i", edbus_save_binary },
/* Add methods here */
dbus_message_unref(msg);
dbus_error_free(&err);
- _D("%s-%s : %d(%d)", DEVICED_INTERFACE_HAPTIC, METHOD_OPEN_DEVICE, ret_val, (unsigned int)ret_val);
+ _D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_OPEN_DEVICE, ret_val);
*device_handle = (haptic_device_h)ret_val;
- return ret;
+ return 0;
}
API int haptic_close(haptic_device_h device_handle)
_D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_CLOSE_DEVICE, ret_val);
- return ret;
+ return 0;
}
API int haptic_vibrate_monotone(haptic_device_h device_handle, int duration, haptic_effect_h *effect_handle)
if (effect_handle != NULL)
*effect_handle = (haptic_effect_h)ret_val;
- return ret;
-}
-
-static int haptic_vibrate_buffer_with_detail_size(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)
-{
- DBusError err;
- DBusMessage *msg;
- char str_handle[32];
- char str_iteration[32];
- char str_feedback[32];
- char str_priority[32];
- char *arr[6];
- int ret, ret_val;
- struct dbus_byte byte;
-
- /* check if handle is valid */
- if (device_handle < 0) {
- _E("Invalid parameter : device_handle(%d)", device_handle);
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- /* check if passed arguments are valid */
- if (vibe_buffer == NULL) {
- _E("Invalid parameter : vibe_buffer(NULL)");
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- if (iteration < HAPTIC_ITERATION_ONCE || iteration > HAPTIC_ITERATION_INFINITE) {
- _E("Invalid parameter : iteration(%d)", iteration);
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- if (feedback < HAPTIC_FEEDBACK_0 || feedback > HAPTIC_FEEDBACK_AUTO) {
- _E("Invalid parameter : feedback(%d)", feedback);
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- if (priority < HAPTIC_PRIORITY_MIN || priority > HAPTIC_PRIORITY_HIGH) {
- _E("Invalid parameter : priority(%d)", priority);
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- /* in case of FEEDBACK_AUTO, should be converted */
- if (feedback == HAPTIC_FEEDBACK_AUTO)
- feedback = convert_setting_to_module_level();
-
- snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
- arr[0] = str_handle;
- byte.size = size;
- byte.data = vibe_buffer;
- arr[2] = &byte;
- snprintf(str_iteration, sizeof(str_iteration), "%d", iteration);
- arr[3] = str_iteration;
- snprintf(str_feedback, sizeof(str_feedback), "%d", feedback);
- arr[4] = str_feedback;
- snprintf(str_priority, sizeof(str_priority), "%d", priority);
- arr[5] = str_priority;
-
- /* request to deviced to open haptic device */
- msg = deviced_dbus_method_sync(BUS_NAME, DEVICED_PATH_HAPTIC, DEVICED_INTERFACE_HAPTIC,
- METHOD_VIBRATE_BUFFER, "uayiii", arr);
- if (!msg)
- return HAPTIC_ERROR_OPERATION_FAILED;
-
- dbus_error_init(&err);
-
- ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
- if (!ret) {
- _E("no message : [%s:%s]", err.name, err.message);
- ret = HAPTIC_ERROR_OPERATION_FAILED;
- }
-
- dbus_message_unref(msg);
- dbus_error_free(&err);
-
- _D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_VIBRATE_BUFFER, ret_val);
-
- if (effect_handle != NULL)
- *effect_handle = (haptic_effect_h)ret_val;
-
- return ret;
+ return 0;
}
API int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path, haptic_effect_h *effect_handle)
return HAPTIC_ERROR_OPERATION_FAILED;
}
- ret = haptic_vibrate_buffer_with_detail_size(device_handle,
+ ret = haptic_vibrate_buffers_with_detail(device_handle,
vibe_buffer,
size,
HAPTIC_ITERATION_ONCE,
return HAPTIC_ERROR_OPERATION_FAILED;
}
- ret = haptic_vibrate_buffer_with_detail_size(device_handle,
+ ret = haptic_vibrate_buffers_with_detail(device_handle,
vibe_buffer,
size,
iteration,
char str_priority[32];
char *arr[6];
int ret, ret_val;
- struct dbus_byte byte;
+ struct dbus_byte bytes;
/* check if handle is valid */
if (device_handle < 0) {
if (feedback == HAPTIC_FEEDBACK_AUTO)
feedback = convert_setting_to_module_level();
- _D("data : %s(%d)", vibe_buffer, strlen(vibe_buffer));
-
snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
arr[0] = str_handle;
- arr[1] = vibe_buffer;
+ bytes.size = size;
+ bytes.data = vibe_buffer;
+ arr[2] = &bytes;
snprintf(str_iteration, sizeof(str_iteration), "%d", iteration);
- arr[2] = str_iteration;
+ arr[3] = str_iteration;
snprintf(str_feedback, sizeof(str_feedback), "%d", feedback);
- arr[3] = str_feedback;
+ arr[4] = str_feedback;
snprintf(str_priority, sizeof(str_priority), "%d", priority);
- arr[4] = str_priority;
+ arr[5] = str_priority;
/* request to deviced to open haptic device */
msg = deviced_dbus_method_sync(BUS_NAME, DEVICED_PATH_HAPTIC, DEVICED_INTERFACE_HAPTIC,
- METHOD_VIBRATE_BUFFER, "usiii", arr);
+ METHOD_VIBRATE_BUFFER, "uayiii", arr);
if (!msg)
return HAPTIC_ERROR_OPERATION_FAILED;
if (effect_handle != NULL)
*effect_handle = (haptic_effect_h)ret_val;
- return ret;
+ return 0;
}
API int haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle)
_D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_STOP_DEVICE, ret_val);
- return ret;
+ return 0;
}
API int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *effect_state)
_D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_GET_STATE, ret_val);
*effect_state = (haptic_state_e)ret_val;
- return ret;
+ return 0;
}
API int haptic_create_effect(unsigned char *vibe_buffer,
_D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_CREATE_EFFECT, ret_val);
- return ret;
+ return 0;
}
API int haptic_save_effect(const unsigned char *vibe_buffer,
return HAPTIC_ERROR_NONE;
}
-static int haptic_get_buffer_duration_size(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration)
-{
- DBusError err;
- DBusMessage *msg;
- char str_handle[32];
- char *arr[2];
- int ret, ret_val;
-
- /* check if handle is valid */
- if (device_handle < 0) {
- _E("Invalid parameter : device_handle(%d)", device_handle);
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- if (vibe_buffer == NULL) {
- _E("Invalid parameter : vibe_buffer(NULL)");
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- /* check if pointer is valid */
- if (buffer_duration == NULL) {
- _E("Invalid parameter : buffer_duration(NULL)");
- return HAPTIC_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
- arr[0] = str_handle;
- arr[1] = vibe_buffer;
-
- /* request to deviced to open haptic device */
- msg = deviced_dbus_method_sync(BUS_NAME, DEVICED_PATH_HAPTIC, DEVICED_INTERFACE_HAPTIC,
- METHOD_GET_DURATION, "us", arr);
- if (!msg)
- return HAPTIC_ERROR_OPERATION_FAILED;
-
- dbus_error_init(&err);
-
- ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
- if (!ret) {
- _E("no message : [%s:%s]", err.name, err.message);
- ret = HAPTIC_ERROR_OPERATION_FAILED;
- }
-
- dbus_message_unref(msg);
- dbus_error_free(&err);
-
- _D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_GET_DURATION, ret_val);
-
- *buffer_duration = ret_val;
- return ret;
-}
-
-API int haptic_get_file_duration_size(haptic_device_h device_handle, const char *file_path, int *file_duration)
+API int haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *file_duration)
{
char *vibe_buffer;
int size, ret;
return HAPTIC_ERROR_OPERATION_FAILED;
}
- ret = haptic_get_buffer_duration_size(device_handle,
+ ret = haptic_get_buffers_duration(device_handle,
vibe_buffer,
size,
file_duration);
DBusError err;
DBusMessage *msg;
char str_handle[32];
- char *arr[2];
+ char *arr[3];
int ret, ret_val;
+ struct dbus_byte bytes;
/* check if handle is valid */
if (device_handle < 0) {
snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
arr[0] = str_handle;
- arr[1] = vibe_buffer;
+ bytes.size = size;
+ bytes.data = vibe_buffer;
+ arr[2] = &bytes;
/* request to deviced to open haptic device */
msg = deviced_dbus_method_sync(BUS_NAME, DEVICED_PATH_HAPTIC, DEVICED_INTERFACE_HAPTIC,
- METHOD_GET_DURATION, "us", arr);
+ METHOD_GET_DURATION, "uay", arr);
if (!msg)
return HAPTIC_ERROR_OPERATION_FAILED;
_D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_GET_DURATION, ret_val);
*buffer_duration = ret_val;
- return ret;
+ return 0;
}
API int haptic_save_led(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
_D("%s-%s : %d", DEVICED_INTERFACE_HAPTIC, METHOD_SAVE_BINARY, ret_val);
- return ret;
+ return 0;
}