emul_state: Replace the way to get host keyboard status on OS X.
authorKitae Kim <kt920.kim@samsung.com>
Thu, 24 Jan 2013 06:14:13 +0000 (15:14 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Thu, 24 Jan 2013 06:14:13 +0000 (15:14 +0900)
There is a library linking problem with X11 on OS X. That is why
we replace the routine.

Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
tizen/src/Makefile.tizen
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/emul_state_darwin.m [new file with mode: 0644]

index 951bce1..dc1864a 100755 (executable)
@@ -12,7 +12,7 @@ QEMU_CFLAGS += $(GLIB_CFLAGS)
 ifdef CONFIG_DARWIN
 QEMU_CFLAGS += -framework Foundation -framework SystemConfiguration
 QEMU_CFLAGS += -framework Cocoa -framework QTKit -framework CoreVideo
-QEMU_CFLAGS += -I/usr/X11/include -L/usr/X11/lib
+QEMU_CFLAGS += -framework AppKit
 endif
 ifndef CONFIG_DEBUG_EXEC
 CFLAGS += -g -O2
@@ -28,7 +28,7 @@ LIBS += -lavformat -lavcodec -lavutil -lm -lcurl -lGL -lXcomposite -lXext
 endif
 ifdef CONFIG_DARWIN
 # FIXME: disabled codec on Mac now
-LIBS += -lavformat -lavcodec -lavutil -lm -lX11
+LIBS += -lavformat -lavcodec -lavutil -lm
 endif
 
 ifdef CONFIG_DEBUG_EXEC
@@ -118,6 +118,7 @@ obj-$(CONFIG_LINUX) += maru_camera_linux_pci.o
 obj-$(CONFIG_WIN32) += maru_camera_win32_pci.o
 obj-$(CONFIG_DARWIN) += maru_camera_darwin_converter.o
 obj-$(CONFIG_DARWIN) += maru_camera_darwin_pci.o
+obj-$(CONFIG_DARWIN) += emul_state_darwin.o
 
 ifdef CONFIG_LINUX # libs for maru camera on linux host
 LIBS += -lv4l2 -lv4lconvert
index 501fcf5..b6d78ed 100644 (file)
 #include "emul_state.h"
 #include "debug_ch.h"
 
-#if defined(CONFIG_WIN32)
-#include <windows.h>
-#else
+#if defined(CONFIG_LINUX)
 #include <X11/XKBlib.h>
+#elif defined (CONFIG_WIN32)
+#include <windows.h>
 #endif
 
 MULTI_DEBUG_CHANNEL(qemu, emul_state);
@@ -164,13 +164,7 @@ MultiTouchState *get_emul_multi_touch_state(void)
 int get_host_lock_key_state(int key)
 {
     /* support only capslock, numlock */
-#if defined(CONFIG_WIN32)
-    if (key == HOST_CAPSLOCK_KEY) {
-        return (GetKeyState(VK_CAPITAL) & 1) != 0;
-    } else if (key == HOST_NUMLOCK_KEY) {
-        return (GetKeyState(VK_NUMLOCK) & 1) != 0;
-    }
-#else
+#if defined(CONFIG_LINUX)
     unsigned state = 0;
     Display *display = XOpenDisplay((char*)0);
     if (display) {
@@ -183,6 +177,15 @@ int get_host_lock_key_state(int key)
     } else if (key == HOST_NUMLOCK_KEY) {
         return (state & 0x02) != 0;
     }
+
+#elif defined(CONFIG_WIN32)
+    if (key == HOST_CAPSLOCK_KEY) {
+        return (GetKeyState(VK_CAPITAL) & 1) != 0;
+    } else if (key == HOST_NUMLOCK_KEY) {
+        return (GetKeyState(VK_NUMLOCK) & 1) != 0;
+    }
+#elif defined(CONFIG_DARWIN)
+    return get_host_lock_key_state_darwin(key);
 #endif
 
     return -1;
@@ -209,5 +212,3 @@ int get_emul_num_lock_state(void)
 {
     return  _emul_state.qemu_num_lock;
 }
-
-
index ec95d1e..66655cc 100644 (file)
@@ -116,6 +116,7 @@ int get_emulator_condition(void);
 short get_emul_rotation(void);
 MultiTouchState *get_emul_multi_touch_state(void);
 int get_host_lock_key_state(int key);
+int get_host_lock_key_state_darwin(int key);
 int get_emul_caps_lock_state(void);
 int get_emul_num_lock_state(void);
 
diff --git a/tizen/src/emul_state_darwin.m b/tizen/src/emul_state_darwin.m
new file mode 100644 (file)
index 0000000..b4fab47
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Emulator
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Kitae Kim <kt920.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <AppKit/NSEvent.h>
+
+#include "emul_state.h"
+
+/* retrieves the status of the host lock key */
+int get_host_lock_key_state_darwin(int key)
+{
+    /* support only capslock */
+    if (key == HOST_CAPSLOCK_KEY) {
+        return ((NSAlphaShiftKeyMask & [NSEvent modifierFlags]) ? 1 : 0);
+    } else if (key == HOST_NUMLOCK_KEY) {
+        return 0;
+    }
+
+    return -1;
+}