diff options
author | pr.jung <pr.jung@samsung.com> | 2016-03-24 21:38:29 +0900 |
---|---|---|
committer | pr.jung <pr.jung@samsung.com> | 2016-03-24 22:43:05 +0900 |
commit | 822f065c0bec1c727a9dc10a63f5b0e5bb1be44f (patch) | |
tree | 905d89a60a33a1a98c131b320542435a4e71cd68 | |
parent | 5e677a38f270783d5d90b0d574aba59e701e3dd6 (diff) | |
download | deviced-822f065c0bec1c727a9dc10a63f5b0e5bb1be44f.tar.gz deviced-822f065c0bec1c727a9dc10a63f5b0e5bb1be44f.tar.bz2 deviced-822f065c0bec1c727a9dc10a63f5b0e5bb1be44f.zip |
Add handling code for haptic on wearable device
Change-Id: I553c4983709464903f78804bcb37250045fce84b
Signed-off-by: pr.jung <pr.jung@samsung.com>
-rwxr-xr-x | CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/haptic/haptic.c | 81 | ||||
-rw-r--r-- | src/haptic/standard.c | 16 |
3 files changed, 103 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bc834d15..96929e21 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,12 @@ ENDIF() ######################################################## # Deviced Macros ######################################################## +IF("${PROFILE}" STREQUAL "wearable") + IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DWEARABLE_CIRCLE") + ENDIF() +ENDIF() + MACRO(ADD_SOURCE DIR OUT) FILE(GLOB ALL_SRCS "${DIR}/*.c") FOREACH(SRC ${ALL_SRCS}) diff --git a/src/haptic/haptic.c b/src/haptic/haptic.c index 83623a81..7ab5d227 100644 --- a/src/haptic/haptic.c +++ b/src/haptic/haptic.c @@ -33,12 +33,23 @@ #include "core/config-parser.h" #include "haptic.h" +#ifdef WEARABLE_CIRCLE +#include <Ecore.h> +#include <sys/types.h> +#include <fcntl.h> +#endif + #ifndef DATADIR #define DATADIR "/usr/share/deviced" #endif #define HAPTIC_CONF_PATH "/etc/deviced/haptic.conf" +#ifdef WEARABLE_CIRCLE +#define CIRCLE_ON_PATH "/sys/class/sec/motor/motor_on" +#define CIRCLE_OFF_PATH "/sys/class/sec/motor/motor_off" +#endif + /* hardkey vibration variable */ #define HARDKEY_VIB_ITERATION 1 #define HARDKEY_VIB_FEEDBACK 3 @@ -149,6 +160,57 @@ static int convert_magnitude_by_conf(int level) return DEFAULT_FEEDBACK_LEVEL * HAPTIC_FEEDBACK_STEP; } +#ifdef WEARABLE_CIRCLE +Ecore_Timer *timer; + +static int circle_stop(); +static Eina_Bool timer_cb(void *data) +{ + Ecore_Timer *t = (Ecore_Timer *)data; + circle_stop(); + t = NULL; + + return ECORE_CALLBACK_CANCEL; +} + +static int circle_stop() +{ + int fd; + char buf[8]; + + fd = open(CIRCLE_OFF_PATH, O_RDONLY); + if (fd < 0) + return -ENODEV; + read(fd, buf, 8); + close(fd); + if (timer) { + ecore_timer_del(timer); + timer = NULL; + } + return 0; +} + +static int circle_play(int duration) +{ + int fd; + char buf[8]; + + if (timer) { + ecore_timer_del(timer); + timer = NULL; + } + + fd = open(CIRCLE_ON_PATH, O_RDONLY); + if (fd < 0) + return -ENODEV; + read(fd, buf, 8); + close(fd); + ecore_timer_add(duration/1000.f, timer_cb, timer); + + return 0; +} +#endif + static DBusMessage *edbus_get_count(E_DBus_Object *obj, DBusMessage *msg) { DBusMessageIter iter; @@ -258,10 +320,15 @@ static DBusMessage *edbus_open_device(E_DBus_Object *obj, DBusMessage *msg) goto exit; } +#ifdef WEARABLE_CIRCLE + ret = 1; + goto exit; +#endif ret = h_ops->open_device(index, &handle); if (ret < 0) goto exit; + sender = dbus_message_get_sender(msg); if (!sender) { ret = -EPERM; @@ -316,6 +383,10 @@ static DBusMessage *edbus_close_device(E_DBus_Object *obj, DBusMessage *msg) goto exit; } +#ifdef WEARABLE_CIRCLE + goto exit; +#endif + ret = h_ops->close_device(handle); if (ret < 0) goto exit; @@ -366,6 +437,11 @@ static DBusMessage *edbus_vibrate_monotone(E_DBus_Object *obj, DBusMessage *msg) goto exit; } +#ifdef WEARABLE_CIRCLE + ret = circle_play(duration); + goto exit; +#endif + ret = h_ops->vibrate_monotone(handle, duration, level, priority, &e_handle); if (ret >= 0) ret = e_handle; @@ -437,6 +513,11 @@ static DBusMessage *edbus_stop_device(E_DBus_Object *obj, DBusMessage *msg) goto exit; } +#ifdef WEARABLE_CIRCLE + ret = circle_stop(); + goto exit; +#endif + ret = h_ops->stop_device(handle); exit: diff --git a/src/haptic/standard.c b/src/haptic/standard.c index f67b6d9c..251cc91a 100644 --- a/src/haptic/standard.c +++ b/src/haptic/standard.c @@ -50,6 +50,11 @@ #define MAX_DATA 16 #define FF_INFO_MAGIC 0xDEADFEED +#ifdef WEARABLE_CIRCLE +#define CIRCLE_ON_PATH "/sys/class/sec/motor/motor_on" +#define CIRCLE_OFF_PATH "/sys/class/sec/motor/motor_off" +#endif + struct ff_info_header { unsigned int magic; int iteration; @@ -665,6 +670,17 @@ static bool is_valid(void) { int ret; +#ifdef WEARABLE_CIRCLE + if ((access(CIRCLE_ON_PATH, R_OK) != 0) || + (access(CIRCLE_OFF_PATH, R_OK) != 0)) { + _E("Do not support wearable haptic device"); + return false; + } + + _I("Support wearable haptic device"); + return true; +#endif + ret = ff_find_device(); if (ret < 0) { _E("Do not support standard haptic device"); |