X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fkeyboard.cpp;h=0a690d1b686a569a790d187224a3fb4e725e93ec;hb=c430f2d7498e9c2daa515ee9aba3a95257e5e999;hp=ea66cf28ab11aa9d74f55680293336f4e5efae83;hpb=5d688fbf457b1f4d3bebde431a7f58c898be584c;p=libs%2Fgui.git diff --git a/source/input/keyboard.cpp b/source/input/keyboard.cpp index ea66cf2..0a690d1 100644 --- a/source/input/keyboard.cpp +++ b/source/input/keyboard.cpp @@ -1,19 +1,7 @@ -#ifdef WIN32 -#include -#else -#include -#include -#endif -#include #include -#include -#include -#include #include "keyboard.h" #include "keys.h" -#define MAPVK_VK_TO_VSC 0 - namespace Msp { namespace Input { @@ -27,58 +15,8 @@ Keyboard::Keyboard(Graphics::Window &w): 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::input_event(const Graphics::Window::Event &event) -{ -#ifdef WIN32 - switch(event.msg) - { - case WM_KEYDOWN: - case WM_KEYUP: - set_button_state(key_from_sys(event.wparam), event.msg==WM_KEYDOWN, true); - break; - case WM_CHAR: - signal_character.emit(event.wparam); - break; - } -#else - switch(event.xevent.type) - { - case KeyPress: - case KeyRelease: - { - KeySym keysym = XKeycodeToKeysym(window.get_display().get_private().display, event.xevent.xkey.keycode, 0); - if(keysym!=NoSymbol) - set_button_state(key_from_sys(keysym), event.xevent.type==KeyPress, true); - if(event.xevent.type==KeyPress) - { - char ch; - if(XLookupString(const_cast(&event.xevent.xkey), &ch, 1, 0, 0)) - // XLookupString always returns Latin-1 - signal_character.emit(static_cast(ch)); - } - } - break; - } -#endif -} +Keyboard::~Keyboard() +{ } } // namespace Input } // namespace Msp