(svn r9852) [0.5] -Backport from trunk (r9728, r9834): 0.5
authorglx
Tue, 15 May 2007 22:00:41 +0000
branch0.5
changeset 5496 e50adc01d7e3
parent 5495 ccc57a497257
child 5497 b9c8c76d31b7
(svn r9852) [0.5] -Backport from trunk (r9728, r9834):
- Fix: [win32] Dead key and open/close console. (r9728)
- Add: win9x check in win32 builds
video/win32_v.c
win32.c
--- a/video/win32_v.c	Tue May 15 21:42:27 2007 +0000
+++ b/video/win32_v.c	Tue May 15 22:00:41 2007 +0000
@@ -212,6 +212,7 @@
 static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	static uint32 keycode = 0;
+	static bool console = false;
 
 	switch (msg) {
 		case WM_CREATE:
@@ -363,6 +364,10 @@
 		}
 #endif /* UNICODE */
 
+		case WM_DEADCHAR:
+			console = GB(lParam, 16, 8) == 41;
+			return 0;
+
 		case WM_CHAR: {
 			uint scancode = GB(lParam, 16, 8);
 			uint charcode = wParam;
@@ -370,6 +375,13 @@
 			/* Silently drop all non-text messages as those were handled by WM_KEYDOWN */
 			if (wParam < VK_SPACE) return 0;
 
+			/* If the console key is a dead-key, we need to press it twice to get a WM_CHAR message.
+			 * But we then get two WM_CHAR messages, so ignore the first one */
+			if (console && scancode == 41) {
+				console = false;
+				return 0;
+			}
+
 #if !defined(UNICODE)
 			{
 				wchar_t w;
--- a/win32.c	Tue May 15 21:42:27 2007 +0000
+++ b/win32.c	Tue May 15 22:00:41 2007 +0000
@@ -887,6 +887,9 @@
 	 * save it because argv[] points into this buffer and thus needs to
 	 * be available between subsequent calls to FS2OTTD() */
 	char cmdlinebuf[MAX_PATH];
+
+	/* Check if a win9x user started the win32 version */
+	if (HASBIT(GetVersion(), 31)) error("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
 #endif /* UNICODE */
 
 	cmdline = WIDE_TO_MB_BUFFER(GetCommandLine(), cmdlinebuf, lengthof(cmdlinebuf));