X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fkeyboard.cpp;h=0a690d1b686a569a790d187224a3fb4e725e93ec;hb=a5be5c703808817dda8feafb03b0aec04b20afbb;hp=fff0678441786d7610a8a1e6c23dae1d85d441b8;hpb=821cea8627597a5458c1cb02c0652384bb3431a4;p=libs%2Fgui.git diff --git a/source/input/keyboard.cpp b/source/input/keyboard.cpp index fff0678..0a690d1 100644 --- a/source/input/keyboard.cpp +++ b/source/input/keyboard.cpp @@ -1,56 +1,22 @@ -#ifdef WIN32 -#include -#else -#include -#endif -#include -#include "../gbase/display.h" +#include #include "keyboard.h" #include "keys.h" -#define MAPVK_VK_TO_VSC 0 - namespace Msp { namespace Input { -Keyboard::Keyboard(Graphics::EventSource &s): - source(s) +Keyboard::Keyboard(Graphics::Window &w): + window(w) { name = "Keyboard"; buttons.resize(N_KEYS_, false); - source.signal_key_press.connect(sigc::mem_fun(this, &Keyboard::key_press)); - source.signal_key_release.connect(sigc::mem_fun(this, &Keyboard::key_release)); + window.signal_input_event.connect(sigc::mem_fun(this, &Keyboard::input_event)); } -std::string Keyboard::get_button_name(unsigned btn) const -{ - if(btn==0) - return "None"; -#ifndef WIN32 - const char *str = XKeysymToString(key_to_sys(btn)); - if(!str) - return format("Key %d", btn); - return str; -#else - char buf[128]; - unsigned scan = MapVirtualKey(key_to_sys(btn), MAPVK_VK_TO_VSC); - if(!GetKeyNameText(scan<<16, buf, sizeof(buf))) - return format("Key %d", btn); - return buf; -#endif -} - -void Keyboard::key_press(unsigned key, unsigned, unsigned) -{ - set_button_state(key_from_sys(key), true, true); -} - -void Keyboard::key_release(unsigned key, unsigned) -{ - set_button_state(key_from_sys(key), false, true); -} +Keyboard::~Keyboard() +{ } } // namespace Input } // namespace Msp