mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
This commit is contained in:
parent
8580e73b65
commit
1527ef3db0
@ -32,7 +32,6 @@ static char* _iconsole_buffer[ICON_BUFFER + 1];
|
||||
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 ** //
|
||||
|
@ -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 {
|
||||
|
@ -2202,7 +2202,7 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ static const int8 scrollamt[16][2] = {
|
||||
|
||||
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);
|
||||
}
|
||||
|
13
win32.c
13
win32.c
@ -714,11 +714,14 @@ static int Win32GdiMainLoop(void)
|
||||
_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;
|
||||
|
Loading…
Reference in New Issue
Block a user