#include <pixman.h>
#include "e_test_event.h"
+#include "e_test_inputevent.h"
#define E_TEST_WORK_TIME 3.0
#define E_TC_SIGN_WIN_INFO "usiiiiibbbiibibbbi"
static Eina_Bool _cb_ecore_mouse_button_down(void *data, int type, void *event);
static Eina_Bool _cb_ecore_mouse_button_up(void *data, int type, void *event);
static Eina_Bool _cb_ecore_mouse_move(void *data, int type, void *event);
+static Eina_Bool _cb_ecore_mouse_relative_move(void *data, int type, void *event);
/* callbacks - evas */
static void _cb_evas_key_down(void * data, Evas * evas, Evas_Object * obj, void * event_info);
ERR("not supported resolution. do not execute verifyTC");
}
+ init_input_device();
+
return EINA_TRUE;
}
{
eina_log_domain_unregister(logDomain);
+ deinit_input_device();
+
freeLastWinInfoList();
if (screenshot)
return EINA_TRUE;
}
+void
+etRunner::feedLowLevelMouseMove(int x, int y)
+{
+ pointer_gen_move(x, y);
+}
+
Eina_Bool
etRunner::feedMouseUp(int x, int y)
{
return recv_item;
}
else if ((ev_type == E_TC_EVENT_TYPE_INPUT_ECORE_KEY) ||
- (ev_type == E_TC_EVENT_TYPE_INPUT_ECORE_MOUSE))
+ (ev_type == E_TC_EVENT_TYPE_INPUT_ECORE_MOUSE) ||
+ (ev_type == E_TC_EVENT_TYPE_INPUT_ECORE_MOUSE_RELATIVE_MOVE))
{
Ecore_Window ew = elm_win_window_id_get(win?win->elm_win:0);
if (recv_item->isSameWin(ew) &&
EINA_SAFETY_ON_NULL_GOTO(eh, err);
ev.eh_list = eina_list_append(ev.eh_list, eh);
+ eh = ecore_event_handler_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, _cb_ecore_mouse_relative_move, this);
+ EINA_SAFETY_ON_NULL_GOTO(eh, err);
+ ev.eh_list = eina_list_append(ev.eh_list, eh);
+
ev.mouse.ecore_state = EINA_FALSE;
return EINA_TRUE;
return ECORE_CALLBACK_PASS_ON;
}
+static Eina_Bool
+_cb_ecore_mouse_relative_move(void *data, int type, void *event)
+{
+ Ecore_Event_Mouse_Relative_Move *ev = (Ecore_Event_Mouse_Relative_Move *)event;
+ etRunner *runner = (etRunner *)data;
+
+ DBG("[%s] Mouse Relative Move cb (%d, %d)", __func__, ev->dx, ev->dy);
+
+ if ((runner->ev.mouse.x == ev->dx) &&
+ (runner->ev.mouse.y == ev->dy))
+ {
+ if (type == ECORE_EVENT_MOUSE_RELATIVE_MOVE)
+ {
+ if (checkEcoreDeviceInfo(ev->dev))
+ {
+ DBG("Mouse Relative Move cb. insert event");
+ runner->insertEventQueue(ev->window, E_TC_EVENT_TYPE_INPUT_ECORE_MOUSE_RELATIVE_MOVE);
+ }
+ else
+ ERR("Mouse Relative MOVE cb. device info is empty");
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
/* callbacks - evas */
static void
_cb_evas_key_down(void *data, Evas * evas, Evas_Object * obj, void * event_info)
--- /dev/null
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <linux/uinput.h>
+#include <string.h>
+#include <stdbool.h>
+
+enum
+{
+ INPUT_SEAT_POINTER = 0,
+ INPUT_SEAT_KEYBOARD
+} Input_Device_Type;
+
+typedef struct _Virtual_Input_Device
+{
+ bool virtual_dev;
+ int fd;
+ char *name;
+} Virtual_Input_Device;
+
+static Virtual_Input_Device _input_info[2] =
+{
+ {
+ false,
+ -1,
+ NULL
+ },
+};
+
+static void
+input_set_keyboard(struct uinput_user_dev *uinput_dev, int uinput_fd)
+{
+ int i;
+
+ for (i = KEY_ESC; i <= KEY_MICMUTE; i++)
+ ioctl(uinput_fd, UI_SET_KEYBIT, i);
+
+ for (i = KEY_OK; i <= KEY_LIGHTS_TOGGLE; i++)
+ ioctl(uinput_fd, UI_SET_KEYBIT, i);
+
+ for (i = KEY_ALS_TOGGLE; i <= KEY_ONSCREEN_KEYBOARD; i++)
+ ioctl(uinput_fd, UI_SET_KEYBIT, i);
+}
+
+static void
+input_set_pointer(struct uinput_user_dev *uinput_dev, int uinput_fd)
+{
+ int i;
+
+ ioctl(uinput_fd, UI_SET_EVBIT, EV_REL);
+
+ ioctl(uinput_fd, UI_SET_RELBIT, REL_X);
+ ioctl(uinput_fd, UI_SET_RELBIT, REL_Y);
+ ioctl(uinput_fd, UI_SET_RELBIT, REL_WHEEL);
+ ioctl(uinput_fd, UI_SET_RELBIT, REL_HWHEEL);
+
+ for (i = BTN_MISC; i <= BTN_TASK; i++)
+ ioctl(uinput_fd, UI_SET_KEYBIT, i);
+}
+
+static int
+create_input_device(const char *dev_name, int device_type)
+{
+ int uinput_fd = -1, nwrite = 0;
+ struct uinput_user_dev uinput_dev = {0, };
+
+ uinput_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
+ if (uinput_fd < 0)
+ return -1;
+
+ strncpy(uinput_dev.name, dev_name, UINPUT_MAX_NAME_SIZE - 1);
+ uinput_dev.id.version = 1;
+ uinput_dev.id.bustype = BUS_VIRTUAL;
+
+ ioctl(uinput_fd, UI_SET_EVBIT, EV_KEY);
+ ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN);
+ ioctl(uinput_fd, UI_SET_EVBIT, EV_MSC);
+ ioctl(uinput_fd, UI_SET_MSCBIT, MSC_SCAN);
+
+ if (device_type == INPUT_SEAT_KEYBOARD)
+ input_set_keyboard(&uinput_dev, uinput_fd);
+ else if (device_type == INPUT_SEAT_POINTER)
+ input_set_pointer(&uinput_dev, uinput_fd);
+
+ /* Create input device into input sub-system */
+ nwrite = write(uinput_fd, &uinput_dev, sizeof(uinput_dev));
+ if (nwrite < 0) printf("Failed to write for create device using uinput (err: %m)\n");
+
+ if (ioctl(uinput_fd, UI_DEV_CREATE))
+ {
+ printf("Failed to create %s device (err: %m)\n", dev_name);
+ close (uinput_fd);
+ return -1;
+ }
+
+ return uinput_fd;
+}
+
+bool init_input_device()
+{
+ int fd = 0;
+ const char *name = "Input_Script";
+
+ for (int device_type = 0; device_type < 2; device_type++)
+ {
+ fd = create_input_device(name, device_type);
+ if (fd)
+ {
+ _input_info[device_type].virtual_dev = true;
+ _input_info[device_type].fd = fd;
+ _input_info[device_type].name = strdup(name);
+ }
+
+ if (fd < 0)
+ {
+ _input_info[device_type].virtual_dev = false;
+ _input_info[device_type].fd = -1;
+ if (_input_info[device_type].name)
+ {
+ free(_input_info[device_type].name);
+ _input_info[device_type].name = NULL;
+ }
+
+ printf("Failed to open event node or uinput node");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void deinit_input_device()
+{
+ int ret;
+
+ for (int i=0; i<2; i++)
+ {
+ if (_input_info[i].fd < 0) continue;
+
+ if (_input_info[i].virtual_dev)
+ {
+ ret = ioctl(_input_info[i].fd, UI_DEV_DESTROY, NULL);
+ if (ret) printf("Failed destroy fd: %d (ret: %d) (err: %m)\n", _input_info[i].fd, ret);
+ }
+ close(_input_info[i].fd);
+
+ _input_info[i].fd = -1;
+ _input_info[i].virtual_dev = false;
+
+ if (_input_info[i].name)
+ {
+ free(_input_info[i].name);
+ _input_info[i].name = NULL;
+ }
+ }
+}
+
+int write_event_to_device_node(int device_type, int event_type, int code, int value)
+{
+ int nwrite;
+ struct input_event ev;
+
+ gettimeofday(&ev.time, NULL);
+
+ ev.type = event_type;
+ ev.code = code;
+ ev.value = value;
+
+ nwrite = write(_input_info[device_type].fd, &ev, sizeof(ev));
+ if (nwrite < 0)
+ printf("Error writing input event\n");
+
+ return nwrite;
+}
+
+static void
+_sync_gen(int device_type)
+{
+ write_event_to_device_node(device_type, EV_SYN, 0, 0);
+}
+
+static void
+_pointer_gen_x(int value)
+{
+ write_event_to_device_node(INPUT_SEAT_POINTER, EV_REL, REL_X, value);
+}
+
+static void
+_pointer_gen_y(int value)
+{
+ write_event_to_device_node(INPUT_SEAT_POINTER, EV_REL, REL_Y, value);
+}
+
+void pointer_gen_move(int x, int y)
+{
+ if (x != 0) _pointer_gen_x(x);
+ if (y != 0) _pointer_gen_y(y);
+ _sync_gen(INPUT_SEAT_POINTER);
+}