diff options
-rw-r--r-- | src/client/input.cc | 31 | ||||
-rw-r--r-- | src/client/input.h | 2 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/client/input.cc b/src/client/input.cc index 3d5b30c..cb54e32 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -20,6 +20,8 @@ namespace client { +core::Cvar *cl_mousecontrol = 0; + namespace input { @@ -27,8 +29,8 @@ namespace input Keyboard *keyboard = 0; -bool free_control = true; -bool free_control_override = false; +//bool free_control = true; +bool cl_mousecontrol_override = false; // local controls float local_direction = 0.0f; @@ -62,8 +64,13 @@ void func_screenshot(std::string const & args) void func_ui_control(std::string const &args) { - free_control = !free_control; - if (!free_control) { + if (cl_mousecontrol->value() > 0) { + (*cl_mousecontrol) = 0.0f; + } else { + (*cl_mousecontrol) = 1.0f; + } + + if (!cl_mousecontrol->value()) { local_direction = 0.0f; local_pitch = 0.0f; local_roll = 0.0f; @@ -153,6 +160,9 @@ void init() SDL_WM_GrabInput(SDL_GRAB_ON); // SDL_EnableUNICODE(1); + cl_mousecontrol = core::Cvar::get("cl_mousecontrol", "1", core::Cvar::Archive); + cl_mousecontrol->set_info("[bool] set mouse control on or off"); + core::Func *func = 0; func = core::Func::add("ui_console", func_ui_console); @@ -165,7 +175,7 @@ void init() func->set_info("switch view mode"); func = core::Func::add("ui_control",func_ui_control); - func->set_info("toggle control on or off"); + func->set_info("toggle mouse control on or off"); func = core::Func::add("list_keys", func_list_keys); func->set_info("list keyboard key names"); @@ -223,7 +233,7 @@ void action_press(std::string const &action) /* -- mouse control ------------------------------- */ } else if (action.compare("+control") == 0) { - free_control_override = true; + cl_mousecontrol_override = true; /* -- directional control ------------------------- */ } else if (action.compare("+left") == 0) { @@ -271,8 +281,8 @@ void action_release(std::string const &action) /* -- mouse control ------------------------------- */ } else if (action.compare("+control") == 0) { - free_control_override = false; - if (!free_control) { + cl_mousecontrol_override = false; + if (!cl_mousecontrol->value()) { local_direction = 0.0f; local_pitch = 0.0f; local_roll = 0.0f; @@ -328,8 +338,7 @@ void frame(float seconds) mouse_x = video::width / 2; mouse_y = video::height / 2; render::Camera::reset(); - free_control = true; - free_control_override = false; + cl_mousecontrol_override = false; } SDL_Event event; @@ -442,7 +451,7 @@ void frame(float seconds) if (core::application()->connected() && core::localcontrol()) { - mouse_control = !console()->visible() && (free_control || free_control_override); + mouse_control = !console()->visible() && ((cl_mousecontrol->value() > 0) || cl_mousecontrol_override); if (mouse_control) { // the mouse will not react if it is in the deadzone diff --git a/src/client/input.h b/src/client/input.h index 87f7dfe..201f4e9 100644 --- a/src/client/input.h +++ b/src/client/input.h @@ -32,6 +32,8 @@ extern bool mouse_control; } // namespace input +extern core::Cvar *cl_mousecontrol; + } // namespace client #endif // __INCLUDED_cLIENT_INPUT_H__ |