summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPius Lee <pius.lee@samsung.com>2012-02-10 19:32:32 +0900
committerPius Lee <pius.lee@samsung.com>2012-02-10 19:32:32 +0900
commitcabc995129a29a1f150bda541f755e1fb7f3ad85 (patch)
tree6e152fa6d183b1e0212059289ccaaadf464ea28e
parent98f46e1fbd4b3590435952f93669817b646b114b (diff)
downloadhaptic-cabc995129a29a1f150bda541f755e1fb7f3ad85.tar.gz
haptic-cabc995129a29a1f150bda541f755e1fb7f3ad85.tar.bz2
haptic-cabc995129a29a1f150bda541f755e1fb7f3ad85.zip
additional fix for lower framework
-rw-r--r--debian/changelog8
-rwxr-xr-xinclude/haptic_private.h1
-rwxr-xr-xsrc/haptic.c40
-rw-r--r--src/haptic_private.c75
4 files changed, 40 insertions, 84 deletions
diff --git a/debian/changelog b/debian/changelog
index 076a445..c5855e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+capi-system-haptic (0.1.0-10) unstable; urgency=low
+
+ * additional fix for lower framework
+ * Git: api/haptic
+ * Tag: capi-system-haptic_0.1.0-10
+
+ -- DongGi Jang <dg0402.jang@samsung.com> Thu, 02 Feb 2012 16:41:18 +0900
+
capi-system-haptic (0.1.0-9) unstable; urgency=low
* patch for lower framework functions
diff --git a/include/haptic_private.h b/include/haptic_private.h
index cbe4059..cbb459f 100755
--- a/include/haptic_private.h
+++ b/include/haptic_private.h
@@ -26,7 +26,6 @@ extern "C" {
void _haptic_init();
void _haptic_deinit();
-int _haptic_play_monotone(int dev, int duration, haptic_level_e level);
#ifdef __cplusplus
}
diff --git a/src/haptic.c b/src/haptic.c
index d9d94cb..3c38779 100755
--- a/src/haptic.c
+++ b/src/haptic.c
@@ -137,7 +137,7 @@ int haptic_initialize()
id = device_haptic_open(_DEV[i], 0);
if(id < 0) {
for (j=i; i>=0; i--){
- device_haptic_close(_DEV[i]);
+ device_haptic_close(haptic_ids[i]);
}
RETURN_ERR(HAPTIC_ERROR_OPERATION_FAILED);
}
@@ -162,7 +162,7 @@ int haptic_deinitialize()
RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
for(i=0; i<=max_device; i++){
- err = device_haptic_close(_DEV[i]);
+ err = device_haptic_close(haptic_ids[i]);
}
initialize = 0;
@@ -190,7 +190,7 @@ int haptic_get_file_duration(int device_index, const char *file_name , int* dura
if(device_index < 0 || device_index > max_device)
RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- device_index = ((device_index < 3) ? _DEV[device_index] : DEV_IDX_ALL); // xxx
+ device_index = ((device_index < 3) ? device_index : 0); // xxx
if(!invalid_ivt(file_name))
RETURN_ERR(HAPTIC_ERROR_NOT_SUPPORTED_FORMAT);
@@ -214,7 +214,7 @@ int haptic_vibrate_file(int device_index, const char *file_name , int count , ha
if(device_index < 0 || device_index > max_device)
RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- device_index = ((device_index < 3) ? _DEV[device_index] : DEV_IDX_ALL); // xxx
+ device_index = ((device_index < 3) ? device_index : 0); // xxx
if(!initialize)
RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
@@ -253,7 +253,7 @@ int haptic_vibrate_monotone(int device_index , int duration)
if(device_index < 0 || device_index > max_device)
RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- device_index = ((device_index < 3) ? _DEV[device_index] : DEV_IDX_ALL); // xxx
+ device_index = ((device_index < 3) ? device_index : 0); // xxx
if(!initialize)
RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
@@ -277,7 +277,7 @@ int haptic_stop_device(int device_index)
if(device_index < 0 || device_index > max_device)
RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- device_index = ((device_index < 3) ? _DEV[device_index] : DEV_IDX_ALL); // xxx
+ device_index = ((device_index < 3) ? device_index : 0); // xxx
if(!initialize)
RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
@@ -304,6 +304,31 @@ static void _free_pattern_from_table(int index)
g_array_index(pattern_table, struct _vibe_pattern *, index) = NULL;
}
+static int _haptic_play_monotone(int device_index, long duration, haptic_level_e level)
+{
+ int ret;
+
+ if(device_index < 0 || device_index > max_device)
+ RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
+
+ device_index = ((device_index < 3) ? device_index : 0); // xxx
+
+ if(!initialize)
+ RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
+
+
+ ret = device_haptic_play_monotone_with_feedback_level(haptic_ids[device_index], duration, _LEVEL[level]);
+
+ if(ret < 0){
+ if(ret == -2)
+ RETURN_ERR(HAPTIC_ERROR_OPERATION_FAILED);
+ else
+ RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
+ }
+
+ return HAPTIC_ERROR_NONE;
+}
+
static gboolean _haptic_play_iter(gpointer data)
{
int err;
@@ -331,8 +356,7 @@ static gboolean _haptic_play_iter(gpointer data)
level = HAPTIC_LEVEL_5;
if(level != HAPTIC_LEVEL_0 || time != 0){
-// err = _haptic_play_monotone(device, time, level);
- err = haptic_vibrate_monotone(device, time);
+ err = _haptic_play_monotone(device, time, level);
if(err<0){
pattern->error = err;
return false;
diff --git a/src/haptic_private.c b/src/haptic_private.c
index 46e597b..2754181 100644
--- a/src/haptic_private.c
+++ b/src/haptic_private.c
@@ -61,14 +61,6 @@ enum {
static int immersion;
-static int IMM_LEVEL[] = {
- 0, 0, 2000, 4000, 6000, 8000, 10000
-};
-
-static int ETC_LEVEL[] = {
- 0,0, 55, 60, 65, 70, 80
-};
-
void _haptic_init()
{
immersion = access(IMMERSION_DRV_NODE, F_OK) == 0;
@@ -78,70 +70,3 @@ void _haptic_deinit()
{
}
-int _haptic_play_monotone(int dev, int duration, haptic_level_e level)
-{
- int status;
- int input = 0;
- unsigned int cmd;
-
- if(duration < 1 || duration > INPUT_PARM_MAX)
- return HAPTIC_ERROR_INVALID_PARAMETER;
-
- dev = DEV_IDX_ALL; // xxx
-
- if(dev != DEV_IDX_ALL && dev != DEV_IDX_0 && dev != DEV_IDX_1)
- return HAPTIC_ERROR_INVALID_PARAMETER;
-
- if(level == HAPTIC_LEVEL_0)
- return HAPTIC_ERROR_NONE;
-
- if(level < HAPTIC_LEVEL_1 || level > HAPTIC_LEVEL_5)
- return HAPTIC_ERROR_INVALID_PARAMETER;
-
- input = immersion ? IMM_LEVEL[level] : ETC_LEVEL[level];
- if(input == 0)
- return HAPTIC_ERROR_NONE;
-
- if (immersion) {
- cmd = COMP_CMD(dev, input);
- status = device_set_property(DEVTYPE_EFFECT_HAPTIC,
- CMD_PROPERTY_SET_STRENGTH, (int)cmd);
-// printf("capi [%d - %d - %d] [%d %d]\n", DEVTYPE_EFFECT_HAPTIC, CMD_PROPERTY_SET_STRENGTH, cmd, dev, input);
- if (status < 0) {
- return HAPTIC_ERROR_OPERATION_FAILED;
- }
-
- cmd = COMP_CMD(dev, 0x05);
- status =
- device_set_property(DEVTYPE_EFFECT_HAPTIC,
- CMD_PROPERTY_SET_PRIORITY, (int)cmd);
- if (status < 0) {
- return HAPTIC_ERROR_OPERATION_FAILED;
- }
- }
-
- if (immersion) {
- cmd = COMP_CMD(dev, duration);
- status =
- device_set_property(DEVTYPE_EFFECT_HAPTIC,
- CMD_SET_NORMAL_PLAY, (int)cmd);
- if (status < 0) {
- return HAPTIC_ERROR_OPERATION_FAILED;
- }
- } else {
- status =
- device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL,
- input);
- if (status < 0) {
- return HAPTIC_ERROR_OPERATION_FAILED;
- }
-
- status =
- device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT,
- duration);
- if (status < 0) {
- return HAPTIC_ERROR_OPERATION_FAILED;
- }
- }
- return HAPTIC_ERROR_NONE;
-}