]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/keyboard.cpp
Split platform-specific parts into separate directories
[libs/gui.git] / source / input / keyboard.cpp
index ab2f9eae3b1e18a13edfb110251cbfa1155866ca..159e5ee41b9e304adfb777e649251aa2c274887c 100644 (file)
@@ -1,18 +1,7 @@
-#ifdef WIN32
-#include <windows.h>
-#else
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#endif
-#include <msp/graphics/display.h>
 #include <msp/graphics/window.h>
-#include <msp/graphics/display_priv.h>
-#include <msp/graphics/window_priv.h>
 #include "keyboard.h"
 #include "keys.h"
 
-#define MAPVK_VK_TO_VSC 0
-
 namespace Msp {
 namespace Input {
 
@@ -26,59 +15,5 @@ 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 Device::get_button_name(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 Device::get_button_name(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 = XLookupKeysym(const_cast<XKeyEvent *>(&event.xevent.xkey), 0);
-                       if(keysym!=NoSymbol)
-                               if(unsigned key = key_from_sys(keysym))
-                                       set_button_state(key, event.xevent.type==KeyPress, true);
-                       if(event.xevent.type==KeyPress)
-                       {
-                               char ch;
-                               if(XLookupString(const_cast<XKeyEvent *>(&event.xevent.xkey), &ch, 1, 0, 0))
-                                       // XLookupString always returns Latin-1
-                                       signal_character.emit(static_cast<unsigned char>(ch));
-                       }
-               }
-               break;
-       }
-#endif
-}
-
 } // namespace Input
 } // namespace Msp