From 44158ccfbe943b832c0e0bf9ce547212aa6c2b8b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 16 Nov 2008 18:47:01 +0000 Subject: camera zoom --- src/client/input.cc | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/client/input.cc') diff --git a/src/client/input.cc b/src/client/input.cc index 8236b9b..a5af430 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -384,17 +384,24 @@ void action_press(Key const *key, std::string const &action) local_afterburner = -1.0f; /* -- camera control ------------------------------ */ + + } else if (action.compare("+zoomin") == 0) { + render::Camera::set_zoom(-0.1f); + + } else if (action.compare("+zoomout") == 0) { + render::Camera::set_zoom(+0.1f); + } else if (action.compare("+camleft") == 0) { - render::Camera::set_direction(1.0f); + render::Camera::set_direction( math::min(key->pressed() - core::application()->time(), 1.0f) ); } else if (action.compare("+camright") == 0) { - render::Camera::set_direction(-1.0f); + render::Camera::set_direction(-math::min(key->pressed() - core::application()->time(),1.0f)); } else if (action.compare("+camup") == 0) { - render::Camera::set_pitch(1.0f); + render::Camera::set_pitch(math::min(key->pressed() - core::application()->time(),1.0f)); } else if (action.compare("+camdown") == 0) { - render::Camera::set_pitch(-1.0f); + render::Camera::set_pitch(-math::min(key->pressed() - core::application()->time(),1.0f)); } else con_warn << "Unknown action " << action << std::endl; } @@ -471,17 +478,15 @@ void action_release(Key *key, std::string const &action) } } -Key::Modifier convert_SDL_modifier(int const sdlmodifier) -{ - if (sdlmodifier & Key::Shift) +Key::Modifier modifier() { + if ((keyboard_modifiers & Key::Shift) > 0 ) return Key::Shift; - else if (sdlmodifier & Key::Ctrl) + else if ((keyboard_modifiers & Key::Ctrl) > 0 ) return Key::Ctrl; - else if (sdlmodifier & Key::Alt) + else if ((keyboard_modifiers & Key::Alt) > 0 ) return Key::Alt; else return Key::None; - } void key_pressed(Key *key) @@ -515,25 +520,25 @@ void key_pressed(Key *key) } else if (!core::localplayer()->view() && core::application()->connected() && core::localcontrol()) { - char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0]; + char c = key->bind(modifier()).c_str()[0]; if (c == '@') { // target bind if (targets::current_id()) - core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << " " << targets::current_id() <<"\n"; + core::cmd() << key->bind(modifier()) << " " << targets::current_id() <<"\n"; } else if (c == '+') { // action bind - action_press(key, key->bind(convert_SDL_modifier(keyboard_modifiers))); + action_press(key, key->bind(modifier())); } else { // normal bind - core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << "\n"; + core::cmd() << key->bind(modifier()) << "\n"; } } else if (core::application()->connected()) { - char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0]; + char c = key->bind(modifier()).c_str()[0]; if (c && c != '+' && c != '@') { // normal bind - core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << "\n"; + core::cmd() << key->bind(modifier()) << "\n"; } } } -- cgit v1.2.3