(svn r8309) [WinCE] -Fix: WinCE doesn't know resolution changing
authortruelight
Sun, 21 Jan 2007 14:32:40 +0000
changeset 6009 cf31b0e5c696
parent 6008 1ed2f76ac388
child 6010 31378995786b
(svn r8309) [WinCE] -Fix: WinCE doesn't know resolution changing
-Fix: WinCE doesn't know GetKeyboardState
-Fix: made a replacement of GetCurrentDirectory, where CurDir is assumed to be the dir the executable is located (esoftinteractive.com)
-Fix: the GCC compiler is more happy if the WinMain is called that
-Fix: a really old typo (missing ')') ;)
-Fix: GdiFlush() isn't supported on WinCE
src/video/win32_v.cpp
src/win32.cpp
--- a/src/video/win32_v.cpp	Sun Jan 21 14:21:31 2007 +0000
+++ b/src/video/win32_v.cpp	Sun Jan 21 14:32:40 2007 +0000
@@ -351,15 +351,22 @@
 			// this is the rewritten ascii input function
 			// it disables windows deadkey handling --> more linux like :D
 			wchar_t w = 0;
+#if !defined(WINCE)
 			byte ks[256];
+#endif
 			uint scancode;
 			uint32 pressed_key;
 
+#if defined(WINCE)
+			/* On WinCE GetKeyboardState isn't supported */
+			w = wParam;
+#else
 			GetKeyboardState(ks);
 			if (ToUnicode(wParam, 0, ks, &w, 1, 0) != 1) {
 				/* On win9x ToUnicode always fails, so fall back to ToAscii */
 				if (ToAscii(wParam, 0, ks, (LPWORD)&w, 0) != 1) w = 0; // no translation was possible
 			}
+#endif
 
 			pressed_key = w | MapWindowsKey(wParam) << 16;
 
@@ -409,6 +416,7 @@
 			}
 			return 0;
 
+#if !defined(WINCE)
 		case WM_SIZING: {
 			RECT* r = (RECT*)lParam;
 			RECT r2;
@@ -472,6 +480,7 @@
 					r->right = r->left + w;
 					break;
 			}
+#endif
 			return TRUE;
 		}
 
@@ -538,6 +547,9 @@
 		_wnd.main_wnd = 0;
 	}
 
+#if defined(WINCE)
+	/* WinCE is always fullscreen */
+#else
 	if (full_screen) {
 		DEVMODE settings;
 
@@ -561,6 +573,7 @@
 		// restore display?
 		ChangeDisplaySettings(NULL, 0);
 	}
+#endif
 
 	{
 		RECT r;
@@ -579,7 +592,9 @@
 			SetRect(&r, 0, 0, _wnd.width, _wnd.height);
 		}
 
+#if !defined(WINCE)
 		AdjustWindowRect(&r, style, FALSE);
+#endif
 		w = r.right - r.left;
 		h = r.bottom - r.top;
 		x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
@@ -669,6 +684,10 @@
 static void FindResolutions(void)
 {
 	uint n = 0;
+#if defined(WINCE)
+	/* EnumDisplaySettingsW is only supported in CE 4.2+ */
+	/* XXX -- One might argue that we assume 4.2+ on every system. Then we can use this function safely */
+#else
 	uint i;
 	DEVMODEA dm;
 
@@ -695,6 +714,7 @@
 			}
 		}
 	}
+#endif
 
 	/* We have found no resolutions, show the default list */
 	if (n == 0) {
@@ -735,7 +755,9 @@
 	DeleteObject(_wnd.dib_sect);
 	DestroyWindow(_wnd.main_wnd);
 
+#if !defined(WINCE)
 	if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0);
+#endif
 	if (_double_size) {
 		_cur_resolution[0] *= 2;
 		_cur_resolution[1] *= 2;
@@ -837,13 +859,17 @@
 
 			if (_force_full_redraw) MarkWholeScreenDirty();
 
+#if !defined(WINCE)
 			GdiFlush();
+#endif
 			_screen.dst_ptr = _wnd.buffer_bits;
 			UpdateWindows();
 			CheckPaletteAnim();
 		} else {
 			Sleep(1);
+#if !defined(WINCE)
 			GdiFlush();
+#endif
 			_screen.dst_ptr = _wnd.buffer_bits;
 			DrawTextMessage();
 			DrawMouseCursor();
--- a/src/win32.cpp	Sun Jan 21 14:21:31 2007 +0000
+++ b/src/win32.cpp	Sun Jan 21 14:32:40 2007 +0000
@@ -60,7 +60,7 @@
 			while (*dll++ != '\0');
 			if (*dll == '\0') break;
 #if defined(WINCE)
-			p = GetProcAddress(lib, MB_TO_WIDE(dll);
+			p = GetProcAddress(lib, MB_TO_WIDE(dll));
 #else
 			p = GetProcAddress(lib, dll);
 #endif
@@ -866,7 +866,12 @@
 	int _set_error_mode(int);
 #endif
 
-int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+#if defined(WINCE)
+int APIENTRY WinMain
+#else
+int APIENTRY _tWinMain
+#endif
+        (HINSTANCE hInstance, HINSTANCE hPrevInstance,
 	LPTSTR lpCmdLine, int nCmdShow)
 {
 	int argc;
@@ -912,6 +917,22 @@
 	return 0;
 }
 
+#if defined(WINCE)
+void GetCurrentDirectoryW(int length, wchar_t *path)
+{
+	wchar_t *pDest = NULL;
+	/* Get the name of this module */
+	GetModuleFileName(NULL, path, length);
+
+	/* Remove the executable name, this we call CurrentDir */
+	pDest = wcsrchr(path, '\\');
+	if (pDest != NULL) {
+		int result = pDest - path + 1;
+		path[result] = '\0';
+	}
+}
+#endif
+
 void DeterminePaths(void)
 {
 	char *s, *cfg;