summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHyungdeuk Kim <hd3.kim@samsung.com>2012-08-21 20:45:41 +0900
committerHyungdeuk Kim <hd3.kim@samsung.com>2012-08-21 20:45:41 +0900
commit2a671aad55d18f2db00b15049bca4651c6302aa2 (patch)
treeb2d0ba922603eba2e91ed1ff7fe9c19f73db5a26 /src
parent0bd165226db5510b590464688ad1b1983625224c (diff)
downloadmedia-key-2.0alpha.tar.gz
media-key-2.0alpha.tar.bz2
media-key-2.0alpha.zip
Diffstat (limited to 'src')
-rwxr-xr-xsrc/media_key.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/media_key.c b/src/media_key.c
new file mode 100755
index 0000000..08a6b6d
--- /dev/null
+++ b/src/media_key.c
@@ -0,0 +1,99 @@
+#include <aul.h>
+#include <media_key.h>
+#include <string.h>
+#include <utilX.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_MEDIA_KEY"
+
+static void (*_media_key_event_cb)(media_key_e key, media_key_event_e status, void* user_data) = NULL;
+static void *_media_key_data = NULL;
+static int _media_key_initialized = 0;
+
+extern int aul_key_reserve();
+extern int aul_key_release();
+extern int aul_key_init(int (*aul_handler) (bundle *, void *), void *data);
+
+
+static int __aul_key_handler(bundle *b, void *data)
+{
+ int ret = MEDIA_KEY_ERROR_NONE;
+ char *key_str;
+ char *event_str;
+ media_key_e key = MEDIA_KEY_UNKNOWN;
+ media_key_event_e event = MEDIA_KEY_STATUS_UNKNOWN;
+
+ key_str = (char *)bundle_get_val(b, AUL_K_MULTI_KEY);
+ event_str = (char *)bundle_get_val(b, AUL_K_MULTI_KEY_EVENT);
+
+ if (!strcmp(key_str, KEY_PLAYCD)) {
+ key = MEDIA_KEY_PLAY;
+ } else if (!strcmp(key_str, KEY_STOPCD)) {
+ key = MEDIA_KEY_STOP;
+ } else if (!strcmp(key_str, KEY_PAUSECD)) {
+ key = MEDIA_KEY_PAUSE;
+ } else if (!strcmp(key_str, KEY_NEXTSONG)) {
+ key = MEDIA_KEY_NEXT;
+ } else if (!strcmp(key_str, KEY_PREVIOUSSONG)) {
+ key = MEDIA_KEY_PREVIOUS;
+ } else if (!strcmp(key_str, KEY_REWIND)) {
+ key = MEDIA_KEY_REWIND;
+ } else if (!strcmp(key_str, KEY_FASTFORWARD)) {
+ key = MEDIA_KEY_FASTFORWARD;
+ }
+
+ if (!strcmp(event_str, AUL_V_KEY_RELEASED)) {
+ event = MEDIA_KEY_STATUS_RELEASED;
+ } else if (!strcmp(event_str, AUL_V_KEY_PRESSED)) {
+ event = MEDIA_KEY_STATUS_PRESSED;
+ }
+
+ LOGD("[%s] media_key [%s][%d]", __FUNCTION__, key_str, key);
+ LOGD("[%s] media_key_event [%s][%d]", __FUNCTION__, event_str, event);
+
+ if(_media_key_event_cb)
+ _media_key_event_cb(key, event, _media_key_data);
+
+ return ret;
+}
+
+int media_key_reserve(media_key_event_cb callback, void* user_data)
+{
+ int ret;
+
+ if(!_media_key_initialized) {
+ aul_key_init(__aul_key_handler, NULL);
+ _media_key_initialized = 1;
+ }
+
+ _media_key_event_cb = callback;
+ _media_key_data = user_data;
+
+ ret = aul_key_reserve();
+ if(ret < 0) {
+ LOGE("[%s] aul_key_set_event error [%d]", __FUNCTION__, ret);
+ return MEDIA_KEY_ERROR_INVALID_PARAMETER;
+ }
+
+ return MEDIA_KEY_ERROR_NONE;
+}
+
+int media_key_release()
+{
+ int ret;
+
+ ret = aul_key_release();
+ if(ret < 0) {
+ LOGE("[%s] aul_key_unset_event error [%d]", __FUNCTION__, ret);
+ return MEDIA_KEY_ERROR_INVALID_PARAMETER;
+ }
+
+ _media_key_event_cb = NULL;
+ _media_key_data = NULL;
+
+ return MEDIA_KEY_ERROR_NONE;
+}