--- np2/wince/np2.cpp 2004/02/18 06:52:34 1.13 +++ np2/wince/np2.cpp 2004/08/16 07:47:18 1.20 @@ -33,9 +33,7 @@ #include "vramhdl.h" #include "menubase.h" #include "sysmenu.h" -#if defined(SUPPORT_SOFTKBD) #include "softkbd.h" -#endif static const TCHAR szAppCaption[] = STRLITERAL("Neko Project II"); @@ -53,7 +51,7 @@ static const TCHAR szClassName[] = STRLI HWND hWndMain; HINSTANCE hInst; HINSTANCE hPrev; - char modulefile[MAX_PATH]; + OEMCHAR modulefile[MAX_PATH]; GXKeyList gx_keylist; enum { @@ -177,7 +175,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT winkbd_keyup(wParam, lParam); break; -#if !defined(_WIN32_WCE) +#if 1 // !defined(_WIN32_WCE) case WM_SYSKEYDOWN: winkbd_keydown(wParam, lParam); break; @@ -200,7 +198,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT if (menuvram) { menubase_moving(LOWORD(lParam), HIWORD(lParam), 1); } - else { + else if (scrnmng_kbdpos(&lParam) == SUCCESS) { #if defined(SUPPORT_SOFTKBD) softkbd_down(LOWORD(lParam), HIWORD(lParam)); #endif @@ -210,23 +208,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case WM_LBUTTONUP: if (scrnmng_mousepos(&lParam) == SUCCESS) { - #if defined(SUPPORT_SOFTKBD) softkbd_up(); +#endif if (menuvram) { menubase_moving(LOWORD(lParam), HIWORD(lParam), 2); } - else if ((LOWORD(lParam) < 32) && (HIWORD(lParam) >= 208)) { - sysmenu_menuopen(0, LOWORD(lParam), HIWORD(lParam)); - } -#else - if (menuvram) { - menubase_moving(LOWORD(lParam), HIWORD(lParam), 2); - } - else { + else if (scrnmng_ismenu(lParam)) { sysmenu_menuopen(0, LOWORD(lParam), HIWORD(lParam)); } -#endif } break; @@ -318,37 +308,49 @@ static void processwait(UINT cnt) { // ---- -#if !defined(UNICODE) -#define GetModuleFileName_A(a, b, c) GetModuleFileName(a, b, c) -#else -static DWORD GetModuleFileName_A(HMODULE hModule, - LPSTR lpFileName, DWORD nSize) { +#if defined(UNICODE) && defined(OSLANG_SJIS) +static DWORD _GetModuleFileName(HMODULE hModule, + OEMCHAR *lpFileName, DWORD nSize) { - TCHAR *FileNameW; - DWORD len; + UINT16 ucs2[MAX_PATH]; - if (nSize) { - FileNameW = (TCHAR *)_MALLOC(nSize * sizeof(TCHAR), "ModuleFile"); - if (FileNameW) { - len = GetModuleFileName(hModule, FileNameW, nSize); - nSize = WideCharToMultiByte(CP_ACP, 0, FileNameW, -1, + GetModuleFileName(hModule, ucs2, NELEMENTS(ucs2)); + nSize = WideCharToMultiByte(CP_ACP, 0, ucs2, -1, lpFileName, nSize, NULL, NULL); - if (nSize) { - nSize--; - } - _MFREE(FileNameW); - } - else { - nSize = 0; - } + if (nSize) { + nSize--; } return(nSize); } +#elif defined(OSLANG_UTF8) +static DWORD _GetModuleFileName(HMODULE hModule, + OEMCHAR *lpFileName, DWORD nSize) { + + UINT16 ucs2[MAX_PATH]; + + GetModuleFileName(hModule, ucs2, NELEMENTS(ucs2)); + nSize = ucscnv_ucs2toutf8(lpFileName, nSize, ucs2, (UINT)-1); + if (nSize) { + nSize--; + } + return(nSize); +} +#else +#define _GetModuleFileName(a, b, c) GetModuleFileName(a, b, c) #endif -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, - LPTSTR lpszCmdLine, int nCmdShow) { +#if defined(_WIN32_WCE) +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, + LPWSTR lpszCmdLine, int nCmdShow) +#elif defined(UNICODE) +int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPreInst, + LPSTR lpszCmdLine, int nCmdShow) +#else +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, + LPSTR lpszCmdLine, int nCmdShow) +#endif +{ HWND hWnd; WNDCLASS np2; int id; @@ -366,7 +368,7 @@ int WINAPI WinMain(HINSTANCE hInstance, return(0); } - GetModuleFileName_A(NULL, modulefile, sizeof(modulefile)); + _GetModuleFileName(NULL, modulefile, sizeof(modulefile)); dosio_init(); file_setcd(modulefile); initload(); @@ -378,7 +380,7 @@ int WINAPI WinMain(HINSTANCE hInstance, TRACEINIT(); inputmng_init(); - keystat_reset(); + keystat_initialize(); // if (!hPreInst) { np2.style = CS_HREDRAW | CS_VREDRAW; @@ -473,7 +475,7 @@ int WINAPI WinMain(HINSTANCE hInstance, if (!GetMessage(&msg, NULL, 0, 0)) { break; } -#if !defined(_WIN32_WCE) +#if 1 // !defined(_WIN32_WCE) if ((msg.hwnd != hWnd) || ((msg.message != WM_SYSKEYDOWN) && (msg.message != WM_SYSKEYUP))) {