diff options
author | Stijn Buys <ingar@osirion.org> | 2008-04-06 17:23:01 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-04-06 17:23:01 +0000 |
commit | 9297b2c1161ab412e083e7c191f64cbdc39125bc (patch) | |
tree | e192334f9ea0a64587a408ae2c027aada578817b /src/client/input.cc | |
parent | c5e90960fc333c2b1d2b3e961da439928b2ac872 (diff) |
mouse control fine-tuning
Diffstat (limited to 'src/client/input.cc')
-rw-r--r-- | src/client/input.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/client/input.cc b/src/client/input.cc index c7c751e..8d80a21 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -19,6 +19,8 @@ namespace client { +core::Cvar *cl_mousecontrol = 0; + namespace input { @@ -34,8 +36,8 @@ unsigned int last_control = 0; // mouse cursor position int mouse_x = 0; int mouse_y = 0; - -core::Cvar *cl_mousecontrol = 0; +// true if the mouse is in the deadzone +bool mouse_deadzone = false; void init() { @@ -197,26 +199,25 @@ void frame(float seconds) if (!console::visible() && core::application()->connected() && core::localcontrol()) { - if (cl_mousecontrol->value()) { + if (camera::mode == camera::Track && cl_mousecontrol->value()) { // mouse control when camera is in tracking mode - if (camera::mode == camera::Track) { - int l = mouse_x - (video::width >> 1); + int l = mouse_x - (video::width >> 1); - if (abs(l) < ( CHARWIDTH >> 1 )) // dead zone - local_turn = 0; - else { - l = (mouse_x - CHARWIDTH) - ((video::width - CHARWIDTH) >> 1); - local_turn = float (-l) / (float) ((video::width - CHARWIDTH) >> 1); - } - } else { + if (abs(l) < ( CHARWIDTH >> 1 )) { + // dead zone local_turn = 0; + mouse_deadzone = true; + } else { + l = (mouse_x - CHARWIDTH) - ((video::width - CHARWIDTH) >> 1); + local_turn = float (-l) / (float) ((video::width - CHARWIDTH) >> 1); + mouse_deadzone = false; } - } else { if (local_turn > 1.0f) local_turn = 1.0f; else if (local_turn < -1.0f) local_turn = -1.0f; + mouse_deadzone = false; } core::localcontrol()->set_thrust(local_thrust); |