#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);
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
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;
/* 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;
}
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);
}
#ifndef MARU_TOUCHSCREEN_H_
#define MARU_TOUCHSCREEN_H_
-#include "ui/console.h"
#include "hw/virtio/virtio.h"
#define TYPE_VIRTIO_TOUCHSCREEN "virtio-touschreen-device"
QEMUBH *bh;
DeviceState *qdev;
- QEMUPutMouseEntry *eh_entry;
} VirtIOTouchscreen;
/* This structure must match the kernel definitions */
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_ */
#include <SDL.h>
#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);
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);
}
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 */
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;
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 */
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);
}
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 */
{
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 */
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;
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 {
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:
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:
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:
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
- }
}
}
}
{
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
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);
}