(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
authordarkvater
Sun, 30 Jan 2005 16:54:39 +0000
changeset 1230 f08094212688
parent 1229 f698e29a6908
child 1231 5fa7581377a9
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
console.c
console.h
main_gui.c
win32.c
--- a/console.c	Sun Jan 30 16:08:19 2005 +0000
+++ b/console.c	Sun Jan 30 16:54:39 2005 +0000
@@ -32,7 +32,6 @@
 static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
 static char _iconsole_cmdline[ICON_CMDLN_SIZE];
 static byte _iconsole_cmdpos;
-static Window* _iconsole_win = NULL;
 static byte _iconsole_scroll;
 
 // ** console cursor ** //
--- a/console.h	Sun Jan 30 16:08:19 2005 +0000
+++ b/console.h	Sun Jan 30 16:54:39 2005 +0000
@@ -1,6 +1,9 @@
 #ifndef CONSOLE_H
 #define CONSOLE_H
 
+/* Pointer to console window */
+VARDEF Window *_iconsole_win;
+
 // ** console parser ** //
 
 typedef enum _iconsole_var_types {
--- a/main_gui.c	Sun Jan 30 16:08:19 2005 +0000
+++ b/main_gui.c	Sun Jan 30 16:54:39 2005 +0000
@@ -2202,7 +2202,7 @@
 	}
 }
 
-void ScrollMainViewport(int x, int y)
+static void ScrollMainViewport(int x, int y)
 {
 	if (_game_mode != GM_MENU) {
 		Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
@@ -2250,7 +2250,7 @@
 
 void HandleKeyScrolling(void)
 {
-	if (_dirkeys) {
+	if (_dirkeys && _iconsole_win == NULL) {
 		int factor = _shift_pressed ? 50 : 10;
 		ScrollMainViewport(scrollamt[_dirkeys][0] * factor, scrollamt[_dirkeys][1] * factor);
 	}
--- a/win32.c	Sun Jan 30 16:08:19 2005 +0000
+++ b/win32.c	Sun Jan 30 16:54:39 2005 +0000
@@ -714,11 +714,14 @@
 			_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0;
 
 			// determine which directional keys are down
-			_dirkeys =
-				(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
-				(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
-				(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
-				(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
+			if (_wnd.has_focus) {
+				_dirkeys =
+					(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
+					(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
+					(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
+					(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
+			} else
+				_dirkeys = 0;
 
 			GameLoop();
 			_cursor.delta.x = _cursor.delta.y = 0;