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-28 22:56:12 +0000
committerStijn Buys <ingar@osirion.org>2008-07-28 22:56:12 +0000
commitd7902db240adc2f081bee7e8fc36b866976fa5d1 (patch)
tree7000b5d396f0340124baf296f860e222664888bd /src/client/input.cc
parentfa45b822bb8cdcd3fb3654ee099bdeddd2290a5c (diff)
modifier keys for binds
Diffstat (limited to 'src/client/input.cc')
-rw-r--r--src/client/input.cc46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
index d26c3ba..aaf83fa 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -129,8 +129,8 @@ void func_list_keys(std::string const &args)
std::stringstream argstr(args);
std::string keyname;
if (argstr >> keyname) {
- aux::lowercase(keyname);
- keyboard->list_bind(keyname);
+ aux::to_lowercase(keyname);
+ keyboard->bind(keyname, "");
} else {
keyboard->list_keys();
}
@@ -145,8 +145,8 @@ void func_list_binds(std::string const &args)
std::stringstream argstr(args);
std::string keyname;
if (argstr >> keyname) {
- aux::lowercase(keyname);
- keyboard->list_bind(keyname);
+ aux::to_lowercase(keyname);
+ keyboard->bind(keyname, "");
} else {
keyboard->list_binds();
}
@@ -161,17 +161,17 @@ void func_bind(std::string const &args)
std::stringstream argstr(args);
std::string keyname;
if (argstr >> keyname) {
- aux::lowercase(keyname);
- if (args.size() > keyname.size()+1) {
+ aux::to_lowercase(keyname);
+ if (args.size() > keyname.size()+1) {
keyboard->bind(keyname, args.substr(keyname.size()+1));
} else {
- keyboard->list_bind(keyname);
+ keyboard->bind(keyname, "");
}
return;
+ } else {
+ core::Func *func = core::Func::find("bind");
+ con_print << "Usage: bind " << func->info() << std::endl;
}
- core::Func *func = core::Func::find("bind");
- con_print << "bind " << func->info() << std::endl;
-
} else {
con_warn << "Keyboard handler not installed!" << std::endl;
}
@@ -390,6 +390,19 @@ void action_release(std::string const &action)
}
}
+Key::Modifier convert_SDL_modifier(int const sdlmodifier)
+{
+ if (sdlmodifier & Key::Shift)
+ return Key::Shift;
+ else if (sdlmodifier & Key::Ctrl)
+ return Key::Ctrl;
+ else if (sdlmodifier & Key::Alt)
+ return Key::Alt;
+ else
+ return Key::None;
+
+}
+
void key_pressed(Key *key)
{
@@ -419,25 +432,24 @@ void key_pressed(Key *key)
targets::select_target(targets::hover());
} else {
- // FIXME modifiers
- char c = key->bind(Key::None).c_str()[0];
+
+ char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0];
if (c == '+') {
// action bind
- action_press(key->bind(Key::None));
+ action_press(key->bind(convert_SDL_modifier(keyboard_modifiers)));
} else if (c) {
// normal bind
- core::cmd() << key->bind(Key::None) << "\n";
+ core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << "\n";
}
}
} else if (core::application()->connected()) {
- // FIXME modifiers
- char c = key->bind(Key::None).c_str()[0];
+ char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0];
if (c && c != '+') {
// normal bind
- core::cmd() << key->bind(Key::None) << "\n";
+ core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << "\n";
}
}