From 2bbe67afdf4d4df36fc100690cf87c8a75d5a354 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 10:06:39 +0000 Subject: Added more flexible KeyState constructor; updated comment in gui/Key.h svn-id: r27654 --- common/keyboard.h | 9 ++++++++- gui/Key.h | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/common/keyboard.h b/common/keyboard.h index f526b8cb8e..d0d0e43f00 100644 --- a/common/keyboard.h +++ b/common/keyboard.h @@ -233,6 +233,7 @@ struct KeyState { * and look at that, if you want to find out a key code. */ KeyCode keycode; + /** * ASCII-value of the pressed key (if any). * This depends on modifiers, i.e. pressing the 'A' key results in @@ -240,6 +241,7 @@ struct KeyState { * caps lock. */ uint16 ascii; + /** * Status of the modifier keys. Bits are set in this for each * pressed modifier @@ -247,7 +249,12 @@ struct KeyState { */ byte flags; - KeyState() { reset(); } + KeyState(KeyCode kc = KEYCODE_INVALID, uint16 asc = 0, byte f = 0) { + keycode = kc; + ascii = asc ? asc : (uint16)kc; + flags = f; + } + void reset() { keycode = KEYCODE_INVALID; ascii = flags = 0; diff --git a/gui/Key.h b/gui/Key.h index 9283a789ae..663293886b 100644 --- a/gui/Key.h +++ b/gui/Key.h @@ -32,7 +32,11 @@ namespace GUI { -// TODO/FIXME: Make use of Common::KeyState from common/keyboard.h +// TODO/FIXME: Make use of Common::KeyState from common/keyboard.h, +// or even better, just completely replace this by it. +// To be able to do that, though, the code using GUI::Key would need to +// be adopted -- right now it uses SDL keycodes, and uses SDL_PushEvent +// to generated fake events. class Key { public: -- cgit v1.2.3