mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-06 22:37:22 +00:00
(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
This commit is contained in:
parent
79dfc62261
commit
6a145e06c3
@ -351,15 +351,22 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||||||
// this is the rewritten ascii input function
|
// this is the rewritten ascii input function
|
||||||
// it disables windows deadkey handling --> more linux like :D
|
// it disables windows deadkey handling --> more linux like :D
|
||||||
wchar_t w = 0;
|
wchar_t w = 0;
|
||||||
|
#if !defined(WINCE)
|
||||||
byte ks[256];
|
byte ks[256];
|
||||||
|
#endif
|
||||||
uint scancode;
|
uint scancode;
|
||||||
uint32 pressed_key;
|
uint32 pressed_key;
|
||||||
|
|
||||||
|
#if defined(WINCE)
|
||||||
|
/* On WinCE GetKeyboardState isn't supported */
|
||||||
|
w = wParam;
|
||||||
|
#else
|
||||||
GetKeyboardState(ks);
|
GetKeyboardState(ks);
|
||||||
if (ToUnicode(wParam, 0, ks, &w, 1, 0) != 1) {
|
if (ToUnicode(wParam, 0, ks, &w, 1, 0) != 1) {
|
||||||
/* On win9x ToUnicode always fails, so fall back to ToAscii */
|
/* 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
|
if (ToAscii(wParam, 0, ks, (LPWORD)&w, 0) != 1) w = 0; // no translation was possible
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pressed_key = w | MapWindowsKey(wParam) << 16;
|
pressed_key = w | MapWindowsKey(wParam) << 16;
|
||||||
|
|
||||||
@ -409,6 +416,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#if !defined(WINCE)
|
||||||
case WM_SIZING: {
|
case WM_SIZING: {
|
||||||
RECT* r = (RECT*)lParam;
|
RECT* r = (RECT*)lParam;
|
||||||
RECT r2;
|
RECT r2;
|
||||||
@ -472,6 +480,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||||||
r->right = r->left + w;
|
r->right = r->left + w;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,6 +547,9 @@ static void MakeWindow(bool full_screen)
|
|||||||
_wnd.main_wnd = 0;
|
_wnd.main_wnd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(WINCE)
|
||||||
|
/* WinCE is always fullscreen */
|
||||||
|
#else
|
||||||
if (full_screen) {
|
if (full_screen) {
|
||||||
DEVMODE settings;
|
DEVMODE settings;
|
||||||
|
|
||||||
@ -561,6 +573,7 @@ static void MakeWindow(bool full_screen)
|
|||||||
// restore display?
|
// restore display?
|
||||||
ChangeDisplaySettings(NULL, 0);
|
ChangeDisplaySettings(NULL, 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
@ -579,7 +592,9 @@ static void MakeWindow(bool full_screen)
|
|||||||
SetRect(&r, 0, 0, _wnd.width, _wnd.height);
|
SetRect(&r, 0, 0, _wnd.width, _wnd.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(WINCE)
|
||||||
AdjustWindowRect(&r, style, FALSE);
|
AdjustWindowRect(&r, style, FALSE);
|
||||||
|
#endif
|
||||||
w = r.right - r.left;
|
w = r.right - r.left;
|
||||||
h = r.bottom - r.top;
|
h = r.bottom - r.top;
|
||||||
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
|
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
|
||||||
@ -669,6 +684,10 @@ static const uint16 default_resolutions[][2] = {
|
|||||||
static void FindResolutions(void)
|
static void FindResolutions(void)
|
||||||
{
|
{
|
||||||
uint n = 0;
|
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;
|
uint i;
|
||||||
DEVMODEA dm;
|
DEVMODEA dm;
|
||||||
|
|
||||||
@ -695,6 +714,7 @@ static void FindResolutions(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We have found no resolutions, show the default list */
|
/* We have found no resolutions, show the default list */
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
@ -735,7 +755,9 @@ static void Win32GdiStop(void)
|
|||||||
DeleteObject(_wnd.dib_sect);
|
DeleteObject(_wnd.dib_sect);
|
||||||
DestroyWindow(_wnd.main_wnd);
|
DestroyWindow(_wnd.main_wnd);
|
||||||
|
|
||||||
|
#if !defined(WINCE)
|
||||||
if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0);
|
if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0);
|
||||||
|
#endif
|
||||||
if (_double_size) {
|
if (_double_size) {
|
||||||
_cur_resolution[0] *= 2;
|
_cur_resolution[0] *= 2;
|
||||||
_cur_resolution[1] *= 2;
|
_cur_resolution[1] *= 2;
|
||||||
@ -837,13 +859,17 @@ static void Win32GdiMainLoop(void)
|
|||||||
|
|
||||||
if (_force_full_redraw) MarkWholeScreenDirty();
|
if (_force_full_redraw) MarkWholeScreenDirty();
|
||||||
|
|
||||||
|
#if !defined(WINCE)
|
||||||
GdiFlush();
|
GdiFlush();
|
||||||
|
#endif
|
||||||
_screen.dst_ptr = _wnd.buffer_bits;
|
_screen.dst_ptr = _wnd.buffer_bits;
|
||||||
UpdateWindows();
|
UpdateWindows();
|
||||||
CheckPaletteAnim();
|
CheckPaletteAnim();
|
||||||
} else {
|
} else {
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
|
#if !defined(WINCE)
|
||||||
GdiFlush();
|
GdiFlush();
|
||||||
|
#endif
|
||||||
_screen.dst_ptr = _wnd.buffer_bits;
|
_screen.dst_ptr = _wnd.buffer_bits;
|
||||||
DrawTextMessage();
|
DrawTextMessage();
|
||||||
DrawMouseCursor();
|
DrawMouseCursor();
|
||||||
|
@ -60,7 +60,7 @@ bool LoadLibraryList(Function proc[], const char *dll)
|
|||||||
while (*dll++ != '\0');
|
while (*dll++ != '\0');
|
||||||
if (*dll == '\0') break;
|
if (*dll == '\0') break;
|
||||||
#if defined(WINCE)
|
#if defined(WINCE)
|
||||||
p = GetProcAddress(lib, MB_TO_WIDE(dll);
|
p = GetProcAddress(lib, MB_TO_WIDE(dll));
|
||||||
#else
|
#else
|
||||||
p = GetProcAddress(lib, dll);
|
p = GetProcAddress(lib, dll);
|
||||||
#endif
|
#endif
|
||||||
@ -866,7 +866,12 @@ void ShowInfo(const char *str)
|
|||||||
int _set_error_mode(int);
|
int _set_error_mode(int);
|
||||||
#endif
|
#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)
|
LPTSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
@ -912,6 +917,22 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
return 0;
|
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)
|
void DeterminePaths(void)
|
||||||
{
|
{
|
||||||
char *s, *cfg;
|
char *s, *cfg;
|
||||||
|
Loading…
Reference in New Issue
Block a user