]> git.tdb.fi Git - libs/gui.git/blob - source/input/android/keyboard.cpp
Android support
[libs/gui.git] / source / input / android / keyboard.cpp
1 #include <android/input.h>
2 #include <msp/graphics/window_private.h>
3 #include "keyboard.h"
4 #include "keys_private.h"
5
6 using namespace std;
7
8 namespace Msp {
9 namespace Input {
10
11 string Keyboard::get_button_name(unsigned btn) const
12 {
13         return Device::get_button_name(btn);
14 }
15
16 void Keyboard::input_event(const Graphics::Window::Event &event)
17 {
18         int type = AInputEvent_getType(event.aevent);
19         if(type!=AINPUT_EVENT_TYPE_KEY)
20                 return;
21
22         int action = AKeyEvent_getAction(event.aevent);
23         switch(action)
24         {
25         case AKEY_EVENT_ACTION_DOWN:
26         case AKEY_EVENT_ACTION_UP:
27                 if(unsigned key = key_from_sys(AKeyEvent_getKeyCode(event.aevent)))
28                         set_button_state(key, action==AKEY_EVENT_ACTION_DOWN, true);
29                 break;
30         default:;
31         }
32 }
33
34 } // namespace Input
35 } // namespace Msp