6 #include <msp/graphics/display.h>
7 #include <msp/strings/format.h>
11 #define MAPVK_VK_TO_VSC 0
16 Keyboard::Keyboard(Graphics::EventSource &s):
21 buttons.resize(N_KEYS_, false);
23 source.signal_key_press.connect(sigc::mem_fun(this, &Keyboard::key_press));
24 source.signal_key_release.connect(sigc::mem_fun(this, &Keyboard::key_release));
27 std::string Keyboard::get_button_name(unsigned btn) const
32 const char *str = XKeysymToString(key_to_sys(btn));
34 return format("Key %d", btn);
38 unsigned scan = MapVirtualKey(key_to_sys(btn), MAPVK_VK_TO_VSC);
39 if(!GetKeyNameText(scan<<16, buf, sizeof(buf)))
40 return format("Key %d", btn);
45 void Keyboard::key_press(unsigned key, unsigned, unsigned)
47 set_button_state(key_from_sys(key), true, true);
50 void Keyboard::key_release(unsigned key, unsigned)
52 set_button_state(key_from_sys(key), false, true);