mirror of https://github.com/OpenTTD/OpenTTD
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
parent
8580e73b65
commit
1527ef3db0
|
@ -32,7 +32,6 @@ static char* _iconsole_buffer[ICON_BUFFER + 1];
|
||||||
static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
|
static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
|
||||||
static char _iconsole_cmdline[ICON_CMDLN_SIZE];
|
static char _iconsole_cmdline[ICON_CMDLN_SIZE];
|
||||||
static byte _iconsole_cmdpos;
|
static byte _iconsole_cmdpos;
|
||||||
static Window* _iconsole_win = NULL;
|
|
||||||
static byte _iconsole_scroll;
|
static byte _iconsole_scroll;
|
||||||
|
|
||||||
// ** console cursor ** //
|
// ** console cursor ** //
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef CONSOLE_H
|
#ifndef CONSOLE_H
|
||||||
#define CONSOLE_H
|
#define CONSOLE_H
|
||||||
|
|
||||||
|
/* Pointer to console window */
|
||||||
|
VARDEF Window *_iconsole_win;
|
||||||
|
|
||||||
// ** console parser ** //
|
// ** console parser ** //
|
||||||
|
|
||||||
typedef enum _iconsole_var_types {
|
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) {
|
if (_game_mode != GM_MENU) {
|
||||||
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
||||||
|
@ -2250,7 +2250,7 @@ static const int8 scrollamt[16][2] = {
|
||||||
|
|
||||||
void HandleKeyScrolling(void)
|
void HandleKeyScrolling(void)
|
||||||
{
|
{
|
||||||
if (_dirkeys) {
|
if (_dirkeys && _iconsole_win == NULL) {
|
||||||
int factor = _shift_pressed ? 50 : 10;
|
int factor = _shift_pressed ? 50 : 10;
|
||||||
ScrollMainViewport(scrollamt[_dirkeys][0] * factor, scrollamt[_dirkeys][1] * factor);
|
ScrollMainViewport(scrollamt[_dirkeys][0] * factor, scrollamt[_dirkeys][1] * factor);
|
||||||
}
|
}
|
||||||
|
|
3
win32.c
3
win32.c
|
@ -714,11 +714,14 @@ static int Win32GdiMainLoop(void)
|
||||||
_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0;
|
_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0;
|
||||||
|
|
||||||
// determine which directional keys are down
|
// determine which directional keys are down
|
||||||
|
if (_wnd.has_focus) {
|
||||||
_dirkeys =
|
_dirkeys =
|
||||||
(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
|
(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
|
||||||
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
|
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
|
||||||
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
|
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
|
||||||
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
|
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
|
||||||
|
} else
|
||||||
|
_dirkeys = 0;
|
||||||
|
|
||||||
GameLoop();
|
GameLoop();
|
||||||
_cursor.delta.x = _cursor.delta.y = 0;
|
_cursor.delta.x = _cursor.delta.y = 0;
|
||||||
|
|
Loading…
Reference in New Issue