return input_strength;
}
-static int __convert_strength_level(int type, int base_level)
+static int __convert_strength_level(int base_level)
{
int convert_strength = 0;
EXTAPI
int device_haptic_play_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback_level)
{
+ int input_feedback_level = feedback_level;
+
if (device_handle_count == 0) {
ERR("Haptic device is not opened yet");
return HAPTIC_NOT_OPENED;
return HAPTIC_NOT_SUPPORTED;
}
- return _haptic_internal_play_buffer(device_handle, vibe_buffer, iteration, feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
+ if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
+ input_feedback_level = setting_fb_level;
+ }
+
+ return _haptic_internal_play_buffer(device_handle, vibe_buffer, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
}
EXTAPI
int device_haptic_play_file(int device_handle, const char *file_name, int iteration, int feedback_level)
{
+ int input_feedback_level = feedback_level;
+
if (device_handle_count == 0) {
ERR("Haptic device is not opened yet");
return HAPTIC_NOT_OPENED;
return HAPTIC_NOT_SUPPORTED;
}
- return _haptic_internal_play_file(device_handle, file_name, iteration, feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
+ if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
+ input_feedback_level = setting_fb_level;
+ }
+
+ return _haptic_internal_play_file(device_handle, file_name, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
}
EXTAPI
}
if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
- input_feedback_level = -setting_fb_level;
+ input_feedback_level = setting_fb_level;
}
/* Set Priority */
EXTAPI
int device_haptic_play_monotone(int device_handle, int duration)
{
+ return device_haptic_play_monotone_with_feedback_level(device_handle, duration, HAPTIC_FEEDBACK_LEVEL_AUTO);
+}
+
+EXTAPI
+int device_haptic_play_monotone_with_feedback_level(int device_handle, int duration, int feedback_level)
+{
int status;
int input_strength;
+ int input_feedback_level = feedback_level;
int effect_handle;
if (device_handle_count == 0) {
}
if (has_haptic_module == 1) {
- status = _haptic_internal_play_monotone(device_handle, duration, -setting_fb_level, 0x05);
+ if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
+ input_feedback_level = setting_fb_level;
+ }
+
+ status = _haptic_internal_play_monotone(device_handle, duration, input_feedback_level, 0x05);
if(HAPTIC_FAILED(status)) {
ERR("_haptic_internal_play_monotone(0) fail: %d", status);
return HAPTIC_FAIL;
}
} else {
- input_strength = __get_master_strength_value();
- if (input_strength < 0) {
- ERR("convert_strength_level fail : %d", input_strength);
- return HAPTIC_FAIL;
+ if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
+ input_feedback_level = __get_master_strength_value();
+ } else {
+ input_feedback_level = __convert_strength_level(feedback_level);
}
- status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, input_strength);
+ status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, input_feedback_level);
if (status < 0) {
ERR(" haptic_set_level for strength:%d (error:%d) \n", input_strength, status);
return HAPTIC_FAIL;
*/
-#ifndef __DEVMAN_HAPTIC_H__
-#define __DEVMAN_HAPTIC_H__
+#ifndef __SAMSUNG_LINUX_DEVMAN_HAPTIC_H__
+#define __SAMSUNG_LINUX_DEVMAN_HAPTIC_H__
#ifdef __cplusplus
extern "C" {
int device_haptic_play_monotone(int dev_handle, int duration);
/**
+ * @fn int device_haptic_play_monotone_with_feedback_level(int dev_handle, int duration, int feedback_level)
+ * @par Description:
+ * This API plays a monotonous haptic-vibration pattern with a given feedback intensity. \n
+ * The first in parameter dev_handle should be from the return value of device_haptic_open().\n
+ * The second in parameter duration defines the length of time this vibration should be played.
+ * This duration is in milliseconds. \n
+ * The fourth in parameter is the vibration feedback intensity level.
+ * This level is already predefined by enumeration type value from HAPTIC _FEEDBACK_LEVEL_1 to HAPTIC _FEEDBACK_LEVEL_5.
+ * If you want to use the value selected by the user in the Setting application menu, just set HAPTIC_FEEDBACK_LEVEL_AUTO value.
+ * (But the application must have a main loop to use the HAPTIC_FEEDBACK_LEVEL_AUTO value ) \n
+ * The third in paramater feedback_level defines the strenth of vibration.
+ * On success it returns a zero value. In case of failure it returns a negative value. \n
+ * Note: The actual behavior of the feedback played and the intensity depends on the target hardware.
+ * @param[in] dev_handle set recived dev_handle value from device_haptic_open()
+ * @param[in] duration set duration times (ms)
+ * @param[in] feedback_level set feedback level
+ * @return if it succeed, it return zero value, otherwise negative value return
+ * @see device_haptic_play_pattern(), device_haptic_play_file(), device_haptic_stop_play()
+ * @par Example
+ * @code
+ * ...
+ * //Play a monotone pattern for 1s == 1000ms
+ * ret_val = device_haptic_play_monotone_with_feedback_level(dev_handle, 1000, HAPTIC_FEEDBACK_LEVEL_3);
+ * if(ret_val !=0)
+ * return -1;
+ * ...
+ * @endcode
+ */
+
+ int device_haptic_play_monotone_with_feedback_level(int dev_handle, int duration, int feedback_level);
+
+
+/**
* @fn int device_haptic_stop_play(int dev_handle)
* @par Description:
* This API stops the current vibration being played.\n