Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-06 19:35:49 +0000
committerStijn Buys <ingar@osirion.org>2008-08-06 19:35:49 +0000
commitd240084aa7e41725a0228e123080aa7fe8a241b7 (patch)
tree09dcde28b6c301c1aff3aaeae6322cc6025d0eb9 /src/client/input.cc
parent6979c74625d51897d99797b309974c2ee82a024b (diff)
target hovering, cursors and mouse and joystick interaction
Diffstat (limited to 'src/client/input.cc')
-rw-r--r--src/client/input.cc34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
index 2f6fb27..fce83dc 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -58,18 +58,27 @@ int mouse_y = 0;
float mouse_pitch = 0;
float mouse_direction = 0;
-// true if the mouse is in the deadzone
-bool mouse_deadzone = false;
+
+
// true if the mouse has control
+const float mouse_timeout = 0.200f; // 200 ms select time-out
float mouse_control_override_time = 0;
bool mouse_control_override = false;
bool mouse_control = false;
+// true if the mouse is in the deadzone
+bool mouse_deadzone = false;
+// time the mouse was last moved
+float mouse_lastmoved = 0;
+
+// true if we're using a joystick
bool joystick_control = false;
+// time the joystick last moved
+
+float joystick_lastmoved = 0;
const float thruster_offset = 0.05f;
-const float mouse_timeout = 0.200f; // 200 ms mouse timout
int mouse_position_x() {
return mouse_x;
@@ -83,6 +92,16 @@ Key *last_key_pressed() {
return last_key;
}
+float mouse_lastmoved_time()
+{
+ return mouse_lastmoved;
+}
+
+float joystick_lastmoved_time()
+{
+ return joystick_lastmoved;
+}
+
//--- engine functions --------------------------------------------
void func_screenshot(std::string const & args)
@@ -387,7 +406,9 @@ void action_release(Key *key, std::string const &action)
} else if (action.compare("+control") == 0) {
mouse_control_override = false;
mouse_control_override_time = 0;
- if (!input_mousecontrol->value()) {
+
+ if (!input_mousecontrol->value() || (joystick_control && mouse_control &&
+ (render::Camera::mode() == render::Camera::Track || render::Camera::mode() == render::Camera::Cockpit))) {
local_direction = 0.0f;
local_pitch = 0.0f;
local_roll = 0.0f;
@@ -601,7 +622,10 @@ void reset()
key->key_waspressed = 0;
}
}
+
last_key = 0;
+ mouse_lastmoved = 0;
+ joystick_lastmoved = 0;
}
void frame(float seconds)
@@ -648,6 +672,7 @@ void frame(float seconds)
case SDL_MOUSEMOTION:
mouse_x = event.motion.x;
mouse_y = event.motion.y;
+ mouse_lastmoved = client()->time();
break;
case SDL_MOUSEBUTTONDOWN:
@@ -672,6 +697,7 @@ void frame(float seconds)
case SDL_JOYAXISMOTION:
axis_event((int) event.jaxis.axis, (int) event.jaxis.value);
+ joystick_lastmoved = client()->time();
break;
case SDL_KEYDOWN: