3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/strings/formatter.h>
9 #include "../gbase/display.h"
13 #define MAPVK_VK_TO_VSC 0
18 Keyboard::Keyboard(Graphics::Window &w):
23 buttons.resize(N_KEYS_, false);
25 window.signal_key_press.connect(sigc::mem_fun(this, &Keyboard::key_press));
26 window.signal_key_release.connect(sigc::mem_fun(this, &Keyboard::key_release));
29 std::string Keyboard::get_button_name(unsigned btn) const
34 const char *str=XKeysymToString(key_to_sys(btn));
36 return format("Key %d", btn);
40 unsigned scan=MapVirtualKey(key_to_sys(btn), MAPVK_VK_TO_VSC);
41 if(!GetKeyNameText(scan<<16, buf, sizeof(buf)))
42 return format("Key %d", btn);
47 void Keyboard::key_press(unsigned key, unsigned, unsigned)
49 set_button_state(key_from_sys(key), true, true);
52 void Keyboard::key_release(unsigned key, unsigned)
54 set_button_state(key_from_sys(key), false, true);