summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-01-21 14:32:40 +0000
committertruelight <truelight@openttd.org>2007-01-21 14:32:40 +0000
commit6a145e06c3bb4d0a9b2991dc09f41ed097684c85 (patch)
tree0c0dd92d945ce238ed04b15a93044472b412cabc
parent79dfc6226186bfe5535c1672d9ef733eaf555d63 (diff)
downloadopenttd-6a145e06c3bb4d0a9b2991dc09f41ed097684c85.tar.xz
(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
-rw-r--r--src/video/win32_v.cpp26
-rw-r--r--src/win32.cpp25
2 files changed, 49 insertions, 2 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 28e5f5e62..838437fbc 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -351,15 +351,22 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
// 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 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
return 0;
+#if !defined(WINCE)
case WM_SIZING: {
RECT* r = (RECT*)lParam;
RECT r2;
@@ -472,6 +480,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
r->right = r->left + w;
break;
}
+#endif
return TRUE;
}
@@ -538,6 +547,9 @@ static void MakeWindow(bool full_screen)
_wnd.main_wnd = 0;
}
+#if defined(WINCE)
+ /* WinCE is always fullscreen */
+#else
if (full_screen) {
DEVMODE settings;
@@ -561,6 +573,7 @@ static void MakeWindow(bool full_screen)
// restore display?
ChangeDisplaySettings(NULL, 0);
}
+#endif
{
RECT r;
@@ -579,7 +592,9 @@ static void MakeWindow(bool full_screen)
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 const uint16 default_resolutions[][2] = {
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 @@ static void FindResolutions(void)
}
}
}
+#endif
/* We have found no resolutions, show the default list */
if (n == 0) {
@@ -735,7 +755,9 @@ static void Win32GdiStop(void)
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 @@ static void Win32GdiMainLoop(void)
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();
diff --git a/src/win32.cpp b/src/win32.cpp
index 018d5c8c2..da129e0d9 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -60,7 +60,7 @@ bool LoadLibraryList(Function proc[], const char *dll)
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 @@ void ShowInfo(const char *str)
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 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
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;