X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fwindows%2Fkeyboard.cpp;fp=source%2Finput%2Fwindows%2Fkeyboard.cpp;h=24b019ebcb5e4c3c8989654433df5f7a95cef6e5;hb=1aca77b93853ee127ac3bbf6886f7f04920542ef;hp=0000000000000000000000000000000000000000;hpb=4464dd5d973c47f6d7a7c352a90bd88cdb717cd2;p=libs%2Fgui.git diff --git a/source/input/windows/keyboard.cpp b/source/input/windows/keyboard.cpp new file mode 100644 index 0000000..24b019e --- /dev/null +++ b/source/input/windows/keyboard.cpp @@ -0,0 +1,38 @@ +#include +#include +#include "keyboard.h" +#include "keys_private.h" + +#define MAPVK_VK_TO_VSC 0 + +namespace Msp { +namespace Input { + +std::string Keyboard::get_button_name(unsigned btn) const +{ + if(btn==0) + return "None"; + + 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; +} + +void Keyboard::input_event(const Graphics::Window::Event &event) +{ + 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; + } +} + +} // namespace Input +} // namespace Msp