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>
15 Keyboard::Keyboard(Graphics::Window &w):
20 buttons.resize(256, false);
22 window.signal_key_press.connect(sigc::mem_fun(this, &Keyboard::key_press));
23 window.signal_key_release.connect(sigc::mem_fun(this, &Keyboard::key_release));
26 std::string Keyboard::get_button_name(unsigned btn) const
29 KeySym ksym=XKeycodeToKeysym(window.get_display().get_display(), btn, 0);
30 return XKeysymToString(ksym);
33 if(!GetKeyNameText(btn<<16, buf, sizeof(buf)))
34 return format("Key %d", btn);
39 void Keyboard::key_press(unsigned key, unsigned, unsigned)
41 set_button_state(key, true, true);
44 void Keyboard::key_release(unsigned key, unsigned)
46 set_button_state(key, false, true);