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-07-22 13:14:35 +0000
committerStijn Buys <ingar@osirion.org>2008-07-22 13:14:35 +0000
commit59ea9fffec01a6cc3fbf147aa311bfaa9abaa933 (patch)
tree818d0aa87f57575d66b4fe37b74de73a525f9614 /src/client/keyboard.cc
parentbe7bb48ecb252cd098f6cae7c72b6645c2be4609 (diff)
list_actions, renamed thruster actions
Diffstat (limited to 'src/client/keyboard.cc')
-rw-r--r--src/client/keyboard.cc78
1 files changed, 71 insertions, 7 deletions
diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc
index c569499..da93814 100644
--- a/src/client/keyboard.cc
+++ b/src/client/keyboard.cc
@@ -28,6 +28,31 @@ Keyboard::Keyboard()
numlock = false;
capslock = false;
+ // ------------------ ACTIONS
+
+ // note: actions should be state keys and not use key repeat
+ // FIXME: thruster should be a state key
+
+ add_action("+left", Action::None, "rotate left");
+ add_action("+right", Action::None, "rotate right");
+ add_action("+up", Action::None, "rotate up");
+ add_action("+down", Action::None, "rotate down");
+
+ add_action("+rollleft", Action::None, "roll left");
+ add_action("+rollright", Action::None, "roll right");
+
+ add_action("+camleft", Action::None, "rotate camera left");
+ add_action("+camright", Action::None, "rotate camera right");
+ add_action("+camup", Action::None, "rotate camera up");
+ add_action("+camdown", Action::None, "rotate camera down");
+
+ add_action("+thrustup", Action::None, "increase thruster");
+ add_action("+thrustdown", Action::None, "decrease thruster");
+
+ add_action("+control", Action::None, "enable mouse control while pressed");
+
+ // ------------------ KEYS
+
add_key("backspace", SDLK_BACKSPACE);
add_key("tab", SDLK_TAB);
add_key("clear", SDLK_CLEAR);
@@ -117,8 +142,8 @@ Keyboard::Keyboard()
add_key("kpperiod", SDLK_KP_PERIOD, '.');
add_key("kpdiv", SDLK_KP_DIVIDE, '/', "+rollleft");
add_key("kpmul", SDLK_KP_MULTIPLY, '*', "+rollright");
- add_key("kpmin", SDLK_KP_MINUS, '-', "-thrust");
- add_key("kpplus", SDLK_KP_PLUS, '+', "+thrust");
+ add_key("kpmin", SDLK_KP_MINUS, '-', "+thrustdown");
+ add_key("kpplus", SDLK_KP_PLUS, '+', "+thrustup");
add_key("kpenter", SDLK_KP_ENTER, '\n');
add_key("kpequal", SDLK_KP_EQUALS, '=');
@@ -181,16 +206,21 @@ Keyboard::Keyboard()
add_key("mouse2", 512 + SDL_BUTTON_RIGHT);
add_key("mouse3", 512 + SDL_BUTTON_MIDDLE);
- add_key("mouse4", 512 + SDL_BUTTON_WHEELUP, 0, "+thrust");
- add_key("mouse5", 512 + SDL_BUTTON_WHEELDOWN, 0, "-thrust");
+ add_key("mouse4", 512 + SDL_BUTTON_WHEELUP, 0, "+thrustup");
+ add_key("mouse5", 512 + SDL_BUTTON_WHEELDOWN, 0, "+thrustdown");
}
Keyboard::~Keyboard()
{
+ // clear key map
for (iterator it = begin(); it != end(); it++)
delete(*it).second;
-
keys.clear();
+
+ // clear action list
+ for(std::list<Action *>::iterator ait = actions.begin(); ait != actions.end(); ait++)
+ delete (*ait);
+ actions.clear();
}
void Keyboard::save_binds()
@@ -323,12 +353,46 @@ void Keyboard::add_key(const char *name, const unsigned int keysym, const char a
keys[keysym] = new Key(name, keysym, ascii, bind);
}
+void Keyboard::add_action(const char *name, Action::Identifier action, const char *info)
+{
+ actions.push_back(new Action(name, action, info));
+}
+
+void Keyboard::list_actions()
+{
+ for (std::list<Action *>::iterator it = actions.begin(); it != actions.end(); it++) {
+ con_print << " " << (*it)->name() << " " << (*it)->info() << std::endl;
+ }
+ con_print << actions.size() << " registered actions" << std::endl;
+}
+
void Keyboard::list_keys()
{
for (iterator it = begin(); it != end(); it++) {
con_print << " " << aux::pad_left((*it).second->name(), 6) << " " << (*it).second->bind(Key::None) << std::endl;
}
- con_print << keys.size() << " keys" << std::endl;
+ con_print << keys.size() << " registered keys" << std::endl;
+}
+
+void Keyboard::list_bind(std::string const &name)
+{
+ Key *key = find(name);
+ if (key) {
+ if (key->bind(Key::None).size()) {
+ con_print << " " << aux::pad_left(key->name(), 6) << " " << key->bind(Key::None) << std::endl;
+ }
+ if (key->bind(Key::Shift).size()) {
+ con_print << " shift+" << aux::pad_left(key->name(), 6) << " " << key->bind(Key::Shift) << std::endl;
+ }
+ if (key->bind(Key::Ctrl).size()) {
+ con_print << " ctrl+" << aux::pad_left(key->name(), 6) << " " << key->bind(Key::Ctrl) << std::endl;
+ }
+ if (key->bind(Key::Alt).size()) {
+ con_print << " alt+" << aux::pad_left(key->name(), 6) << " " << key->bind(Key::Alt) << std::endl;
+ }
+ } else {
+ con_print << "key '" << name << "' not found" << std::endl;
+ }
}
void Keyboard::list_binds()
@@ -353,7 +417,7 @@ void Keyboard::list_binds()
}
}
- con_print << n << " binds" << std::endl;
+ con_print << n << " registered binds" << std::endl;
}
void setkeyboardmode(bool input)