touch: modified device checking method
authorsungmin ha <sungmin82.ha@samsung.com>
Fri, 7 Aug 2015 12:00:31 +0000 (21:00 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 17 Aug 2015 07:50:25 +0000 (16:50 +0900)
Change-Id: I675616d088e65bb9da6107127f93d28575cd3477
Signed-off-by: sungmin ha <sungmin82.ha@samsung.com>
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
13 files changed:
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/emulator.c
tizen/src/emulator_legacy.c
tizen/src/eventcast/common.c
tizen/src/skin/maruskin_client.c
tizen/src/ui/displaybase.cpp
tizen/src/ui/displaybase.h
tizen/src/ui/displayglwidget.cpp
tizen/src/ui/displayglwidget.h
tizen/src/ui/displayswwidget.cpp
tizen/src/ui/displayswwidget.h
tizen/src/util/ui_operations.c

index 2408827d711b8c904d514a62ff7394c85ec4ecaf..1122b12e689108666e6381dfeb262e0ca940e7b3 100644 (file)
@@ -125,36 +125,6 @@ int get_emul_sdl_bpp(void)
     return _emul_info.sdl_bpp;
 }
 
-/* mouse device */
-void set_emul_input_mouse_enable(bool on)
-{
-    _emul_info.input_mouse_enable = on;
-
-    if (_emul_info.input_mouse_enable == true) {
-        LOG_INFO("set_emul_input_mouse_enable\n");
-    }
-}
-
-bool is_emul_input_mouse_enable(void)
-{
-    return _emul_info.input_mouse_enable;
-}
-
-/* touchscreen device */
-void set_emul_input_touch_enable(bool on)
-{
-    _emul_info.input_touch_enable = on;
-
-    if (_emul_info.input_touch_enable == true) {
-        LOG_INFO("set_emul_input_touch_enable\n");
-    }
-}
-
-bool is_emul_input_touch_enable(void)
-{
-    return _emul_info.input_touch_enable;
-}
-
 bool is_netclient_tap_attached(void)
 {
     NetClientState *ncs[MAX_QUEUE_NUM];
@@ -436,15 +406,6 @@ bool get_emul_cpu_accel(void)
     return false;
 }
 
-/* file sharing path */
-const char* get_host_directory_sharing_path(void)
-{
-    FsDriverEntry *sharing_entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID);
-    const char *sharing_path = (sharing_entry != NULL ? sharing_entry->path : NULL);
-
-    return sharing_path;
-}
-
 //
 // cleaned-up
 //
@@ -563,7 +524,16 @@ const char *get_profile_name(void)
     return vio_evdi->profile;
 }
 
-/* GPU virtualization */
+// host directory sharing path
+const char* get_host_directory_sharing_path(void)
+{
+    FsDriverEntry *sharing_entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID);
+    const char *sharing_path = (sharing_entry != NULL ? sharing_entry->path : NULL);
+
+    return sharing_path;
+}
+
+// GPU virtualization
 static bool gpu_accel_enabled;
 
 bool is_gpu_accel_enabled(void)
@@ -609,6 +579,50 @@ uint64_t get_ram_size(void)
     return ram_size;
 }
 
+// look-up PCI devices
+bool is_pci_device_enabled(int device_id)
+{
+    bool is_enabled = false;
+    PciInfoList *info_list, *info;
+    Error *err = NULL;
+
+    info_list = qmp_query_pci(&err);
+    if (err) {
+        LOG_WARNING("PCI devices not supported\n");
+        error_free(err);
+        return false;
+    }
+
+    for (info = info_list; info; info = info->next) {
+        PciDeviceInfoList *dev;
+        for (dev = info->value->devices; dev; dev = dev->next) {
+            if (dev->value->id.device == device_id) {
+                is_enabled = true;
+                break;
+            }
+        }
+    }
+
+    qapi_free_PciInfoList(info_list);
+
+    return is_enabled;
+}
+
+// mouse input
+bool is_mouse_enabled(void)
+{
+    /* TODO: If the maru mouse device is added,
+     * the device id should to be changed for it.
+    */
+    return !is_pci_device_enabled(PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN);
+}
+
+// touchscreen input
+bool is_touchscreen_enabled(void)
+{
+    return is_pci_device_enabled(PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN);
+}
+
 // vm_data_path
 static const char *vm_data_path = NULL;
 
index 70d85fc080d6c37d928e6db238cd4f8f0143e5d9..e94c1ef501e3eaf94a3ffb3994a1bd326c55c49c 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "display/maru_finger.h"
 #include "config-host.h"
+#include "hw/maru_device_ids.h"
 
 #define SUPPORT_LEGACY_ARGS
 #define MAX_ADDR_LEN    256
@@ -92,8 +93,6 @@ enum {
 
 typedef  struct EmulatorConfigInfo {
     int sdl_bpp;
-    bool input_mouse_enable;
-    bool input_touch_enable;
     int vm_base_port;
     int device_serial_number;
     int ecs_port;
@@ -133,8 +132,6 @@ char const *get_log_path(void);
 /* setter */
 void set_emul_win_scale(double scale);
 void set_emul_sdl_bpp(int bpp);
-void set_emul_input_mouse_enable(bool on);
-void set_emul_input_touch_enable(bool on);
 void set_emul_vm_base_port(int port);
 void set_emul_ecs_port(int port);
 void set_emul_guest_ip(char *ip);
@@ -151,8 +148,6 @@ void set_sdb_connection(bool connected);
 /* getter */
 double get_emul_win_scale(void);
 int get_emul_sdl_bpp(void);
-bool is_emul_input_mouse_enable(void);
-bool is_emul_input_touch_enable(void);
 int get_emul_vm_base_port(void);
 int get_device_serial_number(void);
 int get_emul_ecs_port(void);
@@ -187,10 +182,16 @@ const char *get_drive_image_file(void);
 const char *get_http_proxy_addr(void);
 const char *get_vm_name(void);
 const char *get_profile_name(void);
-bool is_gpu_accel_enabled(void);
 const char* get_host_directory_sharing_path(void);
 const char *get_vm_data_path(void);
+
+bool is_gpu_accel_enabled(void);
+bool is_pci_device_enabled(int device_id);
+bool is_mouse_enabled(void);
+bool is_touchscreen_enabled(void);
+
 uint64_t get_ram_size(void);
+
 void set_initial_display_resolution(int width, int height);
 int get_display_resolution_width(void);
 int get_display_resolution_height(void);
index 4205e0cc554b7e441b0e08bfa3eda5ea242ddbb2..485b74acf56d018af511526cc63ec330dd4891f8 100644 (file)
@@ -64,7 +64,6 @@ int thread_running = 1; /* Check if we need exit main */
 
 DECLARE_DEBUG_CHANNEL(main);
 
-#define INPUT_TOUCH_PARAMETER "virtio-touchscreen-pci"
 #define ARGS_LIMIT  128
 char *maru_kernel_cmdline;
 
@@ -212,21 +211,6 @@ void print_system_info(void)
     is_printed = true;
 }
 
-static void set_qemu_input_mode(void)
-{
-    int i;
-    for (i = 0; i < _qemu_argc; ++i) {
-        if (strstr(_qemu_argv[i], INPUT_TOUCH_PARAMETER) != NULL) {
-            /* touchscreen */
-            set_emul_input_touch_enable(true);
-        }
-    }
-
-    if (is_emul_input_touch_enable() != true) {
-        set_emul_input_mouse_enable(true);
-    }
-}
-
 static void print_options_info(void)
 {
     int i;
@@ -274,7 +258,6 @@ const char *prepare_maru(const char * const kernel_cmdline)
 void prepare_maru_after_device_init(void)
 {
     make_vm_lock_os();
-    set_qemu_input_mode();
     init_device_hotplug();
     start_ecs();
     init_sdb(get_emul_vm_base_port() + SDB_UDP_SENSOR_INDEX);
index 3c64841b357b75d4623d42e48cf331f0940e83b5..f713a0e99672d5887332c06b32ed38e54d3c5b0a 100644 (file)
@@ -202,19 +202,12 @@ static void extract_qemu_info(int qemu_argc, char **qemu_argv)
                 strstr(qemu_argv[i], IMAGE_PATH_SUFFIX) != NULL) {
             set_image_and_log_path(qemu_argv[i]);
         } else if (strstr(qemu_argv[i], INPUT_TOUCH_PARAMETER) != NULL) {
-            /* touchscreen */
-            set_emul_input_touch_enable(true);
-
             char *option = strstr(qemu_argv[i] + strlen(INPUT_TOUCH_PARAMETER), TOUCHSCREEN_OPTION_NAME);
             if (option != NULL) {
                 option += strlen(TOUCHSCREEN_OPTION_NAME) + 1;
             }
         }
     }
-
-    if (is_emul_input_touch_enable() != true) {
-        set_emul_input_mouse_enable(true);
-    }
 }
 
 // deprecated
index 0a8fb3587bd7972cf5c7a4f028a30364427e26b5..02172474a74e486d28b8ba805dfefd9cd5555175 100644 (file)
@@ -345,7 +345,7 @@ static bool msgproc_eventcast_event_msg(Eventcast__EventMsg *msg)
         // TODO: check sensor device whether it exists or not
         set_eventcast_sensor_status(EVENTCAST__STATE__ENABLED);
 
-        if (is_emul_input_touch_enable()) {
+        if (is_touchscreen_enabled()) {
             touch_status = EVENTCAST__STATE__ENABLED;
         } else {
             touch_status = EVENTCAST__STATE__DISABLED;
index 235b36aee3cf53f8eb3a8f53c9efd12c4712d1ef..62c24de6ad5f00ae6e0d711cbff665b405154c94 100644 (file)
@@ -129,7 +129,7 @@ static void *run_skin_client(void *arg)
 
     /* input */
     char buf_input[12] = { 0, };
-    if (is_emul_input_mouse_enable() == true) {
+    if (is_mouse_enabled() == true) {
         strcpy(buf_input, OPT_INPUT_MOUSE);
     } else {
         strcpy(buf_input, OPT_INPUT_TOUCH);
index 54689629521c96914cf0ef5ed234f93ec5b6cb38..f9cf74e1cc881cc07079cfef5a22bd89a20fd248 100644 (file)
@@ -58,8 +58,8 @@ DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scale
     this->gImg = new QImage();
     this->gPxmImg = new QPixmap();
 
-    isMouse = is_emul_input_mouse_enable();
-    if (isMouse) {
+    isTouch = is_touchscreen_enabled();
+    if (!isTouch) {
         prevX = 0;
         prevY = 0;
         lastMouseTime.tv_sec = 0;
@@ -248,10 +248,10 @@ void DisplayBase::handleMousePress(QMouseEvent *event)
     if (event->button() == Qt::LeftButton) {
         isDragging = true;
 
-        if (isMouse) {
-            do_mouse_event(1, PS2_PRESS, 0, 0, 0, 0, 0);
-        } else {
+        if (isTouch) {
             tsHelper->mousePressed(event, getGuestPos(event->pos()));
+        } else {
+            do_mouse_event(1, PS2_PRESS, 0, 0, 0, 0, 0);
         }
     }
 }
@@ -263,34 +263,17 @@ void DisplayBase::handleMouseRelease(QMouseEvent *event)
             isDragging = false;
         }
 
-        if (isMouse) {
-            do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
-        } else {
+        if (isTouch) {
             tsHelper->mouseReleased(event, getGuestPos(event->pos()));
+        } else {
+            do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
         }
     }
 }
 
 void DisplayBase::handleMouseMove(QMouseEvent *event)
 {
-    if (isMouse) {
-        int event_type = MOUSE_MOVE;
-        int clientX = event->x();
-        int clientY = event->y();
-
-        if (clientX < 0 || clientX > widget->width() ||
-                    clientY < 0 || clientY > widget->height()) {
-            if (isDragging == true) {
-                isDragging = false;
-                qDebug("auto released...");
-                do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
-                return;
-            } else {
-                /* do nothing */
-            }
-        }
-        sendMouseEvent(event_type, clientX, clientY);
-    } else { /* touch device */
+    if (isTouch) { /* touch device */
         if (isDragging == true) {
             int hostPosX = event->x();
             int hostPosY = event->y();
@@ -322,6 +305,23 @@ void DisplayBase::handleMouseMove(QMouseEvent *event)
                 tsHelper->mouseMoved(event, getGuestPos(event->pos()));
             }
         }
+    } else {
+        int event_type = MOUSE_MOVE;
+        int clientX = event->x();
+        int clientY = event->y();
+
+        if (clientX < 0 || clientX > widget->width() ||
+                    clientY < 0 || clientY > widget->height()) {
+            if (isDragging == true) {
+                isDragging = false;
+                qDebug("auto released...");
+                do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
+                return;
+            } else {
+                /* do nothing */
+            }
+        }
+        sendMouseEvent(event_type, clientX, clientY);
     }
 }
 
@@ -337,7 +337,7 @@ void DisplayBase::handleMouseInit(QMouseEvent *event)
 
 void DisplayBase::handleMouseEnter(QEvent *event)
 {
-    if (isMouse) {
+    if (!isTouch) {
         if (mouseStatus == MOUSE_LEAVE) {
             mouseStatus = MOUSE_ENTER;
         }
@@ -346,7 +346,7 @@ void DisplayBase::handleMouseEnter(QEvent *event)
 
 void DisplayBase::handleMouseLeave(QEvent *event)
 {
-    if (isMouse) {
+    if (!isTouch) {
         mouseStatus = MOUSE_LEAVE;
     }
 }
index 01de41184126fdd1f24bdaa6cc2764a29a1526bf..8469475c22e608008c64a2d25f6c398bbd5441ee 100644 (file)
@@ -104,7 +104,7 @@ private:
     void sendMouseEvent(int eventType, int clientX, int clientY);
 
     QSize resolution;
-    bool isMouse;
+    bool isTouch;
 
     int prevX;
     int prevY;
index 28b5f811b2bcbb93fd08592f292448531272781f..9bbbf57d3cc75094b25732ff18b1393c39c8b44f 100644 (file)
@@ -39,9 +39,9 @@ DisplayGLWidget::DisplayGLWidget(QWidget *parent, QGLContext *context,
     QGLWidget(context, parent), DisplayBase(displayForm, resolution, scaleFactor, this)
 {
     setAutoBufferSwap(false);
-    isMouse = is_emul_input_mouse_enable();
+    isTouch = is_touchscreen_enabled();
     /* mouse mode */
-    if (isMouse) {
+    if (!isTouch) {
         setCursor(Qt::BlankCursor);
         setMouseTracking(true);
     }
index f41e08331a678cd3bff5be4e9e83b6a75cf5f930..170c8011592b9e00c29af8e8e833deb72e1e5d37 100644 (file)
@@ -58,7 +58,7 @@ protected:
     void enterEvent(QEvent *event);
     void leaveEvent(QEvent *event);
 private:
-    bool isMouse;
+    bool isTouch;
 };
 
 #endif // DISPLAYGLWIDGET_H
index 7d1d278df5ad04b1ca998f0d931887e4f5ce7784..a973a8c0a00c98d838d5306c4fdf33f9c579c501 100644 (file)
@@ -48,9 +48,9 @@ DisplaySWWidget::DisplaySWWidget(QWidget *parent,
     initImage.fill(Qt::black);
     setPixmap(initImage);
 
-    isMouse = is_emul_input_mouse_enable();
+    isTouch = is_touchscreen_enabled();
     /* mouse mode */
-    if (isMouse) {
+    if (!isTouch) {
         setCursor(Qt::BlankCursor);
         setMouseTracking(true);
     }
index 779c7e87efe36016993d0bec8f5fa8f6e9733661..5c3d27ec32b46b6514aff6ba47edeb7cb0c92cec 100644 (file)
@@ -57,7 +57,7 @@ protected:
     void leaveEvent(QEvent *event);
 private:
     MultiTouchTracker *mtTracker;
-    bool isMouse;
+    bool isTouch;
 };
 
 #endif // DISPLAYSWWIDGET_H
index c255481bb3912bf77e438619e09a3b9646ec34d1..8964d6482a21db2339453b819510a7512768d1e5 100644 (file)
@@ -139,7 +139,7 @@ void do_mouse_event(int button_type, int event_type,
             break;
         case MOUSE_WHEELUP:
         case MOUSE_WHEELDOWN:
-            if (is_emul_input_touch_enable() == true) {
+            if (is_touchscreen_enabled() == true) {
                 x -= guest_x;
                 y -= guest_y;
                 guest_x += x;