diff --git a/configure.in b/configure.in index 34a3851..376c334 100644 --- a/configure.in +++ b/configure.in @@ -6,6 +6,8 @@ rm -f config.cache AC_INIT(expedite, 0.6.0, enlightenment-devel@lists.sourceforge.net) AC_PREREQ(2.52) AC_CONFIG_SRCDIR(configure.in) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST AM_INIT_AUTOMAKE(1.6 dist-bzip2) AM_CONFIG_HEADER(config.h) @@ -16,6 +18,18 @@ AC_PROG_CC AM_PROG_CC_STDC AC_HEADER_STDC AC_C_CONST +AM_PROG_CC_C_O + +WIN32_CFLAGS="" +lt_enable_auto_import="" +case "$host_os" in + cegcc) + WIN32_CFLAGS="-mwin32" + lt_enable_auto_import="-Wl,--enable-auto-import" + ;; +esac +AC_SUBST(WIN32_CFLAGS) +AC_SUBST(lt_enable_auto_import) PKG_CHECK_MODULES([EVAS], evas) @@ -60,6 +74,10 @@ EXPEDITE_CHECK_ENGINE([software-16-ddraw], [Software 16 bits DirectDraw], "yes", ### Direct3D EXPEDITE_CHECK_ENGINE([direct3d], [Direct3D], "yes", [d3d_libs="-ld3d9 -ld3dx9d"]) +# TODO: Check availability of libs +### 16bit WinCE +EXPEDITE_CHECK_ENGINE([software-16-wince], [Software 16 bits WinCE], "yes", [wince_16_libs="-laygshell"]) + ### Software SDL EXPEDITE_CHECK_ENGINE([software-sdl], [Software SDL], "yes") @@ -97,6 +115,7 @@ AC_SUBST(x_libs) AC_SUBST(ddraw_libs) AC_SUBST(ddraw_16_libs) AC_SUBST(d3d_libs) +AC_SUBST(wince_16_libs) AC_SUBST(glew_libs) AC_OUTPUT([ @@ -118,6 +137,7 @@ echo " Open GL Glew.................: ${have_opengl_glew}" echo " Software DirectDraw..........: ${have_software_ddraw}" echo " Software DirectDraw 16 bits..: ${have_software_16_ddraw}" echo " Direct3D.....................: ${have_direct3d}" +echo " Software WinCE 16 bits.......: ${have_software_16_wince}" echo " Software SDL.................: ${have_software_sdl}" echo " FB...........................: ${have_fb}" echo " DirectFB.....................: ${have_directfb}" diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 69cb54c..986906a 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -57,7 +57,9 @@ image_blend_occlude2_very_many.c \ image_blend_occlude3_very_many.c \ poly_blend.c -expedite_LDADD = @EVAS_LIBS@ @SDL_LIBS@ @x_libs@ @ddraw_libs@ @ddraw_16_libs@ @d3d_libs@ @glew_libs@ @DIRECTFB_LIBS@ -lm +expedite_CFLAGS = @WIN32_CFLAGS@ +expedite_LDADD = @EVAS_LIBS@ @SDL_LIBS@ @x_libs@ @ddraw_libs@ @ddraw_16_libs@ @d3d_libs@ @wince_16_libs@ @glew_libs@ @DIRECTFB_LIBS@ -lm +expedite_LDFLAGS = @lt_enable_auto_import@ if BUILD_SOFTWARE_X11 expedite_SOURCES += \ @@ -99,6 +101,11 @@ expedite_SOURCES += \ engine_direct3d.cpp engine_direct3d.h endif +if BUILD_SOFTWARE_16_WINCE +expedite_SOURCES += \ +engine_software_16_wince.c engine_software_16_wince.h +endif + if BUILD_SOFTWARE_SDL expedite_SOURCES += \ engine_software_sdl.c engine_software_sdl.h diff --git a/src/bin/engine_software_16_wince.c b/src/bin/engine_software_16_wince.c new file mode 100644 index 0000000..07f2c07 --- /dev/null +++ b/src/bin/engine_software_16_wince.c @@ -0,0 +1,254 @@ +#include "main.h" + +#include +#include +#include + + +typedef struct +{ + short vkUp; // key for up + POINT ptUp; // x,y position of key/button. Not on screen but in screen coordinates. + short vkDown; + POINT ptDown; + short vkLeft; + POINT ptLeft; + short vkRight; + POINT ptRight; + short vkA; + POINT ptA; + short vkB; + POINT ptB; + short vkC; + POINT ptC; + short vkStart; + POINT ptStart; +} _GAPI_Key_List; + + +static HWND window; +static int backend = 0; +static _GAPI_Key_List *key_list = NULL; + +typedef int (*suspend) (int backend); +typedef int (*resume) (int backend); + +static suspend _suspend = NULL; +static resume _resume = NULL; + +void +_wince_fb_key_down(WPARAM wParam) +{ + int key; + + key = LOWORD(wParam); + + if ((key == VK_SHIFT) || + (key == VK_LSHIFT) || + (key == VK_RSHIFT)) + evas_key_modifier_on(evas, "Shift"); + + if (key == VK_CAPITAL) + { + if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock")) + evas_key_lock_off(evas, "Caps_Lock"); + else + evas_key_lock_on(evas, "Caps_Lock"); + } + if (key == VK_RETURN) + evas_event_feed_key_down(evas, "Return", "Return", NULL, NULL, 0, NULL); + if (key == VK_LEFT) + evas_event_feed_key_down(evas, "Left", "Left", NULL, NULL, 0, NULL); + if (key == VK_RIGHT) + evas_event_feed_key_down(evas, "Right", "Right", NULL, NULL, 0, NULL); + if (key == 81) + evas_event_feed_key_down(evas, "Q", "Q", NULL, NULL, 0, NULL); + if (key == 113) + evas_event_feed_key_down(evas, "q", "q", NULL, NULL, 0, NULL); +} + +void +_wince_fb_key_up(WPARAM wParam) +{ + int key; + + key = LOWORD(wParam); + + if ((key == VK_SHIFT) || + (key == VK_LSHIFT) || + (key == VK_RSHIFT)) + evas_key_modifier_off(evas, "Shift"); + if (key == VK_RETURN) + evas_event_feed_key_up(evas, "Return", "Return", NULL, NULL, 0, NULL); + if (key == VK_LEFT) + evas_event_feed_key_up(evas, "Left", "Left", NULL, NULL, 0, NULL); + if (key == VK_RIGHT) + evas_event_feed_key_up(evas, "Right", "Right", NULL, NULL, 0, NULL); + if (key == 81) + evas_event_feed_key_up(evas, "Q", "Q", NULL, NULL, 0, NULL); + if (key == 113) + evas_event_feed_key_up(evas, "q", "q", NULL, NULL, 0, NULL); +} + +void +_wince_gapi_key(WPARAM wParam) +{ + if (wParam == (unsigned int)key_list->vkLeft) + evas_event_feed_key_down(evas, "Left", "Left", NULL, NULL, 0, NULL); + if (wParam == (unsigned int)key_list->vkRight) + evas_event_feed_key_down(evas, "Right", "Right", NULL, NULL, 0, NULL); + if (wParam == (unsigned int)key_list->vkA) + evas_event_feed_key_down(evas, "Return", "Return", NULL, NULL, 0, NULL); + if (wParam == (unsigned int)key_list->vkB) + evas_event_feed_key_down(evas, "Q", "Q", NULL, NULL, 0, NULL); + if (wParam == (unsigned int)key_list->vkC) + evas_event_feed_key_down(evas, "q", "q", NULL, NULL, 0, NULL); +} + +static LRESULT CALLBACK +MainWndProc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) +{ + switch (uMsg) + { + case WM_DESTROY: + PostQuitMessage(0); + return 0; + case WM_CLOSE: + PostQuitMessage(0); + return 0; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: { + if (backend == 1) + _wince_fb_key_down(wParam); + if (backend == 2) + _wince_gapi_key(wParam); + + return 0; + } + case WM_KEYUP: + case WM_SYSKEYUP: { + if (backend == 1) + _wince_fb_key_up(wParam); + if (backend == 2) + _wince_gapi_key(wParam); + + return 0; + } + case WM_KILLFOCUS: + if (_suspend) + _suspend (backend); + return 0; + case WM_SETFOCUS: + if (_resume) + _resume (backend); + return 0; + default: + return DefWindowProc(hwnd, uMsg, wParam, lParam); + } +} + +int +engine_software_16_wince_args(int argc, char **argv) +{ + WNDCLASS wc; + RECT rect; + HINSTANCE hinstance; + Evas_Engine_Info_Software_16_WinCE *einfo; + int width; + int height; + int stride_x; + int stride_y; + int bpp; + int format; + void *buffer; + int ok = 0; + int i; + + for (i = 1; i < argc; i++) + { + if ((!strcmp(argv[i], "-e")) && (i < (argc - 1))) + { + i++; + if (!strcmp(argv[i], "wince")) ok = 1; + if (!strcmp(argv[i], "wince-fb")) { ok = 1; backend = 1; } + if (!strcmp(argv[i], "wince-gapi")) { ok = 1; backend = 2; } + } + } + if (!ok) return 0; + + hinstance = GetModuleHandle(NULL); + + memset (&wc, 0, sizeof (wc)); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = MainWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hinstance; + wc.hIcon = NULL; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); + wc.lpszMenuName = NULL; + wc.lpszClassName = L"Evas_Software_16_WinCE_Test"; + + if(!RegisterClass(&wc)) return EXIT_FAILURE; + + SetRect(&rect, 0, 0, + GetSystemMetrics(SM_CXSCREEN), + GetSystemMetrics(SM_CYSCREEN)); + + window = CreateWindowEx(WS_EX_TOPMOST, + L"Evas_Software_16_WinCE_Test", + L"Evas_Software_16_WinCE_Test", + WS_VISIBLE | WS_POPUP, + rect.left, rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + NULL, NULL, hinstance, NULL); + if (!window) return EXIT_FAILURE; + + SHFullScreen(window, + SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON); + + evas_output_method_set(evas, evas_render_method_lookup("software_16_wince")); + einfo = (Evas_Engine_Info_Software_16_WinCE *)evas_engine_info_get(evas); + if (!einfo) + { + printf("Evas does not support the 16bit Software WinCE Engine\n"); + return 0; + } + + einfo->info.window = window; + einfo->info.backend = backend; + einfo->info.rotation = 0; + evas_engine_info_set(evas, (Evas_Engine_Info *)einfo); + + _suspend = einfo->func.suspend; + _resume = einfo->func.resume; + key_list = einfo->func.default_keys(backend); + + /* the second parameter is ignored, as it's the first call of ShowWindow */ + ShowWindow(window, SW_SHOWDEFAULT); + UpdateWindow(window); + + return 1; +} + +void +engine_software_16_wince_loop(void) +{ + MSG msg; + int res; + + again: + if (!PeekMessage (&msg, window, 0, 0, PM_NOREMOVE)) + return; + + res = GetMessage (&msg, NULL, 0, 0); + TranslateMessage (&msg); + DispatchMessage (&msg); + + goto again; +} diff --git a/src/bin/engine_software_16_wince.h b/src/bin/engine_software_16_wince.h new file mode 100644 index 0000000..f78e0a2 --- /dev/null +++ b/src/bin/engine_software_16_wince.h @@ -0,0 +1,9 @@ +#ifndef __ENGINE_SOFTWARE_16_WINCE_H__ +#define __ENGINE_SOFTWARE_16_WINCE_H__ + + +int engine_software_16_wince_args(int argc, char **argv); +void engine_software_16_wince_loop(void); + + +#endif /* __ENGINE_SOFTWARE_16_WINCE_H__ */ diff --git a/src/bin/main.c b/src/bin/main.c index 5b66d31..7421b59 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -3,6 +3,7 @@ Evas *evas = NULL; int win_w = 720, win_h = 420; +static char *datadir = NULL; static int go = 1; static void (*loop_func) (void) = NULL; @@ -1087,11 +1088,13 @@ build_path(const char *filename) { char *prefix; - prefix = getenv("EXPEDITE_DATA_DIR"); + prefix = datadir; if (!prefix) - strcpy(path, PACKAGE_DATA_DIR"/data/"); - else - snprintf(path, 4096, "%s/", prefix); + prefix = getenv("EXPEDITE_DATA_DIR"); + if (!prefix) + prefix = PACKAGE_DATA_DIR"/data/"; + + snprintf(path, 4096, "%s/", prefix); init = 1; } @@ -1154,6 +1157,20 @@ _profile_parse(int argc, char **argv) return 1; } +static char * +_datadir_parse(int argc, char **argv) +{ + int i; + + for (i = 1; i < argc; i++) + { + if ((!strcmp(argv[i], "-datadir")) && (i < (argc - 1))) + return argv[i + 1]; + } + + return NULL; +} + static void _engine_args(int argc, char **argv) { @@ -1199,6 +1216,10 @@ _engine_args(int argc, char **argv) if (engine_direct3d_args(argc, argv)) loop_func = engine_direct3d_loop; #endif +#if HAVE_EVAS_SOFTWARE_16_WINCE + if (engine_software_16_wince_args(argc, argv)) + loop_func = engine_software_16_wince_loop; +#endif #if HAVE_EVAS_FB if (engine_fb_args(argc, argv)) loop_func = engine_fb_loop; @@ -1213,6 +1234,7 @@ _engine_args(int argc, char **argv) "No engine selected.\n" "\n" "Options:\n" + " -datadir path/to/data\n" " -a (autorun all tests)\n" " -e ENGINE\n" " -p PROFILE\n" @@ -1243,6 +1265,11 @@ _engine_args(int argc, char **argv) #if HAVE_EVAS_DIRECT3D " direct3d" #endif +#if HAVE_EVAS_SOFTWARE_16_WINCE + " wince" + " wince-fb" + " wince-gapi" +#endif #if HAVE_EVAS_SOFTWARE_SDL " sdl" #endif @@ -1260,11 +1287,15 @@ _engine_args(int argc, char **argv) exit(-1); } - prefix = getenv("EXPEDITE_FONTS_DIR"); + datadir = _datadir_parse(argc, argv); + + prefix = datadir; if (!prefix) - strcpy(buf, PACKAGE_DATA_DIR"/data"); - else - snprintf(buf, 4096, "%s", prefix); + prefix = getenv("EXPEDITE_FONTS_DIR"); + if (!prefix) + prefix = PACKAGE_DATA_DIR"/data"; + + snprintf(buf, 4096, "%s", prefix); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); diff --git a/src/bin/main.h b/src/bin/main.h index 5554333..e96aa42 100644 --- a/src/bin/main.h +++ b/src/bin/main.h @@ -38,6 +38,9 @@ #if HAVE_EVAS_DIRECT3D #include "engine_direct3d.h" #endif +#if HAVE_EVAS_SOFTWARE_16_WINCE +#include "engine_software_16_wince.h" +#endif #if HAVE_EVAS_SOFTWARE_SDL #include "engine_software_sdl.h" #endif