From 64024ed4a77d24c356850d22f3feca8ab4a83edb Mon Sep 17 00:00:00 2001 From: DongGi jang Date: Sat, 18 Feb 2012 17:23:25 +0900 Subject: [PATCH] update devman --- device_haptic.c | 43 +++++++++++++++++++++++++++++++---------- device_haptic_tsp4000_pattern.h | 6 +++--- devman_haptic.h | 37 +++++++++++++++++++++++++++++++++-- devman_haptic_ext.h | 6 +++--- devman_haptic_ext_core.h | 6 +++--- 5 files changed, 77 insertions(+), 21 deletions(-) diff --git a/device_haptic.c b/device_haptic.c index 5e8ceaf..f6b1e50 100644 --- a/device_haptic.c +++ b/device_haptic.c @@ -183,7 +183,7 @@ static int __get_master_strength_value() 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; @@ -354,6 +354,8 @@ int device_haptic_close(int device_handle) 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; @@ -364,12 +366,18 @@ int device_haptic_play_buffer(int device_handle, const unsigned char *vibe_buffe 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; @@ -380,7 +388,11 @@ int device_haptic_play_file(int device_handle, const char *file_name, int iterat 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 @@ -401,7 +413,7 @@ int device_haptic_play_pattern(int device_handle, int pattern, int iteration, in } if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { - input_feedback_level = -setting_fb_level; + input_feedback_level = setting_fb_level; } /* Set Priority */ @@ -455,8 +467,15 @@ int device_haptic_stop_play(int device_handle) 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) { @@ -465,19 +484,23 @@ int device_haptic_play_monotone(int device_handle, int duration) } 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; diff --git a/device_haptic_tsp4000_pattern.h b/device_haptic_tsp4000_pattern.h index 7a7f253..b42e038 100644 --- a/device_haptic_tsp4000_pattern.h +++ b/device_haptic_tsp4000_pattern.h @@ -20,8 +20,8 @@ */ -#ifndef __DEVICE_HAPTIC_TSP4000_PATTERN_H__ -#define __DEVICE_HAPTIC_TSP4000_PATTERN_H__ +#ifndef __SAMSUNG_LINUX_DEVICE_HAPTIC_TSP4000_PATTERN_H__ +#define __SAMSUNG_LINUX_DEVICE_HAPTIC_TSP4000_PATTERN_H__ #include "devman_haptic_ext.h" @@ -122,4 +122,4 @@ unsigned char silent_ivt[] = }; -#endif /* __DEVICE_HAPTIC_TSP4000_PATTERN_H__ */ +#endif /* __SAMSUNG_LINUX_DEVICE_HAPTIC_TSP4000_PATTERN_H__ */ diff --git a/devman_haptic.h b/devman_haptic.h index d41d9f8..ed9b305 100644 --- a/devman_haptic.h +++ b/devman_haptic.h @@ -20,8 +20,8 @@ */ -#ifndef __DEVMAN_HAPTIC_H__ -#define __DEVMAN_HAPTIC_H__ +#ifndef __SAMSUNG_LINUX_DEVMAN_HAPTIC_H__ +#define __SAMSUNG_LINUX_DEVMAN_HAPTIC_H__ #ifdef __cplusplus extern "C" { @@ -288,6 +288,39 @@ 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 diff --git a/devman_haptic_ext.h b/devman_haptic_ext.h index 669bfa0..279a128 100644 --- a/devman_haptic_ext.h +++ b/devman_haptic_ext.h @@ -20,8 +20,8 @@ */ -#ifndef __DEVMAN_HAPTIC_EXT_H__ -#define __DEVMAN_HAPTIC_EXT_H__ +#ifndef __SAMSUNG_LINUX_DEVMAN_HAPTIC_EXT_H__ +#define __SAMSUNG_LINUX_DEVMAN_HAPTIC_EXT_H__ #include "devman_haptic_ext_core.h" @@ -1300,4 +1300,4 @@ extern "C" { #ifdef __cplusplus } #endif -#endif /* __DEVMAN_HAPTIC_EXT_H__ */ +#endif /* __SAMSUNG_LINUX_DEVMAN_HAPTIC_EXT_H__ */ diff --git a/devman_haptic_ext_core.h b/devman_haptic_ext_core.h index 6659d54..e27350f 100644 --- a/devman_haptic_ext_core.h +++ b/devman_haptic_ext_core.h @@ -20,8 +20,8 @@ */ -#ifndef __DEVMAN_HAPTIC_EXT_CORE_H__ -#define __DEVMAN_HAPTIC_EXT_CORE_H__ +#ifndef __SAMSUNG_LINUX_DEVMAN_HAPTIC_EXT_CORE_H__ +#define __SAMSUNG_LINUX_DEVMAN_HAPTIC_EXT_CORE_H__ #include #include @@ -374,4 +374,4 @@ typedef struct #ifdef __cplusplus } #endif -#endif /* __DEVMAN_HAPTIC_EXT_CORE_H__ */ +#endif /* __SAMSUNG_LINUX_DEVMAN_HAPTIC_EXT_CORE_H__ */ -- 2.7.4