Don't scroll the game view when the mouse is outside the window
This was SVN commit r7283.
This commit is contained in:
parent
68eafaee7f
commit
707539ad69
@ -764,7 +764,7 @@ void CGameView::Update(float DeltaTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mouse movement
|
// Mouse movement
|
||||||
if( !hotkeys[HOTKEY_CAMERA_ROTATE] && !hotkeys[HOTKEY_CAMERA_ROTATE_ABOUT_TARGET] )
|
if( g_mouse_active && !hotkeys[HOTKEY_CAMERA_ROTATE] && !hotkeys[HOTKEY_CAMERA_ROTATE_ABOUT_TARGET] )
|
||||||
{
|
{
|
||||||
if (g_mouse_x >= g_xres-2 && g_mouse_x < g_xres)
|
if (g_mouse_x >= g_xres-2 && g_mouse_x < g_xres)
|
||||||
CameraLock(rightwards * (m->ViewScrollSpeed * DeltaTime));
|
CameraLock(rightwards * (m->ViewScrollSpeed * DeltaTime));
|
||||||
|
@ -26,6 +26,7 @@ bool g_app_has_focus = true;
|
|||||||
|
|
||||||
bool g_keys[SDLK_LAST] = {0};
|
bool g_keys[SDLK_LAST] = {0};
|
||||||
int g_mouse_x = 50, g_mouse_y = 50;
|
int g_mouse_x = 50, g_mouse_y = 50;
|
||||||
|
bool g_mouse_active = true;
|
||||||
|
|
||||||
// unused, left, right, middle, wheel up, wheel down
|
// unused, left, right, middle, wheel up, wheel down
|
||||||
// (order is given by SDL_BUTTON_* constants).
|
// (order is given by SDL_BUTTON_* constants).
|
||||||
@ -45,6 +46,8 @@ InReaction GlobalsInputHandler(const SDL_Event_* ev)
|
|||||||
g_app_minimized = (ev->ev.active.gain == 0); // negated
|
g_app_minimized = (ev->ev.active.gain == 0); // negated
|
||||||
if(ev->ev.active.state & SDL_APPINPUTFOCUS)
|
if(ev->ev.active.state & SDL_APPINPUTFOCUS)
|
||||||
g_app_has_focus = (ev->ev.active.gain != 0);
|
g_app_has_focus = (ev->ev.active.gain != 0);
|
||||||
|
if(ev->ev.active.state & SDL_APPMOUSEFOCUS)
|
||||||
|
g_mouse_active = (ev->ev.active.gain != 0);
|
||||||
return IN_PASS;
|
return IN_PASS;
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
|
@ -27,6 +27,12 @@ extern bool g_app_has_focus;
|
|||||||
|
|
||||||
extern int g_mouse_x, g_mouse_y;
|
extern int g_mouse_x, g_mouse_y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the mouse is focused on the game window (mouse positions
|
||||||
|
* should usually be considered inaccurate if this is false)
|
||||||
|
*/
|
||||||
|
extern bool g_mouse_active;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_keys: Key states, indexed by SDLK* constants. If an entry is true,
|
* g_keys: Key states, indexed by SDLK* constants. If an entry is true,
|
||||||
* it represents a pressed key.
|
* it represents a pressed key.
|
||||||
|
Loading…
Reference in New Issue
Block a user