From 6817dec0b405b325a2762e352ad2a5916c24542a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 31 Jul 2016 14:14:25 +0200 Subject: Added reset_controls function to revert to the default keyboard configuration, don't override unbound keys with default binds. --- src/client/keyboard.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/client/keyboard.cc') diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc index b05aaa8..fe6496f 100644 --- a/src/client/keyboard.cc +++ b/src/client/keyboard.cc @@ -253,8 +253,8 @@ Keyboard::Keyboard() add_control("Roll left", "+rollleft", "q"); add_control("Roll right", "+rollright", "e"); - add_control("Decrease thruster", "+thrustdown", "kpmin"); - add_control("Increase thruster", "+thrustup", "kpplus"); + add_control("Increase thruster", "+thrustup", "mwheelup"); + add_control("Decrease thruster", "+thrustdown", "mwheeldown"); add_control("Aferburner", "+afterburner", "w"); add_control("Reverse engine", "+reverse", "s"); @@ -382,6 +382,9 @@ void Keyboard::load_binds() } con_print << " reading keyboard binds from " << filename << std::endl; + + // clear default configuration + unbindall(); char line[MAXCMDSIZE]; while (ifs.getline(line, MAXCMDSIZE - 1)) { @@ -393,6 +396,21 @@ void Keyboard::load_binds() load_controls(); } + +// load keybinds from control definitions +void Keyboard::load_defaults() +{ + for (Controls::iterator cit = _controls.begin(); cit != _controls.end(); ++cit) + { + Control *control = *cit; + + std::stringstream str; + str << "bind " << control->defaultkeyname() << " " << control->command(); + core::CommandBuffer::exec(str.str().c_str()); + } +} + +// load control keys from binds void Keyboard::load_controls() { for (Controls::iterator cit = _controls.begin(); cit != _controls.end(); ++cit) -- cgit v1.2.3