summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjy910.yun <jy910.yun@samsung.com>2013-02-27 15:33:19 +0900
committerGerrit Code Review <gerrit2@kim11>2013-03-05 08:47:38 +0900
commitdb481e261daf32eac2e4dbee98ad008015086363 (patch)
tree2f00c2aa6831f2dde1ba3db338cfed0612744aca
parent4df7a366b6780ca14da7eef1778762eb6d664732 (diff)
downloadhaptic-module-tizen-db481e261daf32eac2e4dbee98ad008015086363.tar.gz
haptic-module-tizen-db481e261daf32eac2e4dbee98ad008015086363.tar.bz2
haptic-module-tizen-db481e261daf32eac2e4dbee98ad008015086363.zip
revise create_effect function
it can be set the level of each element Change-Id: Ife9713990b5eb6802cab9ed0197b04a27a925aba
-rw-r--r--include/haptic_file.h2
-rw-r--r--packaging/haptic-module-tizen.spec2
-rw-r--r--tizen/DEVICE/src/haptic_module_file.c26
-rw-r--r--tizen/DEVICE/src/haptic_module_internal.c7
4 files changed, 19 insertions, 18 deletions
diff --git a/include/haptic_file.h b/include/haptic_file.h
index 4835946..144d7d6 100644
--- a/include/haptic_file.h
+++ b/include/haptic_file.h
@@ -55,8 +55,8 @@ typedef struct _HapticFile {
} GCC_PACK HapticFile;
typedef struct _HapticElement {
- int stime;
int duration;
+ int level;
} HapticElement;
int GetHapticLevelMax(int *max);
diff --git a/packaging/haptic-module-tizen.spec b/packaging/haptic-module-tizen.spec
index 16f1ec1..812ac14 100644
--- a/packaging/haptic-module-tizen.spec
+++ b/packaging/haptic-module-tizen.spec
@@ -2,7 +2,7 @@
Name: haptic-module-tizen
Summary: Haptic Module library
Version: 0.1.0
-Release: 5
+Release: 6
Group: System/Libraries
License: APLv2
Source0: %{name}-%{version}.tar.gz
diff --git a/tizen/DEVICE/src/haptic_module_file.c b/tizen/DEVICE/src/haptic_module_file.c
index 4f2d2cf..92cc97d 100644
--- a/tizen/DEVICE/src/haptic_module_file.c
+++ b/tizen/DEVICE/src/haptic_module_file.c
@@ -26,8 +26,9 @@
#include "haptic_module_log.h"
#include "haptic_file.h"
-#define BITPERMS 50
-#define DEFAULT_EFFECT_HANDLE 0x02
+#define BITPERMS 50
+#define MAX_LEVEL 0xFF
+#define DEFAULT_EFFECT_HANDLE 0x02
typedef struct {
unsigned char **ppbuffer;
@@ -225,8 +226,9 @@ int InsertHapticElement(unsigned char *vibe_buffer, int max_bufsize, HapticEleme
HapticFile *pfile = NULL;
int databuf = -1;
int needbuf = -1;
- int stime, duration;
- int i = -1, j = -1;
+ int duration;
+ unsigned char level;
+ int i = -1;
pfile = (HapticFile*)vibe_buffer;
if (_check_valid_haptic_format(pfile) < 0) {
@@ -234,24 +236,24 @@ int InsertHapticElement(unsigned char *vibe_buffer, int max_bufsize, HapticEleme
return -1;
}
- stime = element->stime/BITPERMS;
duration = element->duration/BITPERMS;
+ level = (unsigned char)(element->level/pfile->fmt.dwMagnitude*MAX_LEVEL);
- databuf = max_bufsize-sizeof(HapticFile);
- needbuf = (stime+duration)*pfile->fmt.wBlockAlign;
- MODULE_LOG("Data buffer size : %d, Need buffer size : %d", databuf, needbuf);
+ databuf = max_bufsize - sizeof(HapticFile);
+ needbuf = (pfile->fmt.dwDuration + duration)*pfile->fmt.wBlockAlign;
+ MODULE_LOG("Need buffer size : %d", needbuf);
if (databuf < needbuf) {
MODULE_ERROR("buffer lacks a memory : data buf(%d), need buf(%d)", databuf, needbuf);
return -1;
}
- for (i = 0, j = stime; i < duration; ++i, j+=pfile->fmt.wBlockAlign) {
- pfile->data.pData[j] = 0xFF;
+ for (i = pfile->fmt.dwDuration; i < pfile->fmt.dwDuration+duration; i++) {
+ pfile->data.pData[i] = level;
}
- pfile->chunkSize = sizeof(HapticFile)+needbuf;
- pfile->fmt.dwDuration = element->stime+element->duration;
+ pfile->chunkSize = sizeof(HapticFile)+needbuf ;
+ pfile->fmt.dwDuration = pfile->fmt.dwDuration+duration;
pfile->data.chunkSize = sizeof(DataChunk)+needbuf;
return 0;
}
diff --git a/tizen/DEVICE/src/haptic_module_internal.c b/tizen/DEVICE/src/haptic_module_internal.c
index 095a910..6615438 100644
--- a/tizen/DEVICE/src/haptic_module_internal.c
+++ b/tizen/DEVICE/src/haptic_module_internal.c
@@ -466,6 +466,7 @@ static int _create_effect(unsigned char *vibe_buffer, int max_bufsize, haptic_mo
{
int status;
int i;
+ HapticElement elem;
if (vibe_buffer == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
@@ -487,12 +488,10 @@ static int _create_effect(unsigned char *vibe_buffer, int max_bufsize, haptic_mo
MODULE_LOG("effect count : %d", max_elemcnt);
for (i = 0; i < max_elemcnt; ++i) {
- HapticElement elem;
-
- elem.stime = elem_arr[i].haptic_stime;
elem.duration = elem_arr[i].haptic_duration;
+ elem.level = elem_arr[i].haptic_level;
- MODULE_LOG("%d) time : %d, duration : %d", i, elem_arr[i].haptic_stime, elem_arr[i].haptic_duration);
+ MODULE_LOG("%d) duration : %d, level : %d", i, elem_arr[i].haptic_duration, elem_arr[i].haptic_level);
status = InsertHapticElement(vibe_buffer, max_bufsize, &elem);
if (status < 0) {