--- /dev/null
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <linux/input.h>
+
+#include <Eina.h>
+#include <Ecore.h>
+#include <dlog.h>
+
+#include "util.h"
+#include "debug.h"
+#include "conf.h"
+#include "event.h"
+
+#define CRITICAL_SECTION_BEGIN(lock) do { \
+ int ret; \
+ ret = pthread_mutex_lock(&lock); \
+ if (ret != 0) { \
+ ErrPrint("Unable to get lock: %s\n", strerror(ret)); \
+ } \
+} while (0)
+
+#define CRITICAL_SECTION_END(lock) do { \
+ int ret; \
+ ret = pthread_mutex_unlock(&lock); \
+ if (ret != 0) { \
+ ErrPrint("Unable to unlock: %s\n", strerror(ret)); \
+ } \
+} while (0)
+
+#define CANCEL_SECTION_BEGIN() do { \
+ int ret; \
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); \
+ if (ret != 0) \
+ ErrPrint("Unable to set cancelate state: %s\n", strerror(ret)); \
+} while (0)
+
+#define CANCEL_SECTION_END() do { \
+ int ret; \
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); \
+ if (ret != 0) \
+ ErrPrint("Unable to set cancelate state: %s\n", strerror(ret)); \
+} while (0)
+
+#define PIPE_READ 0
+#define PIPE_WRITE 1
+#define EVENT_CH 'e'
+
+int errno;
+
+static struct info {
+ pthread_t tid;
+ Eina_List *event_list;
+ int handle;
+ pthread_mutex_t event_list_lock;
+ int evt_pipe[2];
+ Ecore_Fd_Handler *event_handler;
+
+ int (*event_cb)(enum event_state state, struct event_data *event, void *data);
+ void *cbdata;
+
+ enum event_state event_state;
+ struct event_data event_data;
+
+ int x;
+ int y;
+} s_info = {
+ .event_list = NULL,
+ .handle = -1,
+ .event_handler = NULL,
+
+ .event_cb = NULL,
+ .cbdata = NULL,
+
+ .event_state = EVENT_STATE_DEACTIVATE,
+
+ .event_data = {
+ .x = 0,
+ .y = 0,
+ .device = -1,
+ },
+};
+
+HAPI int event_init(void)
+{
+ int ret;
+ ret = pthread_mutex_init(&s_info.event_list_lock, NULL);
+ if (ret != 0) {
+ ErrPrint("Mutex: %s\n", strerror(ret));
+ return -EFAULT;
+ }
+ return 0;
+}
+
+HAPI int event_fini(void)
+{
+ int ret;
+ ret = pthread_mutex_destroy(&s_info.event_list_lock);
+ if (ret != 0)
+ ErrPrint("Mutex destroy failed: %s\n", strerror(ret));
+ return 0;
+}
+
+static inline int processing_input_event(struct input_event *event)
+{
+ struct event_data *item;
+
+ switch (event->type) {
+ case EV_SYN:
+ switch (event->code) {
+ case SYN_REPORT:
+ if (s_info.event_data.x < 0 || s_info.event_data.y < 0) {
+ /* Waiting full event packet */
+ break;
+ }
+
+ item = malloc(sizeof(*item));
+ if (item) {
+ char event_ch;
+
+ memcpy(item, &s_info.event_data, sizeof(*item));
+
+ CRITICAL_SECTION_BEGIN(s_info.event_list_lock);
+ s_info.event_list = eina_list_append(s_info.event_list, item);
+ CRITICAL_SECTION_END(s_info.event_list_lock);
+
+ event_ch = EVENT_CH;
+ if (write(s_info.evt_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
+ ErrPrint("Unable to send an event: %s\n", strerror(errno));
+ return -EIO;
+ }
+ }
+ break;
+ case SYN_CONFIG:
+ break;
+ case SYN_MT_REPORT:
+ break;
+ /*
+ case SYN_DROPPED:
+ DbgPrint("EV_SYN, SYN_DROPPED\n");
+ break;
+ */
+ default:
+ DbgPrint("EV_SYN, 0x%x\n", event->code);
+ break;
+ }
+ break;
+ case EV_KEY:
+ break;
+ case EV_REL:
+ break;
+ case EV_ABS:
+ switch (event->code) {
+ case ABS_DISTANCE:
+ break;
+ case ABS_MT_POSITION_X:
+ s_info.event_data.x = event->value - s_info.x;
+ break;
+ case ABS_MT_POSITION_Y:
+ s_info.event_data.y = event->value - s_info.y;
+ break;
+ case ABS_MT_SLOT:
+ break;
+ case ABS_MT_TRACKING_ID:
+ s_info.event_data.device = event->value;
+ break;
+ case ABS_MT_TOUCH_MAJOR:
+ break;
+ case ABS_MT_TOUCH_MINOR:
+ break;
+ case ABS_MT_WIDTH_MAJOR:
+ break;
+ case ABS_MT_WIDTH_MINOR:
+ break;
+ default:
+ DbgPrint("EV_ABS, 0x%x\n", event->code);
+ break;
+ }
+ break;
+ case EV_MSC:
+ break;
+ case EV_SW:
+ break;
+ case EV_LED:
+ break;
+ case EV_SND:
+ break;
+ case EV_REP:
+ break;
+ case EV_FF:
+ break;
+ case EV_PWR:
+ break;
+ case EV_FF_STATUS:
+ break;
+ default:
+ DbgPrint("0x%X, 0x%X\n", event->type, event->code);
+ break;
+ }
+
+ return 0;
+}
+
+static void *event_main(void *data)
+{
+ fd_set set;
+ int ret = 0;
+ struct input_event input_event;
+ char *ptr = (char *)&input_event;
+ int offset = 0;
+ int readsize = 0;
+
+ DbgPrint("event_main initiated\n");
+
+ while (1) {
+ CANCEL_SECTION_BEGIN();
+ FD_ZERO(&set);
+ FD_SET(s_info.handle, &set);
+ ret = select(s_info.handle + 1, &set, NULL, NULL, NULL);
+ if (ret < 0) {
+ ret = -errno;
+ if (errno == EINTR) {
+ DbgPrint("Select receives INTR\n");
+ CANCEL_SECTION_END();
+ continue;
+ }
+ ErrPrint("Error: %s\n", strerror(errno));
+ CANCEL_SECTION_END();
+ return (void *)ret;
+ } else if (ret == 0) {
+ ErrPrint("Timeout expired\n");
+ CANCEL_SECTION_END();
+ return (void *)-ETIMEDOUT;
+ }
+ CANCEL_SECTION_END();
+
+ if (!FD_ISSET(s_info.handle, &set)) {
+ ErrPrint("Unexpected handle is toggled\n");
+ ret = -EINVAL;
+ break;
+ }
+
+ readsize = read(s_info.handle, ptr + offset, sizeof(input_event) - offset);
+ if (readsize < 0) {
+ ErrPrint("Unable to read device: %s / fd: %d / offset: %d / size: %d - %d\n", strerror(errno), s_info.handle, offset, sizeof(input_event), readsize);
+ ret = -EFAULT;
+ break;
+ }
+
+ offset += readsize;
+ if (offset == sizeof(input_event)) {
+ offset = 0;
+ if (processing_input_event(&input_event) < 0) {
+ ret = -EFAULT;
+ break;
+ }
+ }
+ }
+
+ return (void *)ret;
+}
+
+static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
+{
+ int fd;
+ struct event_data *item;
+ char event_ch;
+
+ fd = ecore_main_fd_handler_fd_get(handler);
+ if (fd < 0) {
+ ErrPrint("Invalid fd\n");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (read(fd, &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
+ ErrPrint("Unable to read event ch: %s\n", strerror(errno));
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ CRITICAL_SECTION_BEGIN(s_info.event_list_lock);
+ item = eina_list_nth(s_info.event_list, 0);
+ if (item)
+ s_info.event_list = eina_list_remove(s_info.event_list, item);
+ else
+ ErrPrint("Unable to get event\n");
+ CRITICAL_SECTION_END(s_info.event_list_lock);
+
+ if (item && s_info.event_cb) {
+ switch (s_info.event_state) {
+ case EVENT_STATE_DEACTIVATE:
+ s_info.event_state = EVENT_STATE_ACTIVATE;
+ break;
+ case EVENT_STATE_ACTIVATE:
+ s_info.event_state = EVENT_STATE_ACTIVATED;
+ break;
+ case EVENT_STATE_ACTIVATED:
+ default:
+ break;
+ }
+ s_info.event_cb(s_info.event_state, item, s_info.cbdata);
+ }
+
+ free(item);
+ return ECORE_CALLBACK_RENEW;
+}
+
+HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data)
+{
+ int status;
+
+ if (s_info.handle >= 0) {
+ DbgPrint("Already activated\n");
+ return 0;
+ }
+
+ s_info.handle = open(INPUT_PATH, O_RDONLY);
+ if (s_info.handle < 0) {
+ ErrPrint("Unable to access the device: %s\n", strerror(errno));
+ return -EIO;
+ }
+
+ if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+
+ if (fcntl(s_info.handle, F_SETFL, O_NONBLOCK) < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+
+ status = pipe2(s_info.evt_pipe, O_NONBLOCK | O_CLOEXEC);
+ if (status < 0) {
+ ErrPrint("Unable to prepare evt pipe: %s\n", strerror(errno));
+ if (close(s_info.handle) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+ s_info.handle = -1;
+ return -EFAULT;
+ }
+
+ s_info.event_handler = ecore_main_fd_handler_add(s_info.evt_pipe[PIPE_READ], ECORE_FD_READ, event_read_cb, NULL, NULL, NULL);
+ if (!s_info.event_handler) {
+ if (close(s_info.handle) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_READ]) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_WRITE]) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+
+ s_info.handle = -1;
+ return -EFAULT;
+ }
+
+ status = pthread_create(&s_info.tid, NULL, event_main, NULL);
+ if (status != 0) {
+ ErrPrint("Failed to initiate the thread: %s\n", strerror(status));
+ ecore_main_fd_handler_del(s_info.event_handler);
+ s_info.event_handler = NULL;
+
+ if (close(s_info.handle) < 0)
+ ErrPrint("close: %s\n", strerror(errno));
+ s_info.handle = -1;
+
+ if (close(s_info.evt_pipe[PIPE_READ]) < 0)
+ ErrPrint("close: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_WRITE]) < 0)
+ ErrPrint("close: %s\n", strerror(errno));
+
+ return -EFAULT;
+ }
+
+ s_info.event_cb = event_cb;
+ s_info.cbdata = data;
+ s_info.x = x;
+ s_info.y = y;
+
+ DbgPrint("Event handler activated\n");
+ return 0;
+}
+
+HAPI int event_deactivate(void)
+{
+ int status;
+ struct event_data *event;
+ void *ret;
+
+ if (s_info.handle < 0) {
+ ErrPrint("Event handler is not actiavated\n");
+ return 0;
+ }
+
+ status = pthread_cancel(s_info.tid);
+ if (status != 0)
+ ErrPrint("Failed to cacnel a thread: %s\n", strerror(errno));
+
+ status = pthread_join(s_info.tid, &ret);
+ if (status != 0)
+ ErrPrint("Failed to join a thread: %s\n", strerror(errno));
+ else if (ret == PTHREAD_CANCELED)
+ DbgPrint("Thread is canceled\n");
+
+ ecore_main_fd_handler_del(s_info.event_handler);
+ s_info.event_handler = NULL;
+
+ if (close(s_info.evt_pipe[PIPE_READ]) < 0)
+ ErrPrint("Failed to close: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_WRITE]) < 0)
+ ErrPrint("Failed to close: %s\n", strerror(errno));
+
+ if (close(s_info.handle) < 0)
+ ErrPrint("Unable to release the fd: %s\n", strerror(errno));
+
+ s_info.handle = -1;
+ DbgPrint("Event handler deactivated\n");
+
+ EINA_LIST_FREE(s_info.event_list, event) {
+ if (s_info.event_cb) {
+ if (s_info.event_state == EVENT_STATE_DEACTIVATE) {
+ s_info.event_state = EVENT_STATE_ACTIVATE;
+ } else if (s_info.event_state == EVENT_STATE_ACTIVATE) {
+ s_info.event_state = EVENT_STATE_ACTIVATED;
+ }
+ s_info.event_cb(s_info.event_state, event, s_info.cbdata);
+ }
+ free(event);
+ }
+
+ if (s_info.event_state != EVENT_STATE_DEACTIVATE) {
+ s_info.event_state = EVENT_STATE_DEACTIVATE;
+
+ if (s_info.event_cb)
+ s_info.event_cb(s_info.event_state, &s_info.event_data, s_info.cbdata);
+ }
+
+ s_info.event_data.x = -1;
+ s_info.event_data.y = -1;
+
+ return 0;
+}
+
+HAPI int event_is_activated(void)
+{
+ return s_info.handle >= 0;
+}
+
+/* End of a file */
#include "abi.h"
#include "liveinfo.h"
#include "io.h"
+#include "event.h"
static struct info {
int info_fd;
struct inst_info *inst;
};
+static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ struct slave_node *slave;
+ struct packet *packet;
+ const char *cmdstr;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return -EINVAL;
+
+ slave = package_slave(pkg);
+ if (!slave)
+ return -EINVAL;
+
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ cmdstr = "lb_mouse_down";
+ break;
+ case EVENT_STATE_ACTIVATED:
+ cmdstr = "lb_mouse_move";
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ cmdstr = "lb_mouse_up";
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
+ if (!packet)
+ return -EFAULT;
+
+ return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
+}
+
+static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct script_info *script;
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ double timestamp;
+ Evas *e;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return 0;
+
+ script = instance_lb_script(inst);
+ if (!script)
+ return -EFAULT;
+
+ e = script_handler_evas(script);
+ if (!e)
+ return -EFAULT;
+
+ timestamp = util_timestamp();
+
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+ break;
+ case EVENT_STATE_ACTIVATED:
+ script_handler_update_pointer(script, event_info->x, event_info->y, -1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 0);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ struct slave_node *slave;
+ struct packet *packet;
+ const char *cmdstr;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return -EINVAL;
+
+ slave = package_slave(pkg);
+ if (!slave)
+ return -EINVAL;
+
+ DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ cmdstr = "pd_mouse_down";
+ break;
+ case EVENT_STATE_ACTIVATED:
+ cmdstr = "pd_mouse_move";
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ cmdstr = "pd_mouse_up";
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
+ if (!packet)
+ return -EFAULT;
+
+ return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
+}
+
+static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct script_info *script;
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ double timestamp;
+ Evas *e;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return 0;
+
+ script = instance_pd_script(inst);
+ if (!script)
+ return -EFAULT;
+
+ e = script_handler_evas(script);
+ if (!e)
+ return -EFAULT;
+
+ DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
+ timestamp = util_timestamp();
+
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+ break;
+ case EVENT_STATE_ACTIVATED:
+ script_handler_update_pointer(script, event_info->x, event_info->y, -1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 0);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
{
struct client_node *client;
const char *id;
const char *event;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
int ret;
struct inst_info *inst;
goto out;
}
- ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
+ ret = packet_get(packet, "sssdii", &pkgname, &id, &event, ×tamp, &x, &y);
if (ret != 6) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%lf] y[%lf]\n", pid, pkgname, id, event, timestamp, x, y);
+ DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%d] y[%d]\n", pid, pkgname, id, event, timestamp, x, y);
/*!
* \NOTE:
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
+ DbgPrint("(%dx%d)\n", x, y);
/*!
* \NOTE:
}
script_handler_update_pointer(script, x, y, 1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
ret = 0;
} else {
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
+ DbgPrint("(%dx%d)\n", x, y);
/*!
* \NOTE:
* Trust the package name which are sent by the client.
}
script_handler_update_pointer(script, x, y, 0);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
ret = 0;
} else {
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
+ DbgPrint("(%dx%d)\n", x, y);
/*!
* \NOTE:
* Trust the package name which are sent by the client.
}
script_handler_update_pointer(script, x, y, -1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
return NULL;
}
+static int inst_del_cb(struct inst_info *inst, void *data)
+{
+ event_deactivate();
+ return -1; /* Delete this callback */
+}
+
+static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_lb_route_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_lb_consume_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+out:
+ return NULL;
+}
+
+static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+out:
+ return NULL;
+}
+
+static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_pd_route_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_pd_consume_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+out:
+ return NULL;
+}
+
static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
script_handler_update_pointer(script, x, y, 1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
ret = 0;
} else {
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
script_handler_update_pointer(script, x, y, 0);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
ret = 0;
} else {
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 7) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
.handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
},
{
+ .cmd = "lb_mouse_set",
+ .handler = client_lb_mouse_set,
+ },
+ {
+ .cmd = "lb_mouse_unset",
+ .handler = client_lb_mouse_unset,
+ },
+ {
+ .cmd = "pd_mouse_set",
+ .handler = client_pd_mouse_set,
+ },
+ {
+ .cmd = "pd_mouse_unset",
+ .handler = client_pd_mouse_unset,
+ },
+ {
.cmd = "change,visibility",
.handler = client_change_visibility,
},