diff options
author | Masayuki Sasaki <masayuki.sasaki@mail.toyota-td.jp> | 2014-03-13 15:24:18 +0900 |
---|---|---|
committer | Masayuki Sasaki <masayuki.sasaki@mail.toyota-td.jp> | 2014-03-13 15:24:18 +0900 |
commit | 779159e6878575f603179d7da450004ad1956b47 (patch) | |
tree | e32321879ad71dce5e4ab32397b07eb260a27c56 | |
parent | f5ff0b8cc9b086493eb59b14ec1609b9c0015f74 (diff) | |
download | ico-uxf-weston-plugin-779159e6878575f603179d7da450004ad1956b47.tar.gz ico-uxf-weston-plugin-779159e6878575f603179d7da450004ad1956b47.tar.bz2 ico-uxf-weston-plugin-779159e6878575f603179d7da450004ad1956b47.zip |
Test tool The name of test_send_input is changed into ico_send_inputevent.
Change-Id: I8b6d573f1e64ec7f9164653fc3851bb8f52e0869
Signed-off-by: Masayuki Sasaki <masayuki.sasaki@mail.toyota-td.jp>
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | packaging/ico-uxf-weston-plugin.spec | 1 | ||||
-rw-r--r-- | src/ico_input_mgr.c | 7 | ||||
-rw-r--r-- | src/ico_input_mgr.h | 6 | ||||
-rw-r--r-- | src/ico_plugin_loader.c | 1 | ||||
-rw-r--r-- | src/ico_plugin_version.h | 2 | ||||
-rw-r--r-- | src/ico_window_animation.c | 65 | ||||
-rw-r--r-- | src/ico_window_mgr.c | 412 | ||||
-rw-r--r-- | src/ico_window_mgr_private.h | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 6 | ||||
-rwxr-xr-x | tests/weston-plugin-test | 4 | ||||
-rwxr-xr-x | tests/weston-plugin-test.anima | 4 | ||||
-rwxr-xr-x | tests/weston-plugin-test.input | 4 | ||||
-rwxr-xr-x | tests/weston-plugin-test.map | 4 | ||||
-rwxr-xr-x | tests/weston-plugin-test.region | 4 | ||||
-rwxr-xr-x | tests/weston-plugin-test.resize | 4 | ||||
-rwxr-xr-x | tests/weston-plugin-test.send_input | 4 | ||||
-rw-r--r-- | tools/Makefile.am | 15 | ||||
-rw-r--r-- | tools/ico_send_inputevent.c (renamed from tests/test-send_event.c) | 88 |
20 files changed, 445 insertions, 194 deletions
diff --git a/Makefile.am b/Makefile.am index 1c17aa6..80fee79 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = src tests +SUBDIRS = src tools tests -DIST_SUBDIRS = src tests +DIST_SUBDIRS = src tools tests diff --git a/configure.ac b/configure.ac index 9583cfa..12984be 100644 --- a/configure.ac +++ b/configure.ac @@ -46,5 +46,6 @@ WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol']) AC_CONFIG_FILES([Makefile src/Makefile + tools/Makefile tests/Makefile]) AC_OUTPUT diff --git a/packaging/ico-uxf-weston-plugin.spec b/packaging/ico-uxf-weston-plugin.spec index d741e57..0890e7b 100644 --- a/packaging/ico-uxf-weston-plugin.spec +++ b/packaging/ico-uxf-weston-plugin.spec @@ -71,4 +71,5 @@ install -m 0644 settings/weston.ini %{buildroot}%{weston_conf} %{_includedir}/%{name}/ico_input_mgr-client-protocol.h %{_includedir}/%{name}/ico_window_mgr-client-protocol.h %{_includedir}/%{name}/ico_input_mgr.h +%{_bindir}/ico_send_inputevent %{_libdir}/libico-uxf-weston-plugin.so diff --git a/src/ico_input_mgr.c b/src/ico_input_mgr.c index 2fc0c8e..500851a 100644 --- a/src/ico_input_mgr.c +++ b/src/ico_input_mgr.c @@ -38,6 +38,11 @@ #include <math.h> #include <time.h> #include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <linux/input.h> +#include <linux/uinput.h> +#include <errno.h> #include <pixman.h> #include <wayland-server.h> @@ -182,6 +187,7 @@ static void ico_device_configure_code(struct wl_client *client, static void ico_device_input_event(struct wl_client *client, struct wl_resource *resource, uint32_t time, const char *device, int32_t input, int32_t code, int32_t state); + /* send region event */ static void ico_input_send_region_event(struct wl_array *array); /* definition of Wayland protocol */ @@ -1514,4 +1520,3 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) uifw_info("ico_input_mgr: Leave(module_init)"); return 0; } - diff --git a/src/ico_input_mgr.h b/src/ico_input_mgr.h index a4c332e..1b3b40d 100644 --- a/src/ico_input_mgr.h +++ b/src/ico_input_mgr.h @@ -28,6 +28,11 @@ #ifndef _ICO_INPUT_MGR_H_ #define _ICO_INPUT_MGR_H_ +/* Pseudo input device name */ +#define ICO_PSEUDO_INPUT_POINTER "ico-pseudo-input-pointer" +#define ICO_PSEUDO_INPUT_TOUCH "ico-pseudo-input-touch" +#define ICO_PSEUDO_INPUT_KEY "ico-pseudo-input-key" + /* Input Region struct for Haptic Device Controller */ struct ico_uifw_input_region { uint16_t change; /* change method */ @@ -53,4 +58,3 @@ struct ico_uifw_input_region { }; #endif /*_ICO_INPUT_MGR_H_*/ - diff --git a/src/ico_plugin_loader.c b/src/ico_plugin_loader.c index 90fffae..e826ee9 100644 --- a/src/ico_plugin_loader.c +++ b/src/ico_plugin_loader.c @@ -206,4 +206,3 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) return 0; } - diff --git a/src/ico_plugin_version.h b/src/ico_plugin_version.h index 72246d1..63de2ff 100644 --- a/src/ico_plugin_version.h +++ b/src/ico_plugin_version.h @@ -1 +1 @@ -#define ICO_PLUIGN_VERSION "0.9.21 (Mar-06-2014)" +#define ICO_PLUIGN_VERSION "0.9.21 (Mar-11-2014)" diff --git a/src/ico_window_animation.c b/src/ico_window_animation.c index 52514f6..ae7e3b3 100644 --- a/src/ico_window_animation.c +++ b/src/ico_window_animation.c @@ -126,6 +126,8 @@ static void animation_fade(struct weston_animation *animation, struct weston_output *output, uint32_t msecs); /* fade animation end */ static void animation_fade_end(struct weston_animation *animation); + /* slide animation end */ +static void animation_slide_end(struct weston_animation *animation); /* zoom animation */ static void animation_zoom(struct weston_animation *animation, struct weston_output *output, uint32_t msecs); @@ -521,12 +523,10 @@ animation_slide(struct weston_animation *animation, struct weston_output *output, uint32_t msecs) { struct uifw_win_surface *usurf; - struct weston_surface *es; - struct weston_view *ev; + struct animation_data *animadata; + struct weston_layout_SurfaceProperties prop; int dwidth, dheight; - int par; - int x; - int y; + int par, x, y; usurf = container_of(animation, struct uifw_win_surface, animation.animation); @@ -538,14 +538,16 @@ animation_slide(struct weston_animation *animation, } return; } - ev = ico_ivi_get_primary_view(usurf); + if (animation->frame_counter == 1) { + animadata = (struct animation_data *)usurf->animation.animadata; + animadata->end_function = animation_slide_end; + } par = usurf->animation.current; uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d", usurf->surfaceid, animation->frame_counter, par, usurf->animation.anima, usurf->animation.state); - es = usurf->surface; x = usurf->x; y = usurf->y; @@ -599,24 +601,42 @@ animation_slide(struct weston_animation *animation, } break; } - - uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d)", - usurf->surfaceid, par, x, y, usurf->x, usurf->y); - ev->geometry.x = usurf->node_tbl->disp_x + x; - ev->geometry.y = usurf->node_tbl->disp_y + y; - if ((ev->output) && (es->buffer_ref.buffer) && - (es->width > 0) && (es->height > 0)) { - weston_view_geometry_dirty(ev); - weston_surface_damage(es); + if ((par < 8) || (par > 92)) { + uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d) %08x", + usurf->surfaceid, par, x, y, usurf->x, usurf->y, (int)usurf->ivisurf); + } + if (weston_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) { + if (weston_layout_surfaceSetDestinationRectangle(usurf->ivisurf, x, y, + prop.destWidth, prop.destHeight) == 0) { + weston_layout_commitChanges(); + } } if (par >= 100) { /* end of animation */ animation_end(usurf, 1); uifw_trace("animation_slide: End of animation"); } - else { - /* continue animation */ - weston_compositor_schedule_repaint(weston_ec); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief animation_slide_end: slide animation end + * + * @param[in] animation weston animation table + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +animation_slide_end(struct weston_animation *animation) +{ + struct uifw_win_surface *usurf; + + usurf = container_of(animation, struct uifw_win_surface, animation.animation); + if (usurf) { + ico_window_mgr_set_weston_surface(usurf, + usurf->animation.pos_x, usurf->animation.pos_y, + usurf->animation.pos_width, + usurf->animation.pos_height); } } @@ -890,7 +910,7 @@ animation_swing_end(struct weston_animation *animation) es = usurf->surface; ev = ico_ivi_get_primary_view(usurf); ev->alpha = usurf->animation.alpha; - uifw_debug("animation_swing_end: %08x set alpha=%f", + uifw_debug("animation_swing_end: %08x set alpha=%.2f", usurf->surfaceid, usurf->animation.alpha); if ((ev->output) && (es->buffer_ref.buffer)) { weston_surface_damage(es); @@ -979,7 +999,7 @@ animation_fade(struct weston_animation *animation, if (ev->alpha < 0.0f) ev->alpha = 0.0f; else if (ev->alpha > 1.0f) ev->alpha = 1.0f; - if ((par < 5) || (par > 95)) { + if ((par < 8) || (par > 92)) { uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d", usurf->surfaceid, animation->frame_counter, par, ev->alpha, usurf->animation.anima, usurf->animation.state); @@ -1019,7 +1039,7 @@ animation_fade_end(struct weston_animation *animation) es = usurf->surface; ev = ico_ivi_get_primary_view(usurf); ev->alpha = usurf->animation.alpha; - uifw_debug("animation_fade_end: %08x set alpha=%f", + uifw_debug("animation_fade_end: %08x set alpha=%.2f", usurf->surfaceid, usurf->animation.alpha); if ((ev->output) && (es->buffer_ref.buffer) && (es->width > 0) && (es->height > 0)) { @@ -1219,4 +1239,3 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) return 0; } - diff --git a/src/ico_window_mgr.c b/src/ico_window_mgr.c index 36d4ac2..c62c9dd 100644 --- a/src/ico_window_mgr.c +++ b/src/ico_window_mgr.c @@ -43,9 +43,11 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <errno.h> #include <limits.h> #include <pixman.h> #include <wayland-server.h> +#include <wayland-server.h> #include <dirent.h> #include <aul/aul.h> #include <bundle.h> @@ -57,9 +59,10 @@ #include <weston/weston-layout.h> /* detail debug log */ -#define UIFW_DETAIL_OUT 0 /* 1=detail debug log/0=no detail log */ +#define UIFW_DETAIL_OUT 1 /* 1=detail debug log/0=no detail log */ #include <weston/weston-layout.h> +#include <weston/ivi-shell.h> #include "ico_ivi_common_private.h" #include "ico_window_mgr_private.h" #include "ico_window_mgr-server-protocol.h" @@ -114,6 +117,8 @@ struct ico_win_mgr { /* animation for map check */ struct wl_event_source *wait_mapevent; /* map event send wait timer */ + char *pixel_readbuf; /* surface pixel image read buffer */ + int pixel_readsize; /* surface pixel image read buffer size */ struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */ struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */ @@ -147,9 +152,10 @@ static void win_mgr_register_surface(uint32_t id_surface, struct weston_surface struct weston_layout_surface *ivisurf); /* surface destroy */ static void win_mgr_destroy_surface(struct weston_surface *surface); - /* window manager surface configure */ -static void win_mgr_surface_configure(struct uifw_win_surface *usurf, - int x, int y, int width, int height); + /* read surface pixel */ +static int win_mgr_takeSurfaceScreenshot(const char *filename, + struct uifw_win_surface *usurf, + int width, int height); /* set surface animation */ static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource, uint32_t surfaceid, int32_t type, @@ -190,9 +196,6 @@ static void ico_ivi_surfaceCreateNotification(struct weston_layout_surface *ivis /* hook for remove surface of ivi-shell */ static void ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf, void *userdata); - /* hook for configure surface of ivi-shell*/ -static void ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf, - void *userdata); /* hook for property change of ivi-shell*/ static void ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, struct weston_layout_SurfaceProperties *prop, @@ -473,10 +476,6 @@ ico_ivi_get_primary_view(struct uifw_win_surface *usurf) uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view", (int)usurf, usurf->surfaceid, (int)usurf->surface); } - else { - uifw_debug("ico_ivi_get_primary_view: %08x view=%08x view->surf=%08x", - usurf->surfaceid, (int)ev, (int)ev->surface); - } return ev; } @@ -497,7 +496,7 @@ ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, int x, int y, int width, int height) { struct weston_surface *es = usurf->surface; - struct weston_view *ev; + struct weston_layout_SurfaceProperties prop; int buf_width, buf_height; if ((es == NULL) || (usurf->ivisurf == NULL)) { @@ -530,12 +529,15 @@ ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, x = ICO_IVI_MAX_COORDINATE+1; y = ICO_IVI_MAX_COORDINATE+1; } - ev = ico_ivi_get_primary_view(usurf); - if ((ev != NULL) && - (((int)ev->geometry.x != x) || ((int)ev->geometry.y != y) || - (es->width != width) || (es->height != height))) { - weston_view_damage_below(ev); - win_mgr_surface_configure(usurf, x, y, width, height); + if (weston_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) { + if ((prop.destX != x) || (prop.destY != y) || + (prop.destWidth != (uint32_t)width) || + (prop.destHeight != (uint32_t)height)) { + if (weston_layout_surfaceSetDestinationRectangle( + usurf->ivisurf, x, y, width, height) == 0) { + weston_layout_commitChanges(); + } + } } weston_surface_damage(es); } @@ -1207,49 +1209,6 @@ ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf, void *u /*--------------------------------------------------------------------------*/ /** - * @brief ico_ivi_surfaceConfigureNotification: configure ivi-surface - * - * @param[in] ivisurf ivi surface - * @param[in] userdata User Data(Unused) - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf, void *userdata) -{ - struct weston_view *view; - struct weston_surface *surface; - uint32_t id_surface; - - id_surface = weston_layout_getIdOfSurface(ivisurf); - view = weston_layout_get_weston_view(ivisurf); - if (! view) { - uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no view", - id_surface); - } - else { - surface = view->surface; - if (! surface) { - uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no surface", - id_surface); - } - else { - uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x " - "x/y=%d/%d w/h=%d/%d", - id_surface, (int)view->geometry.x, (int)view->geometry.y, - surface->width, surface->height); - weston_layout_surfaceSetSourceRectangle(ivisurf, - 0, 0, surface->width, surface->height); - weston_layout_surfaceSetDestinationRectangle(ivisurf, - (uint32_t)view->geometry.x, (uint32_t)view->geometry.y, - surface->width, surface->height); - weston_layout_commitChanges(); - } - } -} - -/*--------------------------------------------------------------------------*/ -/** * @brief ico_ivi_surfacePropertyNotification: property change ivi-surface * * @param[in] ivisurf ivi surface @@ -1268,7 +1227,7 @@ ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, int retanima; uint32_t newmask; struct uifw_win_surface *usurf; - struct weston_view *ev; + struct weston_view *ev; newmask = ((uint32_t)mask) & (~(IVI_NOTIFICATION_OPACITY|IVI_NOTIFICATION_ORIENTATION| IVI_NOTIFICATION_PIXELFORMAT)); @@ -1288,7 +1247,7 @@ ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, prop->sourceWidth, prop->sourceHeight); if ((usurf->client_width == prop->sourceWidth) && (usurf->client_height == prop->sourceHeight)) { - newmask &= (~(IVI_NOTIFICATION_SOURCE_RECT|IVI_NOTIFICATION_DIMENSION)); + newmask &= (~IVI_NOTIFICATION_SOURCE_RECT); } else { usurf->client_width = prop->sourceWidth; @@ -1296,16 +1255,70 @@ ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, } if ((usurf->x == prop->destX) && (usurf->y == prop->destY) && (usurf->width == prop->destWidth) && (usurf->height == prop->destHeight)) { - newmask &= (~(IVI_NOTIFICATION_DEST_RECT|IVI_NOTIFICATION_POSITION)); + newmask &= (~(IVI_NOTIFICATION_DEST_RECT| + IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION)); } else { usurf->x = prop->destX; usurf->y = prop->destY; usurf->width = prop->destWidth; usurf->height = prop->destHeight; + if ((usurf->width != usurf->configure_width) || + (usurf->height != usurf->configure_height)) { + /* send configure to client(App) */ + uifw_trace("ico_ivi_surfacePropertyNotification: send configure " + "%08x(%d,%d->%d,%d)", usurf->surfaceid, + usurf->configure_width, usurf->configure_height, + usurf->width, usurf->height); + usurf->configure_width = usurf->width; + usurf->configure_height = usurf->height; + + struct wl_array surfaces; + struct shell_surface; + void **shsurf; + if (! usurf->shsurf_resource) { + /* get shell surface if not get */ + ivi_shell_get_shell_surfaces(&surfaces); + wl_array_for_each(shsurf, &surfaces) { + if (shell_surface_get_surface(*shsurf) == usurf->surface) { + usurf->shsurf_resource = *((struct wl_resource **)*shsurf); + break; + } + } + wl_array_release(&surfaces); + } + if (usurf->shsurf_resource) { + uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x " + "resource=%08x", + usurf->surfaceid, (int)usurf->shsurf_resource); + wl_shell_surface_send_configure(usurf->shsurf_resource, + WL_SHELL_SURFACE_RESIZE_RIGHT| + WL_SHELL_SURFACE_RESIZE_BOTTOM, + usurf->configure_width, usurf->configure_height); + } + else { + uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x " + "shell_surface resource not found", usurf->surfaceid); + } + } } } if (newmask & IVI_NOTIFICATION_VISIBILITY) { + if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) && + (win_mgr_hook_animation != NULL)) { + /* start animation, save original position of surface */ + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + ev = weston_layout_get_weston_view(ivisurf); + if (ev) { + usurf->animation.alpha = ev->alpha; + } + else { + usurf->animation.alpha = 1.0; + } + } if ((usurf->visible == 0) && (prop->visibility)) { uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 0=>1", id_surface); @@ -1313,17 +1326,6 @@ ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && (win_mgr_hook_animation != NULL)) { /* show with animation */ - usurf->animation.pos_x = usurf->x; - usurf->animation.pos_y = usurf->y; - usurf->animation.pos_width = usurf->width; - usurf->animation.pos_height = usurf->height; - ev = weston_layout_get_weston_view(ivisurf); - if (ev) { - usurf->animation.alpha = ev->alpha; - } - else { - usurf->animation.alpha = 0.9999f; - } retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW, (void *)usurf); @@ -1334,20 +1336,10 @@ ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, else if ((usurf->visible != 0) && (! prop->visibility)) { uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 1=>0", id_surface); + usurf->visible = 0; if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && (win_mgr_hook_animation != NULL)) { /* hide with animation */ - usurf->animation.pos_x = usurf->x; - usurf->animation.pos_y = usurf->y; - usurf->animation.pos_width = usurf->width; - usurf->animation.pos_height = usurf->height; - ev = weston_layout_get_weston_view(ivisurf); - if (ev) { - usurf->animation.alpha = ev->alpha; - } - else { - usurf->animation.alpha = 0.99999999f; - } retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE, (void *)usurf); @@ -1375,7 +1367,10 @@ ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, if (newmask) { /* surface changed, send event to controller */ wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { - uifw_trace("win_mgr_send_event: Send UPDATE_SURFACE(surf=%08x)", id_surface); + uifw_trace("win_mgr_send_event: Send UPDATE_SURFACE(surf=%08x) " + "v=%d src=%d/%d dest=%d/%d(%d/%d)", id_surface, + usurf->visible, usurf->client_width, usurf->client_height, + usurf->x, usurf->y, usurf->width, usurf->height); ico_window_mgr_send_update_surface(mgr->resource, id_surface, usurf->visible, usurf->client_width, usurf->client_height, usurf->x, usurf->y, @@ -1400,6 +1395,7 @@ static void win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface, struct wl_client *client, struct weston_layout_surface *ivisurf) { + struct weston_layout_SurfaceProperties prop; struct uifw_win_surface *usurf; struct uifw_win_surface *phash; struct uifw_win_surface *bhash; @@ -1417,6 +1413,7 @@ win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface, /* set default color and shader */ weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0); + /* create UIFW surface management table */ usurf = malloc(sizeof(struct uifw_win_surface)); if (! usurf) { @@ -1430,6 +1427,17 @@ win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface, usurf->surface = surface; usurf->ivisurf = ivisurf; usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */ + + if (weston_layout_getPropertiesOfSurface(ivisurf, &prop) == 0) { + usurf->x = prop.destX; + usurf->y = prop.destY; + usurf->width = prop.destWidth; + usurf->height = prop.destHeight; + usurf->client_width = prop.sourceWidth; + usurf->client_height = prop.sourceHeight; + usurf->configure_width = usurf->client_width; + usurf->configure_height = usurf->client_height; + } wl_list_init(&usurf->client_link); wl_list_init(&usurf->animation.animation.link); wl_list_init(&usurf->surf_map); @@ -1603,8 +1611,10 @@ win_mgr_check_mapsurface(struct weston_animation *animation, /* check all mapped surfaces */ curtime = weston_compositor_get_time(); wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) { +#if 0 /* too many log */ uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x", (int)sm, sm->usurf->surfaceid); +#endif win_mgr_change_mapsurface(sm, 0, curtime); if (sm->eventque) { if (sm->interval < wait) { @@ -1658,7 +1668,9 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti uint32_t format; uint32_t dtime; +#if 0 /* too many log */ uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event); +#endif if (event == 0) { event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; } @@ -1720,6 +1732,10 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti if ((sm->initflag == 0) && (width > 0) && (height > 0)) { sm->initflag = 1; event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; +#if PERFORMANCE_EVALUATIONS > 0 + uifw_perf("SWAP_BUFFER appid=%s surface=%08x MAP", + sm->usurf->uclient->appid, sm->usurf->surfaceid); +#endif /*PERFORMANCE_EVALUATIONS*/ } else if ((width <= 0) || (height <= 0)) { event = 0; @@ -1728,11 +1744,15 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti if ((sm->width != width) || (sm->height != height) || (format != sm->format)) { event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; +#if PERFORMANCE_EVALUATIONS > 0 + uifw_perf("SWAP_BUFFER appid=%s surface=%08x RESIZE", + sm->usurf->uclient->appid, sm->usurf->surfaceid); +#endif /*PERFORMANCE_EVALUATIONS*/ } else { if (es->buffer_ref.buffer->legacy_buffer != sm->curbuf) { #if PERFORMANCE_EVALUATIONS > 0 - uifw_perf("SWAP_BUFFER appid=%s surface=%08x", + uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS", sm->usurf->uclient->appid, sm->usurf->surfaceid); #endif /*PERFORMANCE_EVALUATIONS*/ dtime = curtime - sm->lasttime; @@ -1786,7 +1806,7 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) { #if PERFORMANCE_EVALUATIONS > 0 if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) { - uifw_perf("SWAP_BUFFER appid=%s surface=%08x", + uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS", sm->usurf->uclient->appid, sm->usurf->surfaceid); } #endif /*PERFORMANCE_EVALUATIONS*/ @@ -1825,19 +1845,30 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti if (event != 0) { uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d " - "w/h/s=%d/%d/%d format=%x", + "w/h/s=%d/%d/%d format=%x file=<%s>", event, sm->usurf->surfaceid, sm->type, - sm->width, sm->height, sm->stride, sm->format); + sm->width, sm->height, sm->stride, sm->format, sm->filepath); sm->lasttime = curtime; sm->eventque = 0; if ((event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) && - (sm->filepath != NULL)) { + (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP) && + (sm->filepath[0] != 0)) { +#if 1 /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */ + if (win_mgr_takeSurfaceScreenshot(sm->filepath, sm->usurf, + sm->width, sm->height) != 0) +#else /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */ if (weston_layout_takeSurfaceScreenshot(sm->filepath, - sm->usurf->ivisurf) != 0) { + sm->usurf->ivisurf) != 0) +#endif /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */ + { uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) Error", sm->usurf->surfaceid, sm->filepath); event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; } + else { + uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) OK", + sm->usurf->surfaceid, sm->filepath); + } } ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event, sm->usurf->surfaceid, sm->type, @@ -2122,44 +2153,6 @@ uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_surface_configure: UIFW surface configure - * - * @param[in] usurf UIFW surface - * @param[in] x X coordinate on screen - * @param[in] y Y coordinate on screen - * @param[in] width surface width - * @param[in] height surface height - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_surface_configure(struct uifw_win_surface *usurf, - int x, int y, int width, int height) -{ - struct weston_surface *es; - struct weston_view *ev; - - es = usurf->surface; - if ((es != NULL) && (es->buffer_ref.buffer)) { - if (usurf->client_width == 0) { - usurf->client_width = es->width; - if (usurf->client_width == 0) - usurf->client_width = ico_ivi_surface_buffer_width(es); - } - if (usurf->client_height == 0) { - usurf->client_height = es->height; - if (usurf->client_height == 0) - usurf->client_height = ico_ivi_surface_buffer_height(es); - } - - /* not set geometry width/height */ - ev = ico_ivi_get_primary_view(usurf); - weston_view_set_position(ev, x, y); - } -} - -/*--------------------------------------------------------------------------*/ -/** * @brief win_mgr_destroy_surface: surface destroy * * @param[in] surface Weston surface @@ -2237,6 +2230,160 @@ win_mgr_destroy_surface(struct weston_surface *surface) /*--------------------------------------------------------------------------*/ /** + * @brief win_mgr_takeSurfaceScreenshot: take screen image pixel + * + * @param[in] filename output file path + * @param[in] usurf UIFW surface + * @param[in] width surface width + * @param[in] height surface height + * @return result + * @retval 0 success + * @retval -1 error + */ +/*--------------------------------------------------------------------------*/ +static int +win_mgr_takeSurfaceScreenshot(const char *filename, struct uifw_win_surface *usurf, + int width, int height) +{ + int datasize; + int bufsize; + int bitperpixel; + int bmphead_size; + int fd; + int pathlen; + int linesize; + char *sp, *dp; + char *wkbuf = NULL; +#pragma pack(push, 1) + struct _bmphead { + short magic; + uint32_t fullsize; + short res1; + short res2; + int offset; + int headsize; + int width; + int height; + short planes; + short bitperpixel; + int compress; + int datasize; + int xp; + int yp; + int colors; + int colors2; + } *bmphead; +#pragma pack(pop) + + uifw_trace("win_mgr_takeSurfaceScreenshot: Enter(%08x) <%s>", + usurf->surfaceid, filename); + + if (! _ico_win_mgr->compositor->renderer->read_surface_pixels) { + uifw_trace("win_mgr_takeSurfaceScreenshot: Leave(no read_surface_pixels)"); + return -1; + } + bitperpixel = PIXMAN_FORMAT_BPP(_ico_win_mgr->compositor->read_format); + bmphead_size = ((sizeof(struct _bmphead) + 31) / 32) * 32; + datasize = (width * bitperpixel / 8) * height; + bufsize = datasize + bmphead_size; + if ((_ico_win_mgr->pixel_readbuf != NULL) && + (bufsize > _ico_win_mgr->pixel_readsize)) { + free(_ico_win_mgr->pixel_readbuf); + _ico_win_mgr->pixel_readbuf = NULL; + } + if (_ico_win_mgr->pixel_readbuf == NULL) { + _ico_win_mgr->pixel_readbuf = malloc(bufsize); + if (! _ico_win_mgr->pixel_readbuf) { + uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)"); + return -1; + } + _ico_win_mgr->pixel_readsize = bufsize; + } + pathlen = strlen(filename); + if ((pathlen >= 4) && (strcmp(&filename[pathlen-4], ".bmp") == 0)) { + /* BMP format */ + wkbuf = malloc(datasize); + if (! wkbuf) { + uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)"); + return -1; + } + } + fd = open(filename, O_WRONLY|O_CREAT, 0644); + if (fd < 0) { + uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> open Error<%d>)", + filename, errno); + if (wkbuf) free(wkbuf); + return -1; + } + + uifw_detail("win_mgr_takeSurfaceScreenshot: call read_surface_pixels(%d,%d)", + width, height); + if ((*(_ico_win_mgr->compositor-> + renderer->read_surface_pixels))(usurf->surface, PIXMAN_a8r8g8b8, + wkbuf ? wkbuf : + (_ico_win_mgr->pixel_readbuf + bmphead_size), + 0, 0, width, height) != 0) { + close(fd); + uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(read_surface_pixels Error)"); + if (wkbuf) free(wkbuf); + return -1; + } + uifw_detail("win_mgr_takeSurfaceScreenshot: end read_surface_pixels"); + + if (wkbuf) { + /* BMP format */ + bmphead = (struct _bmphead *)(_ico_win_mgr->pixel_readbuf + + (bmphead_size - sizeof(struct _bmphead))); + memset(bmphead, 0, sizeof(struct _bmphead)); + bmphead->magic = 0x4d42; + bmphead->fullsize = sizeof(struct _bmphead) + datasize; + bmphead->offset = 54; + bmphead->headsize = 40; + bmphead->width = width; + bmphead->height = height; + bmphead->planes = 1; + bmphead->bitperpixel = bitperpixel; + bmphead->compress = 0; + bmphead->datasize = datasize; + bmphead->xp = 100000; + bmphead->yp = 100000; + + /* invert Y */ + linesize = width * bitperpixel / 8; + sp = wkbuf; + dp = _ico_win_mgr->pixel_readbuf + bmphead_size + (linesize * (height-1)); + for (pathlen = 0; pathlen < height; pathlen++) { + memcpy(dp, sp, linesize); + sp += linesize; + dp -= linesize; + } + free(wkbuf); + + if (write(fd, bmphead, sizeof(struct _bmphead) + datasize) < 0) { + uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)", + filename, errno); + close(fd); + if (wkbuf) free(wkbuf); + return -1; + } + } + else { + /* Binary format */ + if (write(fd, _ico_win_mgr->pixel_readbuf + bmphead_size, datasize) < 0) { + uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)", + filename, errno); + close(fd); + return -1; + } + } + close(fd); + + uifw_trace("win_mgr_takeSurfaceScreenshot: Leave"); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/** * @brief bind_ico_win_mgr: bind Multi Window Manager from client * * @param[in] client client @@ -2622,9 +2769,6 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) if (weston_layout_setNotificationRemoveSurface(ico_ivi_surfaceRemoveNotification, NULL) != 0) { uifw_error("ico_window_mgr: weston_layout_setNotificationRemoveSurface Error"); } - if (weston_layout_setNotificationConfigureSurface(ico_ivi_surfaceConfigureNotification, NULL) != 0) { - uifw_error("ico_window_mgr: weston_layout_setNotificationConfigureSurface Error"); - } uifw_info("ico_window_mgr: Leave(module_init)"); return 0; diff --git a/src/ico_window_mgr_private.h b/src/ico_window_mgr_private.h index 70c4d2c..99f3b65 100644 --- a/src/ico_window_mgr_private.h +++ b/src/ico_window_mgr_private.h @@ -97,12 +97,15 @@ struct uifw_win_surface { struct weston_surface *surface; /* Weston surface */ struct weston_layout_surface *ivisurf; /* Weston layout surface */ struct uifw_client *uclient; /* Client */ + struct wl_resource *shsurf_resource; /* wl_shell_surface resource */ int x; /* X-coordinate */ int y; /* Y-coordinate */ uint16_t width; /* Width */ uint16_t height; /* Height */ uint16_t client_width; /* Widht that a client(App) required */ uint16_t client_height; /* Height that a client(App) required */ + uint16_t configure_width; /* Widht that a client(App) configured */ + uint16_t configure_height; /* Height that a client(App) configured */ char winname[ICO_IVI_WINNAME_LENGTH];/* Window name */ char visible; /* visibility */ char restrain_configure; /* restrant configure event */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 1a31595..c57892e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,13 +10,12 @@ AM_CFLAGS = $(GCC_CFLAGS) $(EFL_INCLUDE) AM_CPPFLAGS = -I$(top_srcdir)/src -DUNIT_TEST $(COMPOSITOR_CFLAGS) noinst_PROGRAMS = \ - test-send_event \ test-homescreen \ test-client \ test-eflapp check_LTLIBRARIES = $(TESTS) -check_PROGRAMS = test-homescreen test-client test-eflapp test-send_event +check_PROGRAMS = test-homescreen test-client test-eflapp AM_LDFLAGS = -module -avoid-version -rpath $(libdir) -lwayland-egl -lEGL -lGLESv2 @@ -25,9 +24,6 @@ test_protocol_lib = ../src/.libs/libico-uxf-weston-plugin.so test_efl_libs = -lecore_evas -lecore -levas -lecore_wayland -lelementary test_wayland_client = -lwayland-client -test_send_event_SOURCES = test-send_event.c $(test_common_src) -test_send_event_LDADD = $(SIMPLE_CLIENT_LIBS) $(test_wayland_client) - test_homescreen_SOURCES = test-homescreen.c $(test_common_src) test-thumbnail.c test_homescreen_CFLAGS = $(GENIVI_INCLUDE) $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) test_homescreen_LDADD = $(GENIVI_LIBS) $(SIMPLE_CLIENT_LIBS) $(test_protocol_lib) $(test_wayland_client) $(PLUGIN_LIBS) diff --git a/tests/weston-plugin-test b/tests/weston-plugin-test index c053efb..2d1d0d8 100755 --- a/tests/weston-plugin-test +++ b/tests/weston-plugin-test @@ -9,7 +9,7 @@ mkdir ../tests/testlog 2> /dev/null rm -fr ../tests/testlog/* 2> /dev/null # 2 Start Pseudo event device (for Touch Panel) -../tests/test-send_event -d -mq=5551 2> ../tests/testlog/event_log.log & +../tools/ico_send_inputevent -d -mq=5551 2> ../tests/testlog/event_log.log & sleep 1 # 3 Set Environment for Test @@ -31,7 +31,7 @@ export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH # 7 End of Test sleep 2 /usr/bin/killall weston -/usr/bin/killall test-send_event +/usr/bin/killall ico_send_inputevent sleep 1 # 8 Check Error diff --git a/tests/weston-plugin-test.anima b/tests/weston-plugin-test.anima index c18b089..7c243bb 100755 --- a/tests/weston-plugin-test.anima +++ b/tests/weston-plugin-test.anima @@ -9,7 +9,7 @@ mkdir ../tests/testlog 2> /dev/null rm -fr ../tests/testlog/* 2> /dev/null # 2 Start Pseudo event device (for Touch Panel) -../tests/test-send_event -d -mq=5551 2> ../tests/testlog/event_log.log & +../tools/ico_send_inputevent -d -mq=5551 2> ../tests/testlog/event_log.log & sleep 1 # 3 Set Environment for Test @@ -31,7 +31,7 @@ export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH # 7 End of Test sleep 2 /usr/bin/killall weston -/usr/bin/killall test-send_event +/usr/bin/killall ico_send_inputevent sleep 1 # 8 Check Error diff --git a/tests/weston-plugin-test.input b/tests/weston-plugin-test.input index d3dbd89..565ac17 100755 --- a/tests/weston-plugin-test.input +++ b/tests/weston-plugin-test.input @@ -9,7 +9,7 @@ rm -fr ../tests/testlog mkdir ../tests/testlog # 2 Start Pseudo event device (for Touch Panel) -../tests/test-send_event -d -mq=5551 2> ../tests/testlog/event_log.log & +../tools/ico_send_inputevent -d -mq=5551 2> ../tests/testlog/event_log.log & sleep 1 # 3 Set Environment for Test @@ -31,7 +31,7 @@ export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH # 7 End of Test sleep 1 /usr/bin/killall weston -/usr/bin/killall test-send_event +/usr/bin/killall ico_send_inputevent sleep 1 # 8 Check Error diff --git a/tests/weston-plugin-test.map b/tests/weston-plugin-test.map index 2124ae9..4a90933 100755 --- a/tests/weston-plugin-test.map +++ b/tests/weston-plugin-test.map @@ -9,7 +9,7 @@ mkdir ../tests/testlog 2> /dev/null rm -fr ../tests/testlog/* 2> /dev/null # 2 Start Pseudo event device (for Touch Panel) -../tests/test-send_event -d -mq=5551 2> ../tests/testlog/event_log.log & +../tools/ico_send_inputevent -d -mq=5551 2> ../tests/testlog/event_log.log & sleep 1 # 3 Set Environment for Test @@ -33,7 +33,7 @@ export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH # 7 End of Test sleep 2 /usr/bin/killall weston -/usr/bin/killall test-send_event +/usr/bin/killall ico_send_inputevent sleep 1 # 8 Check Error diff --git a/tests/weston-plugin-test.region b/tests/weston-plugin-test.region index 05d9806..7565ca1 100755 --- a/tests/weston-plugin-test.region +++ b/tests/weston-plugin-test.region @@ -9,7 +9,7 @@ mkdir ../tests/testlog 2> /dev/null rm -fr ../tests/testlog/* 2> /dev/null # 2 Start Pseudo event device (for Touch Panel) -../tests/test-send_event -d -mq=5551 2> ../tests/testlog/event_log.log & +../tools/ico_send_inputevent -d -mq=5551 2> ../tests/testlog/event_log.log & sleep 1 # 3 Set Environment for Test @@ -31,7 +31,7 @@ export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH # 7 End of Test sleep 2 /usr/bin/killall weston -/usr/bin/killall test-send_event +/usr/bin/killall ico_send_inputevent sleep 1 # 9 Check Error diff --git a/tests/weston-plugin-test.resize b/tests/weston-plugin-test.resize index 2018120..1032a70 100755 --- a/tests/weston-plugin-test.resize +++ b/tests/weston-plugin-test.resize @@ -9,7 +9,7 @@ mkdir ../tests/testlog 2> /dev/null rm -fr ../tests/testlog/* 2> /dev/null # 2 Start Pseudo event device (for Touch Panel) -../tests/test-send_event -d -mq=5551 2> ../tests/testlog/event_log.log & +../tools/ico_send_inputevent -d -mq=5551 2> ../tests/testlog/event_log.log & sleep 1 # 3 Set Environment for Test @@ -31,7 +31,7 @@ export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH # 7 End of Test sleep 2 /usr/bin/killall weston -/usr/bin/killall test-send_event +/usr/bin/killall ico_send_inputevent sleep 1 # 8 Check Error diff --git a/tests/weston-plugin-test.send_input b/tests/weston-plugin-test.send_input index 1e781d9..dffb431 100755 --- a/tests/weston-plugin-test.send_input +++ b/tests/weston-plugin-test.send_input @@ -9,7 +9,7 @@ mkdir ../tests/testlog 2> /dev/null rm -fr ../tests/testlog/* 2> /dev/null # 2 Start Pseudo event device (for Touch Panel) -../tests/test-send_event -d -mq=5551 2> ../tests/testlog/event_log.log & +../tools/ico_send_inputevent -d -mq=5551 2> ../tests/testlog/event_log.log & sleep 1 # 3 Set Environment for Test @@ -31,7 +31,7 @@ export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH # 7 End of Test sleep 2 /usr/bin/killall weston -/usr/bin/killall test-send_event +/usr/bin/killall ico_send_inputevent sleep 1 # 8 Check Error diff --git a/tools/Makefile.am b/tools/Makefile.am new file mode 100644 index 0000000..3f1fbc7 --- /dev/null +++ b/tools/Makefile.am @@ -0,0 +1,15 @@ +export abs_builddir + +AM_CFLAGS = $(GCC_CFLAGS) +AM_CPPFLAGS = -I$(top_srcdir)/src -DUNIT_TEST $(COMPOSITOR_CFLAGS) + +bin_PROGRAMS = \ + ico_send_inputevent + +check_LTLIBRARIES = $(TESTS) +check_PROGRAMS = ico_send_inputevent + +AM_LDFLAGS = -module -avoid-version -rpath $(libdir) + +ico_send_inputevent_SOURCES = ico_send_inputevent.c +ico_send_inputevent_LDADD = $(SIMPLE_CLIENT_LIBS) diff --git a/tests/test-send_event.c b/tools/ico_send_inputevent.c index 6aa0b7b..bef0f53 100644 --- a/tests/test-send_event.c +++ b/tools/ico_send_inputevent.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <stdarg.h> #include <string.h> #include <errno.h> #include <pthread.h> @@ -42,7 +43,6 @@ #include <linux/input.h> #include <linux/uinput.h> #include <linux/joystick.h> -#include "test-common.h" #define DEV_TOUCH 0 #define DEV_JS 1 @@ -81,6 +81,11 @@ static int mqid = -1; static int mDebug = 0; static int mRun = 1; static int mTouch = 1; +static int mWidth = 1080; +static int mHeight = 1920; +static int mConvert = 0; + +static void print_log(const char *fmt, ...); static void term_signal(const int signo) @@ -128,9 +133,9 @@ init_device(const char *device) } memset(&uinputDevice, 0, sizeof(uinputDevice)); - strcpy(uinputDevice.name, device); - uinputDevice.absmax[ABS_X] = 1920; - uinputDevice.absmax[ABS_Y] = 1080; + strncpy(uinputDevice.name, device, UINPUT_MAX_NAME_SIZE-1); + uinputDevice.absmax[ABS_X] = mHeight; + uinputDevice.absmax[ABS_Y] = mWidth; /* uinput device configuration */ if (write(uifd, &uinputDevice, sizeof(uinputDevice)) < (int)sizeof(uinputDevice)) { @@ -201,6 +206,7 @@ init_device(const char *device) close(fd); print_log("%d.event device(%s) is %s", ii+1, devFile, devName); } + usleep(200*1000); } static int @@ -307,10 +313,12 @@ send_event(const char *cmd) gettimeofday(&event.time, NULL); if (event_key[key].type == SPECIALTYPE_XY) { event.type = EV_ABS; - event.code = ABS_X; + if (mConvert) event.code = ABS_Y; + else event.code = ABS_X; event.value = convert_value(value, &errp, 0); if (mDebug) { - print_log("Send Event ABS_X=%d\t# %d.%03d", event.value, + print_log("Send Event ABS_%c=%d\t# %d.%03d", mConvert ? 'Y' : 'X', + event.value, (int)event.time.tv_sec, (int)(event.time.tv_usec/1000)); fflush(stderr); } @@ -319,20 +327,25 @@ send_event(const char *cmd) fflush(stderr); return; } - event.code = ABS_Y; + if (mConvert) event.code = ABS_X; + else event.code = ABS_Y; if (*errp == ',') { event.value = convert_value(errp + 1, (char **)0, 0); } else { event.value = 0; } + if (mConvert) { + event.value = mHeight - event.value - 1; + } event.time.tv_usec += 200; if (event.time.tv_usec >= 1000000) { event.time.tv_sec ++; event.time.tv_usec -= 1000000; } if (mDebug) { - print_log("Send Event ABS_Y=%d\t# %d.%03d", event.value, + print_log("Send Event ABS_%c=%d\t# %d.%03d", mConvert ? 'X' : 'Y', + event.value, (int)event.time.tv_sec, (int)(event.time.tv_usec/1000)); fflush(stderr); } @@ -345,7 +358,12 @@ send_event(const char *cmd) } else { event.code = event_key[key].code; - event.value = convert_value(value, (char **)0, 0); + if (value[0] == 0) { + event.value = event_key[key].value; + } + else { + event.value = convert_value(value, (char **)0, 0); + } } if (mDebug) { if ((event.type == EV_ABS) && (event.code == ABS_X)) { @@ -357,6 +375,16 @@ send_event(const char *cmd) (int)event.time.tv_sec, (int)(event.time.tv_usec/1000)); } else if ((event.type == EV_KEY) && + (event.code == BTN_TOUCH) && (event.value == 1)) { + print_log("Send Event BTN_TOUCH=Down\t# %d.%03d", + (int)event.time.tv_sec, (int)(event.time.tv_usec/1000)); + } + else if ((event.type == EV_KEY) && + (event.code == BTN_TOUCH) && (event.value == 0)) { + print_log("Send Event BTN_TOUCH=Up\t# %d.%03d", + (int)event.time.tv_sec, (int)(event.time.tv_usec/1000)); + } + else if ((event.type == EV_KEY) && (event.code == BTN_LEFT) && (event.value == 1)) { print_log("Send Event BTN_LEFT=Down\t# %d.%03d", (int)event.time.tv_sec, (int)(event.time.tv_usec/1000)); @@ -413,11 +441,35 @@ send_event(const char *cmd) } } +void +print_log(const char *fmt, ...) +{ + va_list ap; + char log[128]; + struct timeval NowTime; + extern long timezone; + static int sTimeZone = (99*60*60); + + va_start(ap, fmt); + vsnprintf(log, sizeof(log)-2, fmt, ap); + va_end(ap); + + gettimeofday( &NowTime, (struct timezone *)0 ); + if( sTimeZone > (24*60*60) ) { + tzset(); + sTimeZone = timezone; + } + NowTime.tv_sec -= sTimeZone; + fprintf(stderr, "[%02d:%02d:%02d.%03d@%d] %s\n", (int)((NowTime.tv_sec/3600) % 24), + (int)((NowTime.tv_sec/60) % 60), (int)(NowTime.tv_sec % 60), + (int)NowTime.tv_usec/1000, getpid(), log); +} + static void usage(const char *prog) { - fprintf(stderr, "Usage: %s [-device=device] [{-m/-t/-j}] [-mq[=key]] " - "[-d] [event=value] [event=value] ...\n", prog); + fprintf(stderr, "Usage: %s [-device=device] [-w=w] [-h=h] [-c] [{-m/-t/-j/-J}] " + "[-mq[=key]] [-d] [event[=value]] [event[=value]] ...\n", prog); exit(0); } @@ -433,12 +485,23 @@ main(int argc, char *argv[]) char buf[240]; j = 0; + mWidth = 1080; + mHeight = 1920; strcpy(buf, "ico_test_device"); for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { if (strncasecmp(argv[i], "-device=", 8) == 0) { strcpy(buf, &argv[i][8]); } + else if (strncasecmp(argv[i], "-w=", 3) == 0) { + mWidth = strtol(&argv[i][3], (char **)0, 0); + } + else if (strncasecmp(argv[i], "-h=", 3) == 0) { + mHeight = strtol(&argv[i][3], (char **)0, 0); + } + else if (strcasecmp(argv[i], "-c") == 0) { + mConvert = 1; /* Convert logical to physical */ + } else if (strcasecmp(argv[i], "-m") == 0) { mTouch = 1; /* Simulate mouse */ } @@ -485,7 +548,7 @@ main(int argc, char *argv[]) memset(&mqbuf, 0, sizeof(mqbuf)); if (msgrcv(mqid, &mqbuf, sizeof(mqbuf)-sizeof(long), 0, 0) < 0) { if (errno == EINTR) continue; - print_log("test-send_event: mq(%d) receive error[%d]", + print_log("ico_send_inputevent: mq(%d) receive error[%d]", mqkey, errno); fflush(stderr); break; @@ -525,6 +588,7 @@ main(int argc, char *argv[]) send_event(argv[i]); } } + usleep(300*1000); exit(0); } |