From: GiWoong Kim Date: Tue, 22 Apr 2014 07:53:47 +0000 (+0900) Subject: touch: Maru touchscreen device handles touch events directly X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~386^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F63%2F19863%2F1;p=sdk%2Femulator%2Fqemu.git touch: Maru touchscreen device handles touch events directly Change-Id: I40f4af19103e7a2add265f3bcefe1f62d03fa2b7 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ecs/ecs_tethering.c b/tizen/src/ecs/ecs_tethering.c index 4e98aa9829..0e6f5920cb 100644 --- a/tizen/src/ecs/ecs_tethering.c +++ b/tizen/src/ecs/ecs_tethering.c @@ -32,7 +32,7 @@ #include "ecs.h" #include "ecs_tethering.h" #include "../tethering/app_tethering.h" - +#include "../hw/maru_virtio_touchscreen.h" #include "../debug_ch.h" MULTI_DEBUG_CHANNEL(tizen, ecs_tethering); @@ -227,7 +227,7 @@ void send_tethering_sensor_data(const char *data, int len) void send_tethering_touch_data(int x, int y, int index, int status) { - kbd_mouse_event(x, y, index, status); + virtio_touchscreen_event(x, y, index, status); } // handle tethering_req message diff --git a/tizen/src/hw/maru_virtio_touchscreen.c b/tizen/src/hw/maru_virtio_touchscreen.c index b68991ffbb..2f0f1789ab 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.c +++ b/tizen/src/hw/maru_virtio_touchscreen.c @@ -85,7 +85,7 @@ static pthread_mutex_t event_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t elem_mutex = PTHREAD_MUTEX_INITIALIZER; -void virtio_touchscreen_event(void *opaque, int x, int y, int z, int buttons_state) +void virtio_touchscreen_event(int x, int y, int z, int buttons_state) { TouchEventEntry *entry = NULL; @@ -326,14 +326,6 @@ static int virtio_touchscreen_device_init(VirtIODevice *vdev) /* bottom halves */ ts->bh = qemu_bh_new(maru_touchscreen_bh, ts); -#if 1 - /* register a event handler */ - ts->eh_entry = qemu_add_mouse_event_handler( - virtio_touchscreen_event, ts, 1, "QEMU Virtio Touchscreen"); - qemu_activate_mouse_event_handler(ts->eh_entry); - INFO("virtio touchscreen is added to qemu mouse event handler\n"); -#endif - return 0; } @@ -343,10 +335,6 @@ static int virtio_touchscreen_device_exit(DeviceState *qdev) INFO("exit the touchscreen device\n"); - if (ts->eh_entry) { - qemu_remove_mouse_event_handler(ts->eh_entry); - } - if (ts->bh) { qemu_bh_delete(ts->bh); } diff --git a/tizen/src/hw/maru_virtio_touchscreen.h b/tizen/src/hw/maru_virtio_touchscreen.h index 777d3ef7a0..7c35298a39 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.h +++ b/tizen/src/hw/maru_virtio_touchscreen.h @@ -30,7 +30,6 @@ #ifndef MARU_TOUCHSCREEN_H_ #define MARU_TOUCHSCREEN_H_ -#include "ui/console.h" #include "hw/virtio/virtio.h" #define TYPE_VIRTIO_TOUCHSCREEN "virtio-touschreen-device" @@ -46,7 +45,6 @@ typedef struct VirtIOTouchscreen { QEMUBH *bh; DeviceState *qdev; - QEMUPutMouseEntry *eh_entry; } VirtIOTouchscreen; /* This structure must match the kernel definitions */ @@ -55,11 +53,8 @@ typedef struct EmulTouchEvent { uint8_t state; } EmulTouchEvent; -VirtIODevice *maru_virtio_touchscreen_init(DeviceState *dev); -void maru_virtio_touchscreen_exit(VirtIODevice *vdev); - -void virtio_touchscreen_event(void *opaque, int x, int y, int z, int buttons_state); +void virtio_touchscreen_event(int x, int y, int z, int buttons_state); void maru_virtio_touchscreen_notify(void); #endif /* MARU_TOUCHSCREEN_H_ */ diff --git a/tizen/src/maru_finger.c b/tizen/src/maru_finger.c index 6c2ccf5eba..f8d55d7a10 100644 --- a/tizen/src/maru_finger.c +++ b/tizen/src/maru_finger.c @@ -33,8 +33,8 @@ #include #include "maru_finger.h" #include "emul_state.h" +#include "hw/maru_virtio_touchscreen.h" #include "debug_ch.h" -#include "ui/console.h" MULTI_DEBUG_CHANNEL(qemu, maru_finger); @@ -318,7 +318,8 @@ void maru_finger_processing_1( finger->y = y; if (finger->id != 0) { - kbd_mouse_event(x, y, _grab_finger_id - 1, QEMU_MOUSE_PRESSED); + virtio_touchscreen_event(x, y, + _grab_finger_id - 1, QEMU_MOUSE_PRESSED); TRACE("id %d finger multi-touch dragging : (%d, %d)\n", _grab_finger_id, x, y); } @@ -333,7 +334,7 @@ void maru_finger_processing_1( return; } - kbd_mouse_event(x, y, 0, QEMU_MOUSE_PRESSED); + virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED); } else if ((finger = get_finger_point_search(x, y)) != NULL) { /* check the position of previous touch event */ @@ -348,7 +349,8 @@ void maru_finger_processing_1( finger = get_finger_point_from_slot(mts->finger_cnt_max - 1); if (finger != NULL) { #if 1 /* send release event?? */ - kbd_mouse_event(finger->x, finger->y, mts->finger_cnt_max - 1, 0); + virtio_touchscreen_event(finger->x, finger->y, + mts->finger_cnt_max - 1, QEMU_MOUSE_RELEASEED); #endif finger->origin_x = origin_x; @@ -356,15 +358,16 @@ void maru_finger_processing_1( finger->x = x; finger->y = y; if (finger->id != 0) { - kbd_mouse_event(x, y, mts->finger_cnt_max - 1, QEMU_MOUSE_PRESSED); + virtio_touchscreen_event(x, y, + mts->finger_cnt_max - 1, QEMU_MOUSE_PRESSED); } } } else /* one more finger */ { - - add_finger_point(origin_x, origin_y, x, y) ; - kbd_mouse_event(x, y, mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); + add_finger_point(origin_x, origin_y, x, y); + virtio_touchscreen_event(x, y, + mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); } } else if (touch_type == MOUSE_UP) { /* released */ @@ -423,7 +426,8 @@ void maru_finger_processing_2( finger->y += distance_y; if (finger->id != 0) { - kbd_mouse_event(finger->x, finger->y, i, QEMU_MOUSE_PRESSED); + virtio_touchscreen_event(finger->x, finger->y, + i, QEMU_MOUSE_PRESSED); TRACE("id %d finger multi-touch dragging = (%d, %d)\n", i + 1, finger->x, finger->y); } @@ -446,7 +450,7 @@ void maru_finger_processing_2( return; } - kbd_mouse_event(x, y, 0, QEMU_MOUSE_PRESSED); + virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED); } else if ((finger = get_finger_point_search(x, y)) != NULL) { /* check the position of previous touch event */ @@ -464,7 +468,7 @@ void maru_finger_processing_2( { add_finger_point(origin_x, origin_y, x, y) ; - kbd_mouse_event(x, y, mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); + virtio_touchscreen_event(x, y, mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); } } else if (touch_type == MOUSE_UP) { /* released */ @@ -558,7 +562,8 @@ void clear_finger_slot(bool keep_enable) finger = get_finger_point_from_slot(i); if (finger != NULL) { if (finger->id > 0) { - kbd_mouse_event(finger->x, finger->y, finger->id - 1, QEMU_MOUSE_RELEASEED); + virtio_touchscreen_event(finger->x, finger->y, + finger->id - 1, QEMU_MOUSE_RELEASEED); } finger->id = 0; diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 6c6b150ee1..6878f5b4e2 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -106,7 +106,7 @@ void do_mouse_event(int button_type, int event_type, if (brightness_off) { if (button_type == 0) { INFO("auto mouse release\n"); - kbd_mouse_event(0, 0, 0, 0); + virtio_touchscreen_event(0, 0, 0, 0); return; } else { @@ -145,7 +145,7 @@ void do_mouse_event(int button_type, int event_type, pressing_origin_x = origin_x; pressing_origin_y = origin_y; - kbd_mouse_event(x, y, z, 1); + virtio_touchscreen_event(x, y, z, 1); break; case MOUSE_UP: @@ -154,7 +154,7 @@ void do_mouse_event(int button_type, int event_type, pressing_x = pressing_y = -1; pressing_origin_x = pressing_origin_y = -1; - kbd_mouse_event(x, y, z, 0); + virtio_touchscreen_event(x, y, z, 0); break; case MOUSE_WHEELUP: @@ -169,14 +169,14 @@ void do_mouse_event(int button_type, int event_type, guest_y = y; } - kbd_mouse_event(x, y, -z, event_type); + virtio_touchscreen_event(x, y, -z, event_type); break; case MOUSE_MOVE: guest_x = x; guest_y = y; - kbd_mouse_event(x, y, z, event_type); + virtio_touchscreen_event(x, y, z, event_type); break; default: @@ -287,22 +287,21 @@ void do_keyboard_key_event(int event_type, void do_hw_key_event(int event_type, int keycode) { - INFO("HW Key : event_type=%d, keycode=%d\n", - event_type, keycode); - - if ( runstate_check(RUN_STATE_SUSPENDED) ) { - if ( KEY_PRESSED == event_type ) { - if ( kbd_mouse_is_absolute() ) { - // home key or power key is used for resume. - if ( ( HARD_KEY_HOME == keycode ) || ( HARD_KEY_POWER == keycode ) ) { - INFO( "user requests system resume.\n" ); - resume(); + INFO("HW Key : event_type=%d, keycode=%d\n", event_type, keycode); + + // TODO: remove workaround + if (runstate_check(RUN_STATE_SUSPENDED)) { + if (KEY_PRESSED == event_type) { + /* home key or power key is used for resume */ + if ((HARD_KEY_HOME == keycode) || (HARD_KEY_POWER == keycode)) { + INFO("user requests system resume\n"); + resume(); + #ifdef CONFIG_WIN32 - Sleep( RESUME_KEY_SEND_INTERVAL ); + Sleep(RESUME_KEY_SEND_INTERVAL); #else - usleep( RESUME_KEY_SEND_INTERVAL * 1000 ); + usleep(RESUME_KEY_SEND_INTERVAL * 1000); #endif - } } } } @@ -589,7 +588,7 @@ void request_close(void) { INFO("request_close\n"); - /* FIXME: convert to device emulatoion */ + // TODO: convert to device emulation do_hw_key_event(KEY_PRESSED, HARD_KEY_POWER); #ifdef CONFIG_WIN32 diff --git a/ui/input.c b/ui/input.c index 6d678d1ed6..7afa8d884c 100644 --- a/ui/input.c +++ b/ui/input.c @@ -267,27 +267,6 @@ int qemu_input_scale_axis(int value, int size_in, int size_out) if (size_in < 2) { return size_out / 2; } -#if 0 //defined (CONFIG_MARU) - QTAILQ_FOREACH(entry, &mouse_handlers, node) { - /* if mouse event is wheelup ,wheeldown or move - then go to ps2 mouse event(index == 0) */ - if (buttons_state > 3 && entry->index == 0) { - //INFO("input device: %s, event: %d\n", entry->qemu_put_mouse_event_name, buttons_state); - buttons_state = 0; - mouse_event = entry->qemu_put_mouse_event; - mouse_event_opaque = entry->qemu_put_mouse_event_opaque; - break; - } - } - /* other events(mouse up, down and drag), go to touch screen */ - if (!entry) { - entry = QTAILQ_FIRST(&mouse_handlers); - mouse_event = entry->qemu_put_mouse_event; - mouse_event_opaque = entry->qemu_put_mouse_event_opaque; - //INFO("input device: %s, event: %d\n", entry->qemu_put_mouse_event_name, buttons_state); - } -#endif - return (int64_t)value * (size_out - 1) / (size_in - 1); }