]> git.tdb.fi Git - libs/gui.git/blob - source/input/cocoa/keyboard.cpp
db097aaaa67d9a93c98b1e46f8b177d7256e5fdc
[libs/gui.git] / source / input / cocoa / keyboard.cpp
1 #include <msp/graphics/window_private.h>
2 #include "keyboard.h"
3 #include "keys_private.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace Input {
9
10 string Keyboard::get_button_name(unsigned btn) const
11 {
12         return Device::get_button_name(btn);
13 }
14
15 void Keyboard::input_event(const Graphics::Window::Event &event)
16 {
17         switch(event.cevent.type)
18         {
19         case KEY_DOWN:
20         case KEY_UP:
21                 if(unsigned key = key_from_sys(event.cevent.key.key))
22                         set_button_state(key, event.cevent.type==KEY_DOWN, true);
23                 if(event.cevent.type==KEY_DOWN && event.cevent.key.character>0)
24                         signal_character.emit(event.cevent.key.character);
25                 break;
26         default:;
27         }
28 }
29
30 } // namespace Input
31 } // namespace Msp