From 2c7c599647773221fceacc1633b95e4b614b8af3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 21 Jul 2008 22:57:08 +0000 Subject: unbindall, proper delete key support --- src/client/chat.cc | 5 +++++ src/client/console.cc | 5 +++++ src/client/input.cc | 4 ++++ src/client/keyboard.cc | 11 ++++++----- 4 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src/client') diff --git a/src/client/chat.cc b/src/client/chat.cc index 6c3140d..522a675 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -173,6 +173,11 @@ void keypressed(unsigned int key) if (input_pos < (*history_pos).size()) input_pos++; break; + case SDLK_DELETE: + if ((*history_pos).size() && input_pos < (*history_pos).size()) { + (*history_pos).erase(input_pos, 1); + } + break; case SDLK_BACKSPACE: if ((*history_pos).size() && input_pos) { (*history_pos).erase(input_pos-1, 1); diff --git a/src/client/console.cc b/src/client/console.cc index 7bb1aaf..ddcaa32 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -151,6 +151,11 @@ void Console::keypressed(unsigned int key) if (input_pos < (*history_pos).size()) input_pos++; break; + case SDLK_DELETE: + if ((*history_pos).size() && input_pos < (*history_pos).size()) { + (*history_pos).erase(input_pos, 1); + } + break; case SDLK_BACKSPACE: if ((*history_pos).size() && input_pos) { (*history_pos).erase(input_pos-1, 1); diff --git a/src/client/input.cc b/src/client/input.cc index 5e75f0a..dc40b8f 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -201,6 +201,9 @@ void init() func = core::Func::add("unbind", func_unbind); func->set_info("[key] unbind a key"); + func = core::Func::add("unbindall", func_unbind); + func->set_info("unbind all keys"); + func = core::Func::add("screenshot", func_screenshot); func->set_info("make a screenshot"); @@ -216,6 +219,7 @@ void shutdown() core::Func::remove("bind"); core::Func::remove("unbind"); + core::Func::remove("unbindall"); core::Func::remove("screenshot"); diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc index 170fbd1..c569499 100644 --- a/src/client/keyboard.cc +++ b/src/client/keyboard.cc @@ -372,8 +372,6 @@ unsigned int translate_keysym(const SDL_keysym &keysym) bool shift = false; bool numlock = false; - - // keypad keys if (keysym.mod & KMOD_NUM) { numlock = true; @@ -408,6 +406,9 @@ unsigned int translate_keysym(const SDL_keysym &keysym) case SDLK_KP9: return '9'; break; + case SDLK_KP_PERIOD: + return '.'; + break; } } else { switch (key) { @@ -438,6 +439,9 @@ unsigned int translate_keysym(const SDL_keysym &keysym) case SDLK_KP9: return SDLK_PAGEUP; break; + case SDLK_KP_PERIOD: + return SDLK_DELETE; + break; } } @@ -449,9 +453,6 @@ unsigned int translate_keysym(const SDL_keysym &keysym) case SDLK_KP_ENTER: return SDLK_RETURN; break; - case SDLK_KP_PERIOD: - return '.'; - break; case SDLK_KP_DIVIDE: return '/'; break; -- cgit v1.2.3