]> git.tdb.fi Git - libs/gltk.git/blob - source/systemkeyboardinput.cpp
Add an input method subsystem
[libs/gltk.git] / source / systemkeyboardinput.cpp
1 #include <msp/input/keys.h>
2 #include "root.h"
3 #include "systemkeyboardinput.h"
4
5 namespace Msp {
6 namespace GLtk {
7
8 SystemKeyboardInput::SystemKeyboardInput(Root &r, Input::Keyboard &k):
9         InputMethod(r),
10         keyboard(k)
11 {
12         keyboard.signal_button_press.connect(sigc::mem_fun(this, &SystemKeyboardInput::key_press));
13         keyboard.signal_button_release.connect(sigc::mem_fun(this, &SystemKeyboardInput::key_release));
14         keyboard.signal_character.connect(sigc::mem_fun(this, &SystemKeyboardInput::character));
15 }
16
17 bool SystemKeyboardInput::key_press(unsigned key)
18 {
19         // TODO modifiers
20         if(root.key_press(key, 0))
21                 return true;
22         
23         return false;
24 }
25
26 bool SystemKeyboardInput::key_release(unsigned key)
27 {
28         return root.key_release(key, 0);
29 }
30
31 bool SystemKeyboardInput::character(StringCodec::unichar ch)
32 {
33         return root.character(ch);
34 }
35
36 } // namespace GLtk
37 } // namespace Msp