From da18502a892f7ab025972c51fe268ef7e5e9a18b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 6 Jan 2015 19:16:58 +0000 Subject: SDL2 support in previous commit, corrected a segfault when pressing a key with an unknown scancode, renamed camera related actions to +lookleft +lookright +lookup +lookdown, bind +freelook to left shift by default. --- src/client/action.h | 2 +- src/client/input.cc | 20 ++++++++++---------- src/client/keyboard.cc | 11 ++++++----- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/client/action.h b/src/client/action.h index 0a7e247..abd7059 100644 --- a/src/client/action.h +++ b/src/client/action.h @@ -34,7 +34,7 @@ public: ThrustUp, ThrustDown, Afterburner, Reverse, Control, - CamLeft, CamRight, CamUp, CamDown, + LookLeft, LookRight, LookUp, LookDown, ZoomIn, ZoomOut, Fire, FreeLook diff --git a/src/client/input.cc b/src/client/input.cc index cf0c986..9b2521e 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -411,7 +411,7 @@ void action_press(Key *key) /* -- camera control ------------------------------ */ - case Action::CamLeft: + case Action::LookLeft: if (render::Camera::mode() == render::Camera::Free) { render::Camera::set_direction(math::min(key->pressed() - core::application()->time(), 1.0f)); @@ -419,7 +419,7 @@ void action_press(Key *key) render::Camera::set_direction(-math::min(key->pressed() - core::application()->time(), 1.0f)); } break; - case Action::CamRight: + case Action::LookRight: if (render::Camera::mode() == render::Camera::Free) { render::Camera::set_direction(-math::min(key->pressed() - core::application()->time(), 1.0f)); @@ -427,7 +427,7 @@ void action_press(Key *key) render::Camera::set_direction(math::min(key->pressed() - core::application()->time(), 1.0f)); } break; - case Action::CamUp: + case Action::LookUp: if (render::Camera::mode() == render::Camera::Free) { render::Camera::set_pitch(math::min(key->pressed() - core::application()->time(), 1.0f)); @@ -435,7 +435,7 @@ void action_press(Key *key) render::Camera::set_pitch(-math::min(key->pressed() - core::application()->time(), 1.0f)); } break; - case Action::CamDown: + case Action::LookDown: if (render::Camera::mode() == render::Camera::Free) { render::Camera::set_pitch(-math::min(key->pressed() - core::application()->time(), 1.0f)); @@ -546,16 +546,16 @@ void action_release(Key *key) /* -- camera control ------------------------------ */ - case Action::CamLeft: + case Action::LookLeft: render::Camera::set_direction(0.0f); break; - case Action::CamRight: + case Action::LookRight: render::Camera::set_direction(0.0f); break; - case Action::CamUp: + case Action::LookUp: render::Camera::set_pitch(0.0f); break; - case Action::CamDown: + case Action::LookDown: render::Camera::set_pitch(0.0f); break; case Action::ZoomIn: @@ -804,7 +804,7 @@ void frame() case SDL_MOUSEBUTTONDOWN: key = keyboard->press(512 + event.button.button); pressed = true; - if (key && (console_key_pressed(key) || ui::root()->input_mouse_button(true, event.button.button))) + if ((key && console_key_pressed(key)) || ui::root()->input_mouse_button(true, event.button.button)) { key = 0; } @@ -865,7 +865,7 @@ void frame() keyboard_modifiers = event.key.keysym.mod; key = keyboard->press(event.key.keysym.scancode); pressed = true; - if (console_key_pressed(key) || ui::root()->input_key(true, Keyboard::translate_keysym(event.key.keysym.sym, keyboard_modifiers), keyboard_modifiers)) + if ((key && console_key_pressed(key)) || ui::root()->input_key(true, Keyboard::translate_keysym(event.key.keysym.sym, keyboard_modifiers), keyboard_modifiers)) { key = 0; } diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc index e21fc91..bb3b20d 100644 --- a/src/client/keyboard.cc +++ b/src/client/keyboard.cc @@ -38,10 +38,10 @@ Keyboard::Keyboard() add_action("+rollleft", Action::RollLeft, "roll left"); add_action("+rollright", Action::RollRight, "roll right"); - add_action("+camleft", Action::CamLeft, "rotate camera left"); - add_action("+camright", Action::CamRight, "rotate camera right"); - add_action("+camup", Action::CamUp, "rotate camera up"); - add_action("+camdown", Action::CamDown, "rotate camera down"); + add_action("+lookleft", Action::LookLeft, "look left"); + add_action("+lookright", Action::LookRight, "look right"); + add_action("+lookup", Action::LookUp, "look up"); + add_action("+lookdown", Action::LookDown, "look down"); add_action("+zoomin", Action::ZoomIn, "zoom camera in"); add_action("+zoomout", Action::ZoomOut, "zoom camera out"); @@ -151,6 +151,7 @@ Keyboard::Keyboard() add_key(SDL_SCANCODE_KP_PLUS, "kpplus", '+', "+thrustup"); add_key(SDL_SCANCODE_KP_ENTER, "kpenter", '\n', "ui_chat"); add_key(SDL_SCANCODE_KP_EQUALS, "kpequal", '='); + add_key(SDL_SCANCODE_KP_LESS, "kpless", '<'); add_key(SDL_SCANCODE_UP, "up", 0, "+camup"); add_key(SDL_SCANCODE_DOWN, "down", 0, "+camdown"); @@ -187,7 +188,7 @@ Keyboard::Keyboard() add_key(SDL_SCANCODE_SCROLLLOCK, "scrollock"); add_key(SDL_SCANCODE_RSHIFT, "rshift"); - add_key(SDL_SCANCODE_LSHIFT, "lshift"); + add_key(SDL_SCANCODE_LSHIFT, "lshift", 0, "+freelook"); add_key(SDL_SCANCODE_RCTRL, "rctrl"); add_key(SDL_SCANCODE_LCTRL, "lctrl"); -- cgit v1.2.3