summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjy910.yun <jy910.yun@samsung.com>2012-08-21 19:11:00 +0900
committerjy910.yun <jy910.yun@samsung.com>2012-08-21 19:11:00 +0900
commit084b8672dd390c1338a7949ebe91ad76f081a29e (patch)
tree2f6a5a833bbd67aaee97bb644d4b739a38b40f3c
parent24c06363581c4713b198e0c12d6c01ae380da000 (diff)
downloadhaptic-2.0alpha.tar.gz
haptic-2.0alpha.tar.bz2
haptic-2.0alpha.zip
-rwxr-xr-xTC/_export_env.sh8
-rwxr-xr-xTC/_export_target_env.sh7
-rwxr-xr-xTC/build.sh16
-rwxr-xr-xTC/clean.sh11
-rw-r--r--TC/config2
-rwxr-xr-xTC/execute.sh15
-rwxr-xr-xTC/testcase/Makefile28
-rw-r--r--TC/testcase/tslist2
-rw-r--r--TC/testcase/utc_system_haptic_basic.c114
-rw-r--r--TC/testcase/utc_system_haptic_play.c214
-rwxr-xr-xTC/tet_scen7
-rw-r--r--TC/tetbuild.cfg5
-rw-r--r--TC/tetclean.cfg5
-rw-r--r--TC/tetexec.cfg5
-rw-r--r--debian/changelog139
-rw-r--r--include/haptic.h98
-rw-r--r--[-rwxr-xr-x]include/haptic_private.h0
-rw-r--r--packaging/capi-system-haptic.spec16
-rw-r--r--[-rwxr-xr-x]src/haptic.c218
-rwxr-xr-xtest/CMakeLists.txt65
-rw-r--r--test/system-haptic.c160
-rw-r--r--test/system-haptic2.c107
-rw-r--r--test/system-haptic3.c142
-rw-r--r--test/test_lock.c136
-rw-r--r--test/test_ui.c127
25 files changed, 1397 insertions, 250 deletions
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100755
index 0000000..72a11ec
--- /dev/null
+++ b/TC/_export_env.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100755
index 0000000..5ddaa53
--- /dev/null
+++ b/TC/_export_target_env.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755
index 0000000..72aad6c
--- /dev/null
+++ b/TC/build.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/clean.sh b/TC/clean.sh
new file mode 100755
index 0000000..29743e0
--- /dev/null
+++ b/TC/clean.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./ # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
diff --git a/TC/config b/TC/config
new file mode 100644
index 0000000..8b68019
--- /dev/null
+++ b/TC/config
@@ -0,0 +1,2 @@
+TET_INSTALL_HOST_PATH=/home/idkiller/work/tetware/TETware
+TET_INSTALL_TARGET_PATH=/mnt/nfs/tetware/TETware
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755
index 0000000..a4f6095
--- /dev/null
+++ b/TC/execute.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. ./_export_target_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile
new file mode 100755
index 0000000..04df82b
--- /dev/null
+++ b/TC/testcase/Makefile
@@ -0,0 +1,28 @@
+CC = gcc
+
+C_FILES = $(shell ls *.c)
+
+PKGS = dlog capi-system-haptic
+
+#TET_ROOT = /home/idkiller/work/tetware/TETware/tetware-target
+
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+LDFLAGS += `pkg-config --libs $(PKGS)`
+
+CFLAGS += `pkg-config --cflags $(PKGS)`
+CFLAGS += -I.
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+#TARGETS = $(C_FILES:%.c=tc-%)
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TCS)
diff --git a/TC/testcase/tslist b/TC/testcase/tslist
new file mode 100644
index 0000000..29af7f6
--- /dev/null
+++ b/TC/testcase/tslist
@@ -0,0 +1,2 @@
+/testcase/utc_system_haptic_basic
+/testcase/utc_system_haptic_play
diff --git a/TC/testcase/utc_system_haptic_basic.c b/TC/testcase/utc_system_haptic_basic.c
new file mode 100644
index 0000000..a792cd9
--- /dev/null
+++ b/TC/testcase/utc_system_haptic_basic.c
@@ -0,0 +1,114 @@
+/*
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of SAMSUNG
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
+ * this software is owned by Samsung and you shall not disclose such
+ * Confidential Information and shall use it only in accordance with the terms
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
+ * make no representations or warranties about the suitability of the software,
+ * either express or implied, including but not limited to the implied
+ * warranties of merchantability, fitness for a particular purpose, or
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by
+ * licensee arising out of or related to this software.
+ *
+ */
+#include <stdio.h>
+#include <tet_api.h>
+#include <haptic.h>
+
+#define API_NAME_HAPTIC_GET_DEVICE_COUNT "haptic_get_count"
+#define API_NAME_HAPTIC_INITALIZE "haptic_initialize"
+#define API_NAME_HAPTIC_DEINITALIZE "haptic_deinitialize"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+
+static void utc_haptic_get_count_p(void);
+static void utc_haptic_initialize_p(void);
+static void utc_haptic_deinitialize_p(void);
+static void utc_haptic_deinitialize_n(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_haptic_get_count_p, POSITIVE_TC_IDX},
+ { utc_haptic_initialize_p, POSITIVE_TC_IDX},
+ { utc_haptic_deinitialize_p, POSITIVE_TC_IDX},
+ { utc_haptic_deinitialize_n, NEGATIVE_TC_IDX},
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_haptic_get_count_p(void)
+{
+ int cnt, err;
+ err = haptic_get_count(&cnt);
+
+ if(err < 0 ){
+ dts_fail(API_NAME_HAPTIC_GET_DEVICE_COUNT);
+ }
+ else{
+ dts_pass(API_NAME_HAPTIC_GET_DEVICE_COUNT);
+ }
+}
+
+static void utc_haptic_initialize_p(void)
+{
+ int err = haptic_initialize();
+ haptic_deinitialize();
+
+ if(err < 0){
+ dts_fail(API_NAME_HAPTIC_INITALIZE);
+ }
+ else{
+ dts_pass(API_NAME_HAPTIC_INITALIZE);
+ }
+}
+
+static void utc_haptic_deinitialize_p(void)
+{
+ int err;
+
+ haptic_initialize();
+ err = haptic_deinitialize();
+
+ if(err < 0){
+ dts_fail(API_NAME_HAPTIC_DEINITALIZE);
+ }
+ else{
+ dts_pass(API_NAME_HAPTIC_DEINITALIZE);
+ }
+}
+
+static void utc_haptic_deinitialize_n(void)
+{
+ int err;
+
+ err = haptic_deinitialize();
+
+ if(err < 0){
+ dts_pass(API_NAME_HAPTIC_DEINITALIZE);
+ }
+ else{
+ dts_fail(API_NAME_HAPTIC_DEINITALIZE);
+ }
+}
diff --git a/TC/testcase/utc_system_haptic_play.c b/TC/testcase/utc_system_haptic_play.c
new file mode 100644
index 0000000..247acd1
--- /dev/null
+++ b/TC/testcase/utc_system_haptic_play.c
@@ -0,0 +1,214 @@
+/*
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of SAMSUNG
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
+ * this software is owned by Samsung and you shall not disclose such
+ * Confidential Information and shall use it only in accordance with the terms
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
+ * make no representations or warranties about the suitability of the software,
+ * either express or implied, including but not limited to the implied
+ * warranties of merchantability, fitness for a particular purpose, or
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by
+ * licensee arising out of or related to this software.
+ *
+ */
+#include <stdio.h>
+#include <tet_api.h>
+#include <haptic.h>
+
+#define API_NAME_HAPTIC_PLAY_FILE "haptic_vibrate_file"
+#define API_NAME_PLAY_MONOTONE "haptic_vibrate_monotone"
+#define API_NAME_STOP_PLAY "haptic_stop_device"
+#define API_NAME_PLAY_PTN "haptic_play_pattern"
+#define API_NAME_STOP_PTN "haptic_stop_pattern"
+#define TEST_IVT "/usr/share/immersion/01_Touch/touch_20ms_sharp.ivt"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_system_haptic_vibrate_monotone_p(void);
+static void utc_system_haptic_vibrate_monotone_n_1(void);
+static void utc_system_haptic_vibrate_monotone_n_2(void);
+static void utc_system_haptic_stop_device_p(void);
+static void utc_system_haptic_stop_device_n(void);
+
+static void utc_system_haptic_vibrate_p(void);
+static void utc_system_haptic_vibrate_n(void);
+
+static void utc_system_haptic_stop_pattern_p(void);
+static void utc_system_haptic_stop_pattern_n(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_system_haptic_vibrate_monotone_p, POSITIVE_TC_IDX },
+ { utc_system_haptic_vibrate_monotone_n_1, NEGATIVE_TC_IDX },
+ { utc_system_haptic_vibrate_monotone_n_2, NEGATIVE_TC_IDX },
+ { utc_system_haptic_stop_device_p, POSITIVE_TC_IDX },
+ { utc_system_haptic_stop_device_n, NEGATIVE_TC_IDX },
+ { utc_system_haptic_vibrate_p, POSITIVE_TC_IDX},
+ { utc_system_haptic_vibrate_n, NEGATIVE_TC_IDX},
+ { utc_system_haptic_stop_pattern_p, POSITIVE_TC_IDX},
+ { utc_system_haptic_stop_pattern_n, NEGATIVE_TC_IDX},
+ { NULL, 0},
+};
+
+
+static void startup(void)
+{
+ int error = HAPTIC_ERROR_NONE;
+
+ error = haptic_initialize();
+
+ dts_check_eq("haptic_initialize", error, HAPTIC_ERROR_NONE, "fail initialize in startup");
+}
+
+static void cleanup(void)
+{
+ int error = HAPTIC_ERROR_NONE;
+
+ error = haptic_deinitialize();
+
+ dts_check_eq("haptic_deinitialize", error, HAPTIC_ERROR_NONE, "fail deinitialize in startup");
+}
+
+
+/**
+ * @brief Positive test case of haptic_vibrate_monotone()
+ */
+static void utc_system_haptic_vibrate_monotone_p(void)
+{
+ int error = HAPTIC_ERROR_NONE;
+
+ error = haptic_vibrate_monotone(0, 1000);
+ if(error != HAPTIC_ERROR_NONE)
+ dts_fail(API_NAME_PLAY_MONOTONE);
+
+ dts_pass(API_NAME_PLAY_MONOTONE);
+}
+
+/**
+ * @brief Negative test case of haptic_vibrate_monotone()
+ */
+static void utc_system_haptic_vibrate_monotone_n_1(void)
+{
+ int error = HAPTIC_ERROR_NONE;
+
+ error = haptic_vibrate_monotone(-1, 1000);
+ if(error == HAPTIC_ERROR_NONE)
+ dts_fail(API_NAME_PLAY_MONOTONE);
+
+ dts_pass(API_NAME_PLAY_MONOTONE);
+}
+
+/**
+ * @brief Negative test case of haptic_vibrate_monotone()
+ */
+static void utc_system_haptic_vibrate_monotone_n_2(void)
+{
+ int error = HAPTIC_ERROR_NONE;
+
+ error = haptic_vibrate_monotone(0, -1);
+ if(error == HAPTIC_ERROR_NONE)
+ dts_fail(API_NAME_PLAY_MONOTONE);
+
+ dts_pass(API_NAME_PLAY_MONOTONE);
+}
+
+
+/**
+ * @brief Positive test case of haptic_stop_device()
+ */
+static void utc_system_haptic_stop_device_p(void)
+{
+ int error = HAPTIC_ERROR_NONE;
+
+ error = haptic_vibrate_monotone(0, 1000);
+ if(error != HAPTIC_ERROR_NONE)
+ dts_fail(API_NAME_STOP_PLAY);
+
+ error = haptic_stop_device(0);
+ if(error != HAPTIC_ERROR_NONE)
+ dts_fail(API_NAME_STOP_PLAY);
+
+ dts_pass(API_NAME_STOP_PLAY);
+}
+
+/**
+ * @brief Negative test case of haptic_stop_device()
+ */
+static void utc_system_haptic_stop_device_n(void)
+{
+ int error = HAPTIC_ERROR_NONE;
+
+ error = haptic_stop_device(-1);
+ if(error == HAPTIC_ERROR_NONE)
+ dts_fail(API_NAME_STOP_PLAY);
+
+ dts_pass(API_NAME_STOP_PLAY);
+}
+
+static void utc_system_haptic_vibrate_p(void)
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_5, 500},
+ {0, HAPTIC_LEVEL_1, 500},
+ };
+
+ int ptn_id;
+ if(haptic_play_pattern(ptn, 2, 1, 0, &ptn_id) < 0){
+ dts_fail(API_NAME_PLAY_PTN);
+ }else{
+ dts_pass(API_NAME_PLAY_PTN);
+ }
+}
+
+static void utc_system_haptic_vibrate_n(void)
+{
+ int ptn_id;
+ if(haptic_play_pattern(NULL, 7, 1, 0, &ptn_id) < 0){
+ dts_pass(API_NAME_PLAY_PTN);
+ }else{
+ dts_fail(API_NAME_PLAY_PTN);
+ }
+}
+
+static void utc_system_haptic_stop_pattern_p(void)
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_5, 500},
+ {0, HAPTIC_LEVEL_1, 500},
+ };
+
+ int ptn_id;
+ haptic_play_pattern(ptn, 2, 1, 0, &ptn_id);
+
+ int err = haptic_stop_pattern(ptn_id);
+ if(err < 0){
+ dts_fail(API_NAME_STOP_PTN);
+ }
+ else{
+ dts_pass(API_NAME_STOP_PTN);
+ }
+}
+
+static void utc_system_haptic_stop_pattern_n(void)
+{
+ int err = haptic_stop_pattern(-1);
+ if(err < 0){
+ dts_pass(API_NAME_STOP_PTN);
+ }
+ else{
+ dts_fail(API_NAME_STOP_PTN);
+ }
+
+}
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755
index 0000000..03f029a
--- /dev/null
+++ b/TC/tet_scen
@@ -0,0 +1,7 @@
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/testcase/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644
index 0000000..f7eda55
--- /dev/null
+++ b/TC/tetbuild.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644
index 0000000..02d7030
--- /dev/null
+++ b/TC/tetclean.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644
index 0000000..ef3e452
--- /dev/null
+++ b/TC/tetexec.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE= # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/debian/changelog b/debian/changelog
index 21a3d6e..7f4ea39 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,37 +1,152 @@
+capi-system-haptic (0.1.0-12) unstable; urgency=low
+
+ * fix race condition segfault error in pattern play functions
+ * Git: slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-12
+
+ -- pius lee <pius.lee@samsung.com> Fri, 01 Jun 2012 16:56:46 +0900
+
capi-system-haptic (0.1.0-11) unstable; urgency=low
- * now, version will be attached to shared object extension.
- * Git: api/haptic
+ * so version added
+ * Git: slp/api/haptic
* Tag: capi-system-haptic_0.1.0-11
- -- Pius Lee <pius.lee@samsung.com> Thu, 16 Feb 2012 17:23:52 +0900
+ -- pius lee <pius.lee@samsung.com> Thu, 16 Feb 2012 16:53:33 +0900
capi-system-haptic (0.1.0-10) unstable; urgency=low
* additional fix for lower framework
- * Git: api/haptic
+ * Git: slp/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
- * Git: api/haptic
+ * fix for lower framework
+ * Git: slp/api/haptic
* Tag: capi-system-haptic_0.1.0-9
- -- Pius Lee <pius.lee@samsung.com> Wed, 04 Jan 2012 16:41:58 +0900
+ -- pius lee <pius.lee@samsung.com> Wed, 04 Jan 2012 16:45:31 +0900
capi-system-haptic (0.1.0-8) unstable; urgency=low
- * update version
- * Git: api/haptic
+ * fix error check for malloc and time type in iter structure, fix document
+ * Git: slp/api/haptic
* Tag: capi-system-haptic_0.1.0-8
- -- Pius Lee <pius.lee@samsung.com> Thu, 15 Dec 2011 13:51:19 +0900
+ -- pius lee <pius.lee@samsung.com> Wed, 07 Dec 2011 10:28:49 +0900
+
+capi-system-haptic (0.1.0-7) unstable; urgency=low
+
+ * fix error_ok to error_none
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-7
+
+ -- pius lee <pius.lee@samsung.com> Mon, 05 Dec 2011 16:03:56 +0900
+
+capi-system-haptic (0.1.0-6) unstable; urgency=low
+
+ * add error logging
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-6
+
+ -- pius lee <pius.lee@samsung.com> Fri, 02 Dec 2011 14:50:06 +0900
+
+capi-system-haptic (0.1.0-5) unstable; urgency=low
+
+ * replace project name from SLP to Tizen
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-5
+
+ -- pius lee <pius.lee@samsung.com> Wed, 23 Nov 2011 13:15:03 +0900
+
+capi-system-haptic (0.1.0-4) unstable; urgency=low
+
+ * fix segfault when call stop_pattern before play_pattern.
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-4
+
+ -- pius lee <pius.lee@samsung.com> Fri, 11 Nov 2011 19:34:43 +0900
+
+capi-system-haptic (0.1.0-3) unstable; urgency=low
+
+ * fix vibration function's ID bugs
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-3
+
+ -- pius lee <pius.lee@samsung.com> Mon, 24 Oct 2011 17:26:13 +0900
+
+capi-system-haptic (0.1.0-2) unstable; urgency=low
+
+ * Fix TC, fix vibration function's bugs
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-2
+
+ -- pius lee <pius.lee@samsung.com> Tue, 27 Sep 2011 22:30:08 +0900
+
+capi-system-haptic (0.1.0-1) unstable; urgency=low
+
+ * alpha version update
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.1.0-1
+
+ -- pius lee <pius.lee@samsung.com> Tue, 27 Sep 2011 21:55:56 +0900
+
+capi-system-haptic (0.0.1-6) unstable; urgency=low
+
+ * Now count function return value through output parameter.
+ * Now play pattern function return id through output parameter.
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.0.1-6
+
+ -- pius lee <pius.lee@samsung.com> Tue, 27 Sep 2011 16:14:04 +0900
+
+capi-system-haptic (0.0.1-5) unstable; urgency=low
+
+ * Fix version number
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.0.1-5
+
+ -- pius lee <pius.lee@samsung.com> Mon, 26 Sep 2011 21:54:30 +0900
+
+capi-system-haptic (0.0.1-4-docfix) unstable; urgency=low
+
+ * Fix documents
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.0.1-4-docfix
+
+ -- pius lee <pius.lee@samsung.com> Mon, 26 Sep 2011 21:09:04 +0900
+
+capi-system-haptic (0.0.1-4) unstable; urgency=low
+
+ * renew functions to new way. (merged from experimental branch)
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.0.1-4
+
+ -- pius lee <pius.lee@samsung.com> Mon, 26 Sep 2011 15:01:40 +0900
+
+capi-system-haptic (0.0.1-3) unstable; urgency=low
+
+ * change unknown error to more meaningful
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.0.1-3
+
+ -- pius lee <pius.lee@samsung.com> Mon, 29 Aug 2011 18:20:36 +0900
+
+capi-system-haptic (0.0.1-2) unstable; urgency=low
+
+ * fix doxygen comment in header about haptic_open
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.0.1-2
+
+ -- pius lee <pius.lee@samsung.com> Thu, 11 Aug 2011 19:15:12 +0900
capi-system-haptic (0.0.1-1) unstable; urgency=low
- * Initial release.
+ * Initial upload
+ * Git: slp-source.sec.samsung.net:slp/api/haptic
+ * Tag: capi-system-haptic_0.0.1-1
- -- Pius Lee <pius.lee@samsung.com> Wed, 07 Dec 2011 12:47:27 +0900
+ -- pius lee <pius.lee@samsung.com> Fri, 05 Aug 2011 13:02:31 +0900
diff --git a/include/haptic.h b/include/haptic.h
index 11183e6..c69473f 100644
--- a/include/haptic.h
+++ b/include/haptic.h
@@ -45,13 +45,13 @@ extern "C" {
*/
typedef enum
{
- HAPTIC_LEVEL_AUTO, /**< vibration level from settings */
- HAPTIC_LEVEL_0, /**< vibration level 0 (silence) */
- HAPTIC_LEVEL_1, /**< vibration level 1 (the lowest) */
- HAPTIC_LEVEL_2, /**< vibration level 2 (low)*/
- HAPTIC_LEVEL_3, /**< vibration level 3 (middle) */
- HAPTIC_LEVEL_4, /**< vibration level 4 (high) */
- HAPTIC_LEVEL_5, /**< vibration level 5 (the highest) */
+ HAPTIC_LEVEL_AUTO = -1, /**< vibration level from settings */
+ HAPTIC_LEVEL_0 = 0, /**< vibration level 0 (silence) */
+ HAPTIC_LEVEL_1 = 20, /**< vibration level 1 (the lowest) */
+ HAPTIC_LEVEL_2 = 40, /**< vibration level 2 (low)*/
+ HAPTIC_LEVEL_3 = 60, /**< vibration level 3 (middle) */
+ HAPTIC_LEVEL_4 = 80, /**< vibration level 4 (high) */
+ HAPTIC_LEVEL_5 = 100, /**< vibration level 5 (the highest) */
} haptic_level_e;
/**
@@ -77,7 +77,6 @@ typedef enum
typedef struct
{
int vibrator_index; /**< Index of the vibrator */
- haptic_level_e level; /**< Intensity of the vibration in a iteration */
int time; /**< Duration of the vibration in a iteration */
} haptic_vibration_iter_s;
@@ -123,67 +122,20 @@ int haptic_initialize(void);
int haptic_deinitialize(void);
/**
- * @brief Plays a stored rhythmic haptic vibration pattern from a file.
- *
- * @remarks Both the actual behavior of the vibration pattern and the intensity depend on devices.
- *
- * @param[in] vibrator_index The index of the vibrator.\n
- * The index of the first vibrator is 1.\n
- * 0 is reserved for every vibrators at once.
- * @param[in] file_path The path of a rhythmic vibration pattern file.
- * Only .ivt (Immersion VibeTonz) file is supported.
- * @param[in] count The number of iterations to be vibrated. Must be less than the maximum\n
- * Iteration range allowed for the device. (currently it's 255)
- * @param[in] level The feedback intensity level (it is dependent on target's hardware).\n
- * This level is already predefined by enumeration type value from\n
- * #HAPTIC_LEVEL_1 to #HAPTIC_LEVEL_5.\n
- * If you want to use the value selected by the user in the Setting application menu,\n
- * #HAPTIC_LEVEL_AUTO has to be set. It is required that application\n
- * must have a main loop to use the #HAPTIC_LEVEL_AUTO.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #HAPTIC_ERROR_NONE Success
- * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
- * @retval #HAPTIC_ERROR_NO_SUCH_FILE No such file
- * @retval #HAPTIC_ERROR_NOT_SUPPORTED_FORMAT Not supported file format
- *
- * @see haptic_stop_device()
- * @see haptic_get_count()
- */
-int haptic_vibrate_file(int vibrator_index, const char *file_path, int count, haptic_level_e level);
-
-/**
- * @brief Gets the duration of a rhythmic vibration pattern saved in a given file.
- *
- * @param[in] vibrator_index The index of the vibrator.\n
- * The index of the first vibrator is 1.\n
- * 0 is reserved for every vibrators at once.
- * @param[in] file_path The path of a rhythmic vibration pattern file.
- * Only .ivt (Immersion VibeTonz) file is supported.
- * @param[out] duration_ms The duration in milliseconds.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #HAPTIC_ERROR_NONE Successful
- * @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
- * @retval #HAPTIC_ERROR_NO_SUCH_FILE No such file
- * @retval #HAPTIC_ERROR_NOT_SUPPORTED_FORMAT Not supported file format
- *
- * @see haptic_get_count()
- */
-int haptic_get_file_duration(int vibrator_index, const char *file_path, int *duration_ms);
-
-/**
* @brief Vibrates during the specified time with a constant intensity.
* @details
* This function can be used to start monotonous vibration for specified time.\n
* Default value of intensity is used.\n
*
+ * @remark
+ * level is intensity variation of vibration. it has a value from 0 to 100.\n
+ * level -1 is reserved for auto changing to saved variable in the settings.
+ *
* @param[in] vibrator_index The index of the vibrator.\n
* The index of the first vibrator is 1.\n
* 0 is reserved for every vibrators at once.
* @param[in] duration_ms The play duration in milliseconds
+ * @param[in] level The amount of the intensity variation
*
* @return 0 on success, otherwise a negative error value.
* @retval #HAPTIC_ERROR_NONE Successful
@@ -195,7 +147,7 @@ int haptic_get_file_duration(int vibrator_index, const char *file_path, int *dur
* @see haptic_vibrate_file()
* @see haptic_get_count()
*/
-int haptic_vibrate_monotone(int vibrator_index, int duration_ms);
+int haptic_vibrate_monotone(int vibrator_index, int duration_ms, int level);
/**
* @brief Stops the current vibration which is being played.
@@ -222,32 +174,22 @@ int haptic_stop_device(int vibrator_index);
/**
* @brief Starts playing the pattern of continuous vibration data.
* @details
- * Each vibration data has index of vibrator, intensity level and duration time. \n
+ * Each vibration data has index of vibrator and duration time. \n
* Vibration data plays continuously in order of specific array. \n
* This function returns the ID of playing session if it succeeds.
* This ID can be used to stop playing iterations.
*
- * When played intensity in each vibration data can be changed with level_change parameter. \n
- * level_change parameter is quantity of intensity variation, it can be minus or plus integer number. \n
- * But if vibration intensity level is under #HAPTIC_LEVEL_0, it does not change. \n
- * And level can't be under #HAPTIC_LEVEL_0 or over #HAPTIC_LEVEL_5.
- *
- * For example, \n
- * Level(#HAPTIC_LEVEL_1) + level_change(2) = #HAPTIC_LEVEL_3 \n
- * Level(#HAPTIC_LEVEL_2) + level_change(-2) = #HAPTIC_LEVEL_0 \n
- * Level(#HAPTIC_LEVEL_5) + level_change(-10) = #HAPTIC_LEVEL_0 \n
- * Level(#HAPTIC_LEVEL_0) + level_change(3) = #HAPTIC_LEVEL_0 (It does not change) \n
- * Level(#HAPTIC_LEVEL_2) + level_change(-3) = #HAPTIC_LEVEL_0 (It can't be under zero) \n
- * Level(#HAPTIC_LEVEL_3) + level_change(10) = #HAPTIC_LEVEL_5 (It can't be over five) \n
- *
+ * @remark
+ * level is intensity variation of vibration. it has a value from 0 to 100.\n
+ * level -1 is reserved for auto changing to saved variable in the settings.
*
* @param[in] pattern The array of the vibration data
* @param[in] pattern_size The number of the vibration data
* @param[in] count The number of the Iteration that include playing every vibrations
- * @param[in] level_change The amount of the intensity variation in each vibrations
+ * @param[in] level The amount of the intensity variation in every vibrations
* @param[out] id The ID of the vibration pattern
*
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #HAPTIC_ERROR_NONE Successful
* @retval #HAPTIC_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #HAPTIC_ERROR_OPERATION_FAILED Operation failed
@@ -255,7 +197,7 @@ int haptic_stop_device(int vibrator_index);
*
* @see haptic_stop_pattern()
*/
-int haptic_play_pattern(haptic_vibration_iter_s* pattern, int pattern_size, int count, int level_change, int* id);
+int haptic_play_pattern(haptic_vibration_iter_s* pattern, int pattern_size, int count, int level, int* id);
/**
* @brief Stops playing the pattern which is being played.
diff --git a/include/haptic_private.h b/include/haptic_private.h
index cbb459f..cbb459f 100755..100644
--- a/include/haptic_private.h
+++ b/include/haptic_private.h
diff --git a/packaging/capi-system-haptic.spec b/packaging/capi-system-haptic.spec
index 8ae3721..99f660b 100644
--- a/packaging/capi-system-haptic.spec
+++ b/packaging/capi-system-haptic.spec
@@ -1,9 +1,10 @@
+#sbs-git:slp/api/haptic capi-system-haptic 0.1.0 0092e2c55dbf60717ae8f43aee931f2dd1c57157
Name: capi-system-haptic
-Summary: A Haptic library in Tizen Native API
+Summary: A Haptic library in Tizen C API
Version: 0.1.0
-Release: 11
+Release: 17
Group: TO_BE/FILLED_IN
-License: Apache-2.0
+License: TO BE FILLED IN
Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
BuildRequires: pkgconfig(devman)
@@ -20,7 +21,7 @@ Requires(postun): /sbin/ldconfig
%package devel
-Summary: A Haptic library in Tizen Native API (Development)
+Summary: A Haptic library in Tizen C API (Development)
Group: TO_BE/FILLED_IN
Requires: %{name} = %{version}-%{release}
@@ -56,4 +57,11 @@ rm -rf %{buildroot}
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-system-haptic.so
+%changelog
+* Thu Aug 16 2012 - Jiyoung Yun <jy910.yun@samsung.com>
+- modify the function parameter to control detail feedback level
+- Tag : capi-system-haptic_0.1.0-17
+* Thu Aug 09 2012 - Jiyoung Yun <jy910.yun@samsung.com>
+- Revert "add level parameter to monotone vibration function."
+- Tag : capi-system-haptic_0.1.0-16
diff --git a/src/haptic.c b/src/haptic.c
index 3c38779..c05fd2a 100755..100644
--- a/src/haptic.c
+++ b/src/haptic.c
@@ -58,28 +58,19 @@ static int _DEV[] = {
DEV_IDX_1,
};
-static int _LEVEL[] =
-{
- HAPTIC_FEEDBACK_LEVEL_AUTO,
- VIBE_SILENCE,
- HAPTIC_FEEDBACK_LEVEL_1,
- HAPTIC_FEEDBACK_LEVEL_2,
- HAPTIC_FEEDBACK_LEVEL_3,
- HAPTIC_FEEDBACK_LEVEL_4,
- HAPTIC_FEEDBACK_LEVEL_5,
-};
-
struct _vibe_pattern {
haptic_vibration_iter_s *iters;
int current;
int size;
- int level_change;
+ int level;
int iter_count;
- int stop;
int pattern_index;
int error;
};
+static const int UNDEFINED = 0;
+static const int START = 1;
+
GArray *pattern_table = NULL;
static int initialize = 0;
@@ -87,23 +78,6 @@ static int max_device = 0;
static int* haptic_ids = NULL;
-static void _free_pattern_from_table(int index);
-
-static bool invalid_ivt(const char* file_name)
-{
- if( 0 != access(file_name, R_OK) )
- {
- return false;
- }
-
- char* ext = strrchr(file_name, '.');
- if (ext == NULL || 0 != strcasecmp(ext, ".ivt")){
- return false;
- }
-
- return true;
-}
-
int haptic_get_count(int* vibrator_number)
{
int count;
@@ -124,6 +98,10 @@ int haptic_initialize()
int i, j;
int id;
+ if(initialize)
+ return HAPTIC_ERROR_NONE;
+
+
if( haptic_get_count(&max_device) < 0)
RETURN_ERR(HAPTIC_ERROR_OPERATION_FAILED);
@@ -147,7 +125,7 @@ int haptic_initialize()
initialize = 1;
- pattern_table = g_array_new(FALSE, TRUE, sizeof(struct _vibe_pattern*));
+ pattern_table = g_array_new(FALSE, TRUE, sizeof(int));
_haptic_init();
@@ -165,14 +143,11 @@ int haptic_deinitialize()
err = device_haptic_close(haptic_ids[i]);
}
initialize = 0;
-
if(haptic_ids != NULL)
free(haptic_ids);
- for(i=0; i< pattern_table->len; i++){
- _free_pattern_from_table(i);
- }
g_array_free(pattern_table, TRUE);
+ pattern_table = NULL;
_haptic_deinit();
@@ -180,92 +155,33 @@ int haptic_deinitialize()
}
-int haptic_get_file_duration(int device_index, const char *file_name , int* duration)
+int haptic_vibrate_monotone(int device_index, int duration_ms, int level)
{
int ret;
- if(!initialize)
- RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
-
- if(device_index < 0 || device_index > max_device)
- RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
-
- device_index = ((device_index < 3) ? device_index : 0); // xxx
-
- if(!invalid_ivt(file_name))
- RETURN_ERR(HAPTIC_ERROR_NOT_SUPPORTED_FORMAT);
-
- ret = device_haptic_get_file_duration(haptic_ids[device_index], file_name, duration);
-
- if(ret < 0){
- if(ret == -2)
- RETURN_ERR(HAPTIC_ERROR_OPERATION_FAILED);
- else
- RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- }
-
- return HAPTIC_ERROR_NONE;
-}
-
-int haptic_vibrate_file(int device_index, const char *file_name , int count , 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);
-
- if(level == VIBE_SILENCE)
- return HAPTIC_ERROR_NONE;
-
- if(level > HAPTIC_LEVEL_5 || level < 0)
+ if(device_index < 0 || device_index > max_device)
RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- if(count < 0 || count >= HAPTIC_INFINITE_ITERATION)
- RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
-
- if(count == 0)
- count = HAPTIC_INFINITE_ITERATION;
-
- if(!invalid_ivt(file_name))
- RETURN_ERR(HAPTIC_ERROR_NOT_SUPPORTED_FORMAT);
-
- ret = device_haptic_play_file(haptic_ids[device_index], file_name, count, _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;
-}
-
-int haptic_vibrate_monotone(int device_index , int duration)
-{
- int ret;
+ if(level < HAPTIC_LEVEL_AUTO || level > HAPTIC_LEVEL_5)
+ RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- if(device_index < 0 || device_index > max_device)
- RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
+ device_index = ((device_index < 3) ? device_index : 0); // xxx
- device_index = ((device_index < 3) ? device_index : 0); // xxx
+ if(!initialize)
+ RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
- if(!initialize)
- RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
+ if(level == HAPTIC_LEVEL_0)
+ return HAPTIC_ERROR_NONE;
- ret = device_haptic_play_monotone(haptic_ids[device_index], duration);
+ level = (level == HAPTIC_LEVEL_AUTO) ? 0 : level;
+ ret = device_haptic_play_monotone_with_detail_feedback_level(haptic_ids[device_index], duration_ms, level);
if(ret < 0){
- if(ret == -2)
- RETURN_ERR(HAPTIC_ERROR_OPERATION_FAILED);
- else
- RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- }
+ if(ret == -2)
+ RETURN_ERR(HAPTIC_ERROR_OPERATION_FAILED);
+ else
+ RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
+ }
return HAPTIC_ERROR_NONE;
}
@@ -294,17 +210,7 @@ int haptic_stop_device(int device_index)
return HAPTIC_ERROR_NONE;
}
-static void _free_pattern_from_table(int index)
-{
- struct _vibe_pattern* p = g_array_index(pattern_table, struct _vibe_pattern *, index);
- if(p == NULL)
- return;
- free(p->iters);
- free(p);
- g_array_index(pattern_table, struct _vibe_pattern *, index) = NULL;
-}
-
-static int _haptic_play_monotone(int device_index, long duration, haptic_level_e level)
+static int _haptic_play_monotone(int device_index, long duration, int level)
{
int ret;
@@ -316,8 +222,13 @@ static int _haptic_play_monotone(int device_index, long duration, haptic_level_e
if(!initialize)
RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
+ if(level == HAPTIC_LEVEL_AUTO) {
+ level = HAPTIC_FEEDBACK_LEVEL_AUTO;
+ }else {
+ level = level > 100 ? 100 : (level < 0 ? 0 : level);
+ }
- ret = device_haptic_play_monotone_with_feedback_level(haptic_ids[device_index], duration, _LEVEL[level]);
+ ret = device_haptic_play_monotone_with_detail_feedback_level(haptic_ids[device_index], duration, level);
if(ret < 0){
if(ret == -2)
@@ -332,57 +243,54 @@ static int _haptic_play_monotone(int device_index, long duration, haptic_level_e
static gboolean _haptic_play_iter(gpointer data)
{
int err;
- struct _vibe_pattern* pattern = (struct _vibe_pattern*)data;
+ struct _vibe_pattern* pattern = NULL;
+
+ pattern = (struct _vibe_pattern*)data;
+
+ if(pattern == NULL)
+ return false;
- if(pattern->stop){
- _free_pattern_from_table(pattern->pattern_index);
+ if(pattern_table == NULL || g_array_index(pattern_table, int, pattern->pattern_index) != START) {
+ free(pattern->iters);
+ free(pattern);
return false;
}
+ if(pattern->iters == NULL)
+ return false;
int current = pattern->current;
int device = pattern->iters[current].vibrator_index;
- int level = pattern->iters[current].level;
long time = pattern->iters[current].time;
- int level_change = pattern->level_change;
- int iter_count = pattern->iter_count;
+ int level = pattern->level;
// set default device, if can't find given device.
if(device >= max_device || device < 0)
device = 0;
- if(level + level_change < HAPTIC_LEVEL_0)
- level = HAPTIC_LEVEL_0;
- if(level + level_change > HAPTIC_LEVEL_5)
- level = HAPTIC_LEVEL_5;
-
- if(level != HAPTIC_LEVEL_0 || time != 0){
+ if(level != 0 || time != 0){
err = _haptic_play_monotone(device, time, level);
if(err<0){
pattern->error = err;
return false;
}
}
-
- pattern->current++;
-
// pattern play finish
- if(pattern->current >= pattern->size){
- if(iter_count <= 0){
- _free_pattern_from_table(pattern->pattern_index);
+ if(++pattern->current >= pattern->size){
+ if(pattern->iter_count <= 0){
+ free(pattern->iters);
+ free(pattern);
return false;
}else{
pattern->current = 0;
pattern->iter_count--;
}
}
-
-
g_timeout_add(time, _haptic_play_iter, data);
return false;
}
-int haptic_play_pattern(haptic_vibration_iter_s* pattern, int pattern_size, int count, int level_change, int* id)
+int haptic_play_pattern(haptic_vibration_iter_s* pattern, int pattern_size, int count, int level, int* id)
{
int i, key = -1;
@@ -409,32 +317,34 @@ int haptic_play_pattern(haptic_vibration_iter_s* pattern, int pattern_size, int
}
vibe_p->iters = tmp_ptn;
vibe_p->size = pattern_size;
- vibe_p->level_change = level_change;
+ vibe_p->level = level;
vibe_p->iter_count = count;
vibe_p->current = 0;
- vibe_p->stop = 0;
vibe_p->error= 0;
for(i=0; i< pattern_table->len; i++){
- if(g_array_index(pattern_table, struct _vibe_pattern *, i) == NULL){
+ if(g_array_index(pattern_table, int, i) == UNDEFINED){
key = i;
break;
}
}
if(key == -1){
- g_array_append_val(pattern_table, vibe_p);
+ g_array_append_val(pattern_table, START);
key = pattern_table->len -1;
}else{
- g_array_index(pattern_table, struct _vibe_pattern *, key) = vibe_p;
+ g_array_index(pattern_table, int, key) = START;
}
vibe_p->pattern_index = key;
_haptic_play_iter((gpointer)vibe_p);
- if(vibe_p->error < 0){
- _free_pattern_from_table(key);
- if(vibe_p->error == -2)
+ int error = vibe_p->error;
+ if(error < 0){
+ free(vibe_p->iters);
+ free(vibe_p);
+
+ if(error == -2)
RETURN_ERR(HAPTIC_ERROR_OPERATION_FAILED);
else
RETURN_ERR(HAPTIC_ERROR_NOT_INITIALIZED);
@@ -456,11 +366,7 @@ int haptic_stop_pattern(int id)
if(id >= pattern_table->len)
RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
- struct _vibe_pattern* pattern = g_array_index(pattern_table, struct _vibe_pattern *, id);
- if(pattern != NULL)
- pattern->stop = 1;
- else
- RETURN_ERR(HAPTIC_ERROR_INVALID_PARAMETER);
+ g_array_index(pattern_table, int, id) = UNDEFINED;
return HAPTIC_ERROR_NONE;
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755
index 0000000..d312607
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,65 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-system-haptic")
+SET(fw_test "capi-system-haptic-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 ecore-x elementary ecore evas)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -g")
+INCLUDE_DIRECTORIES(../include)
+
+#ADD_EXECUTABLE("system-sensor" system-sensor.c)
+#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS})
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+ GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+ MESSAGE("${src_name}")
+ ADD_EXECUTABLE(${src_name} ${src})
+ IF(EXISTS "${src_name}.edc")
+ ADD_CUSTOM_TARGET(
+ "${src_name}.edj"
+ COMMAND edje_cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/${src_name}.edc
+ ${CMAKE_CURRENT_SOURCE_DIR}/${src_name}.edj
+ )
+ ADD_DEPENDENCIES(${src_name} ${src_name}.edj)
+ ENDIF(EXISTS "${src_name}.edc")
+ TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${pkgs_LDFLAGS} ${fw_name})
+ENDFOREACH()
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+ DEPENDS clean
+ COMMENT "distribution clean"
+ COMMAND find
+ ARGS .
+ -not -name config.cmake -and \(
+ -name tester.c -or
+ -name Testing -or
+ -name CMakeFiles -or
+ -name cmake.depends -or
+ -name cmake.check_depends -or
+ -name CMakeCache.txt -or
+ -name cmake.check_cache -or
+ -name *.cmake -or
+ -name Makefile -or
+ -name core -or
+ -name core.* -or
+ -name gmon.out -or
+ -name install_manifest.txt -or
+ -name *.pc -or
+ -name *.edj -or
+ -name *~ \)
+ | grep -v TC | xargs rm -rf
+ TARGET distclean
+ VERBATIM
+)
+
+ENDIF(UNIX)
diff --git a/test/system-haptic.c b/test/system-haptic.c
new file mode 100644
index 0000000..6d6aaf7
--- /dev/null
+++ b/test/system-haptic.c
@@ -0,0 +1,160 @@
+/*
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of SAMSUNG
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
+ * this software is owned by Samsung and you shall not disclose such
+ * Confidential Information and shall use it only in accordance with the terms
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
+ * make no representations or warranties about the suitability of the software,
+ * either express or implied, including but not limited to the implied
+ * warranties of merchantability, fitness for a particular purpose, or
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by
+ * licensee arising out of or related to this software.
+ *
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <haptic.h>
+
+static GMainLoop *mainloop;
+static int ptn_id;
+
+static void sig_quit(int signo)
+{
+ if(mainloop)
+ {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+static gboolean play_ptn(gpointer data)
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+ };
+
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+
+ return false;
+}
+
+static gboolean stop_play(gpointer data)
+{
+ int err;
+ int id = (int)data;
+
+ printf("-- stop!! [%d]\n", id);
+ err = haptic_stop_pattern(id);
+ if(err < 0){
+ printf("-- error!! when stop play!!\n");
+ }
+
+ return false;
+}
+static gboolean stop_and_play(gpointer data)
+{
+ int err;
+ int id = (int)data;
+
+ printf("-- stop!! [%d]\n", id);
+ err = haptic_stop_pattern(id);
+ if(err < 0){
+ printf("-- error!! when stop play!!\n");
+ }
+
+// g_timeout_add(6000, play_ptn, NULL);
+ g_timeout_add(10000, play_ptn, NULL);
+
+ return false;
+}
+
+static gboolean stop_device(gpointer data)
+{
+ haptic_stop_device(0);
+
+ return false;
+}
+
+int main(int argc, char *argv[])
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_1, 3000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_3, 2000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_2, 3000},
+ };
+
+ if(haptic_initialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device opened\n");
+ }else{
+ printf("haptic_open fail\n");
+ }
+
+ signal(SIGINT, sig_quit);
+ signal(SIGTERM, sig_quit);
+ signal(SIGQUIT, sig_quit);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(4000, stop_play, (gpointer)ptn_id);
+
+ if(haptic_play_pattern(ptn, 7, 2, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(2000, stop_play, (gpointer)ptn_id);
+
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(7000, stop_play, (gpointer)ptn_id);
+
+ if(haptic_play_pattern(ptn, 7, 3, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(10, stop_and_play, (gpointer)ptn_id);
+
+
+ g_timeout_add(4000, stop_device, NULL);
+
+
+ g_main_loop_run(mainloop);
+ g_main_loop_unref(mainloop);
+
+ if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device closed\n");
+ }else{
+ printf("haptic_close fail\n");
+ }
+
+ return 0;
+}
diff --git a/test/system-haptic2.c b/test/system-haptic2.c
new file mode 100644
index 0000000..dc189ce
--- /dev/null
+++ b/test/system-haptic2.c
@@ -0,0 +1,107 @@
+/*
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of SAMSUNG
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
+ * this software is owned by Samsung and you shall not disclose such
+ * Confidential Information and shall use it only in accordance with the terms
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
+ * make no representations or warranties about the suitability of the software,
+ * either express or implied, including but not limited to the implied
+ * warranties of merchantability, fitness for a particular purpose, or
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by
+ * licensee arising out of or related to this software.
+ *
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <haptic.h>
+
+#define TEST_IVT "/usr/share/immersion/01_Touch/touch_20ms_sharp.ivt"
+
+static GMainLoop *mainloop;
+
+static void sig_quit(int signo)
+{
+ if(mainloop)
+ {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+static char* error_msg(int err){
+ switch(err){
+ case HAPTIC_ERROR_NONE :
+ return "HAPTIC_ERROR_NONE";
+ case HAPTIC_ERROR_INVALID_PARAMETER :
+ return "HAPTIC_ERROR_INVALID_PARAMETER";
+ case HAPTIC_ERROR_NO_SUCH_FILE :
+ return "HAPTIC_ERROR_NO_SUCH_FILE";
+ case HAPTIC_ERROR_NOT_SUPPORTED_FORMAT :
+ return "HAPTIC_ERROR_NOT_SUPPORTED_FORMAT";
+ case HAPTIC_ERROR_NOT_INITIALIZED :
+ return "HAPTIC_ERROR_NOT_INITIALIZED";
+ case HAPTIC_ERROR_OPERATION_FAILED :
+ return "HAPTIC_ERROR_OPERATION_FAILED";
+ }
+ return "------??";
+}
+
+int main(int argc, char *argv[])
+{
+ int count, i, err;
+ if(haptic_initialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device opened\n");
+ }else{
+ printf("haptic_open fail\n");
+ }
+
+ signal(SIGINT, sig_quit);
+ signal(SIGTERM, sig_quit);
+ signal(SIGQUIT, sig_quit);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ haptic_get_count(&count);
+
+ printf("count = %d\n", count);
+
+ for(i=0; i<=count;i++){
+ printf("play with device(%d)\n", i);
+
+ if((err = haptic_vibrate_monotone(count, 1000)) < 0){
+ printf("haptic play fail [%s]\n", error_msg(err));
+ }else{
+ printf("haptic play success\n");
+ }
+
+ if(haptic_stop_device(count) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+
+ if(haptic_vibrate_file(count, TEST_IVT, 1, HAPTIC_LEVEL_AUTO) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ }
+
+
+ g_main_loop_run(mainloop);
+ g_main_loop_unref(mainloop);
+
+ if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device closed\n");
+ }else{
+ printf("haptic_close fail\n");
+ }
+
+ return 0;
+}
diff --git a/test/system-haptic3.c b/test/system-haptic3.c
new file mode 100644
index 0000000..9f48d4b
--- /dev/null
+++ b/test/system-haptic3.c
@@ -0,0 +1,142 @@
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <haptic.h>
+
+static GMainLoop *mainloop;
+static int ptn_id;
+
+static void sig_quit(int signo)
+{
+ if(mainloop)
+ {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+static gboolean play_ptn(gpointer data)
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+ };
+
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+
+ return false;
+}
+
+static gboolean stop_play(gpointer data)
+{
+ int err;
+ int id = (int)data;
+
+ printf("-- stop!! [%d]\n", id);
+ err = haptic_stop_pattern(id);
+ if(err < 0){
+ printf("-- error!! when stop play!!\n");
+ }
+
+ return false;
+}
+static gboolean stop_and_play(gpointer data)
+{
+ int err;
+ int id = (int)data;
+
+ printf("-- stop!! [%d]\n", id);
+ err = haptic_stop_pattern(id);
+ if(err < 0){
+ printf("-- error!! when stop play!!\n");
+ }
+
+// g_timeout_add(6000, play_ptn, NULL);
+ g_timeout_add(10000, play_ptn, NULL);
+
+ return false;
+}
+
+static gboolean stop_device(gpointer data)
+{
+ haptic_stop_device(0);
+
+ return false;
+}
+
+int main(int argc, char *argv[])
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_1, 3000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_3, 2000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_2, 3000},
+ };
+
+ if(haptic_initialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device opened\n");
+ }else{
+ printf("haptic_open fail\n");
+ }
+
+ signal(SIGINT, sig_quit);
+ signal(SIGTERM, sig_quit);
+ signal(SIGQUIT, sig_quit);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(4000, stop_play, (gpointer)ptn_id);
+
+ if(haptic_play_pattern(ptn, 7, 2, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(2000, stop_play, (gpointer)ptn_id);
+
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(7000, stop_play, (gpointer)ptn_id);
+
+ if(haptic_play_pattern(ptn, 7, 3, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ g_timeout_add(10, stop_and_play, (gpointer)ptn_id);
+
+
+ g_timeout_add(4000, stop_device, NULL);
+
+
+ g_main_loop_run(mainloop);
+ g_main_loop_unref(mainloop);
+
+ if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device closed\n");
+ }else{
+ printf("haptic_close fail\n");
+ }
+
+ return 0;
+}
diff --git a/test/test_lock.c b/test/test_lock.c
new file mode 100644
index 0000000..30663e7
--- /dev/null
+++ b/test/test_lock.c
@@ -0,0 +1,136 @@
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <haptic.h>
+
+static GMainLoop *mainloop;
+static int ptn_id;
+
+static void sig_quit(int signo)
+{
+ if(mainloop)
+ {
+ g_main_loop_quit(mainloop);
+ }
+
+ if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device closed\n");
+ }else{
+ printf("haptic_close fail\n");
+ }
+}
+
+static gboolean play_ptn(gpointer data)
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+ };
+
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+
+ return false;
+}
+
+static gboolean stop_play(gpointer data)
+{
+ int err;
+ int id = (int)data;
+
+ printf("-- stop!! [%d]\n", id);
+ err = haptic_stop_pattern(id);
+ if(err < 0){
+ printf("-- error!! when stop play!!\n");
+ }
+
+ return false;
+}
+static gboolean stop_and_play(gpointer data)
+{
+ int err;
+ int id = (int)data;
+
+ printf("-- stop!! [%d]\n", id);
+ err = haptic_stop_pattern(id);
+ if(err < 0){
+ printf("-- error!! when stop play!!\n");
+ }
+
+// g_timeout_add(6000, play_ptn, NULL);
+ g_timeout_add(10000, play_ptn, NULL);
+
+ return false;
+}
+
+static gboolean stop_device(gpointer data)
+{
+ haptic_stop_device(0);
+
+ return false;
+}
+
+int main(int argc, char *argv[])
+{
+ haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_1, 3000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_3, 2000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_0, 10},
+ {0, HAPTIC_LEVEL_2, 3000},
+ };
+
+ signal(SIGINT, sig_quit);
+ signal(SIGTERM, sig_quit);
+ signal(SIGQUIT, sig_quit);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ if(haptic_initialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device opened\n");
+ }else{
+ printf("haptic_open fail\n");
+ }
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device closed\n");
+ }else{
+ printf("haptic_close fail\n");
+ }
+ if(haptic_initialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device opened\n");
+ }else{
+ printf("haptic_open fail\n");
+ }
+ if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
+ printf("haptic play fail\n");
+ }else{
+ printf("haptic play success\n");
+ }
+ if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
+ printf("haptic device closed\n");
+ }else{
+ printf("haptic_close fail\n");
+ }
+
+
+ g_main_loop_run(mainloop);
+ g_main_loop_unref(mainloop);
+
+ return 0;
+}
diff --git a/test/test_ui.c b/test/test_ui.c
new file mode 100644
index 0000000..3043536
--- /dev/null
+++ b/test/test_ui.c
@@ -0,0 +1,127 @@
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <haptic.h>
+
+#include <Elementary.h>
+#include <Ecore_X.h>
+
+static haptic_vibration_iter_s ptn[] = {
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_1, 1000},
+ {0, HAPTIC_LEVEL_5, 1000},
+};
+
+int ptn_id;
+
+static void _quit_cb(void *data, Evas_Object* obj, void* event_info)
+{
+ Evas_Object *win = (Evas_Object *) data;
+ elm_win_lower(win);
+}
+
+static void _vibe_clicked_cb(void *data, Evas_Object* obj, void* event_info)
+{
+ printf("initialize!\n");
+ haptic_initialize();
+ printf("after initialize!\n");
+
+ printf("play pattern!\n");
+ haptic_play_pattern(ptn, 7, 1, 0, &ptn_id);
+ printf("after play pattern!\n");
+}
+
+static void _stop_clicked_cb(void *data, Evas_Object* obj, void* event_info)
+{
+ int err;
+ printf("stop pattern!\n");
+ err = haptic_stop_pattern(ptn_id);
+ printf("after stop pattern! [%d]\n", err);
+
+ printf("deinitialize!\n");
+ haptic_deinitialize();
+ printf("after deinitialize!\n");
+}
+
+static void winmain()
+{
+ const char* name = "Hapti_UI_TEST";
+ int w,h;
+
+ Evas_Object* win;
+ Evas_Object* bg;
+ Evas_Object* main_layout;
+ Evas_Object* btns_box;
+ Evas_Object* btn_vibe;
+ Evas_Object* btn_stop;
+
+ Evas* evas;
+
+ win = elm_win_add(NULL, name, ELM_WIN_BASIC);
+ if(!win)
+ return;
+
+ elm_win_title_set(win, name);
+ elm_win_borderless_set(win, EINA_TRUE);
+ elm_win_autodel_set(win, EINA_TRUE);
+ evas_object_smart_callback_add(win, "delete,request", _quit_cb, NULL);
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(win, w, h);
+
+ evas_object_show(win);
+
+ evas = evas_object_evas_get(win);
+
+ // set background
+ bg = elm_bg_add(win);
+ elm_bg_color_set(bg, 0xff, 0xff, 0xff);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bg);
+ evas_object_show(bg);
+
+ // Base Layout
+ main_layout = elm_layout_add(win);
+ elm_layout_theme_set(main_layout, "layout", "application", "default");
+ evas_object_size_hint_weight_set(main_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, main_layout);
+ evas_object_show(main_layout);
+
+ // Indicator
+ elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
+
+
+ // add box
+ btns_box = elm_box_add(win);
+ elm_box_horizontal_set(btns_box, EINA_TRUE);
+ elm_win_resize_object_add(win, btns_box);
+ elm_box_padding_set(btns_box, 10, 0);
+ evas_object_show(btns_box);
+
+ // add Button
+ btn_vibe = elm_button_add(main_layout);
+ btn_stop = elm_button_add(main_layout);
+ elm_object_text_set(btn_vibe, "Vibe");
+ elm_object_text_set(btn_stop, "Stop");
+ evas_object_smart_callback_add(btn_vibe, "clicked", _vibe_clicked_cb, NULL);
+ evas_object_smart_callback_add(btn_stop, "clicked", _stop_clicked_cb, NULL);
+
+ elm_box_pack_end(btns_box, btn_vibe);
+ elm_box_pack_end(btns_box, btn_stop);
+ evas_object_show(btn_vibe);
+ evas_object_show(btn_stop);
+}
+
+EAPI_MAIN int elm_main(int argc, char** argv)
+{
+ winmain();
+
+ elm_run();
+ elm_shutdown();
+ return 0;
+}
+ELM_MAIN()