From 7af0f889a4296ad465f829ab6609b3e6efced997 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 17 Oct 2010 22:28:18 +0000 Subject: add input_grab variable --- src/client/input.cc | 5 +++++ src/client/video.cc | 3 ++- src/ui/console.cc | 15 +++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/client/input.cc b/src/client/input.cc index d483f5d..f9acce0 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -32,6 +32,7 @@ core::Cvar *input_mousecontrol = 0; core::Cvar *input_keydelay = 0; core::Cvar *input_keyrepeat = 0; core::Cvar *input_mousedelay = 0; +core::Cvar *input_grab = 0; namespace input { @@ -274,6 +275,10 @@ void init() input_mousedelay = core::Cvar::get("input_mousedelay", 150.0f, core::Cvar::Archive); input_mousedelay->set_info("[int] mouse click time-out in milliseconds"); + + input_grab = core::Cvar::get("input_grab", 1.0f, core::Cvar::Archive); + input_grab->set_info("[bool] grab input"); + core::Func *func = 0; func = core::Func::add("ui_control", func_ui_control); diff --git a/src/client/video.cc b/src/client/video.cc index aa7ca9e..5610f36 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -187,7 +187,8 @@ bool init() ui::root()->event_resize(); // to grab or not to grab - if (ui::console()->visible()) { + core::Cvar *input_grab = core::Cvar::find("input_grab"); + if (ui::console()->visible() || (input_grab && input_grab->value())) { SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_ShowCursor(SDL_ENABLE); } else { diff --git a/src/ui/console.cc b/src/ui/console.cc index 7bd308e..67d5054 100644 --- a/src/ui/console.cc +++ b/src/ui/console.cc @@ -88,11 +88,18 @@ void Console::show() } void Console::hide() -{ +{ ui::Window::hide(); - SDL_WM_GrabInput(SDL_GRAB_ON); - SDL_ShowCursor(SDL_DISABLE); - + + core::Cvar *input_grab = core::Cvar::find("input_grab"); + if (!input_grab || input_grab->value()) { + SDL_WM_GrabInput(SDL_GRAB_ON); + SDL_ShowCursor(SDL_DISABLE); + } else { + SDL_WM_GrabInput(SDL_GRAB_OFF); + SDL_ShowCursor(SDL_ENABLE); + } + audio::play("ui/console"); } -- cgit v1.2.3