]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/android/keyboard.cpp
Android support
[libs/gui.git] / source / input / android / keyboard.cpp
diff --git a/source/input/android/keyboard.cpp b/source/input/android/keyboard.cpp
new file mode 100644 (file)
index 0000000..631b048
--- /dev/null
@@ -0,0 +1,35 @@
+#include <android/input.h>
+#include <msp/graphics/window_private.h>
+#include "keyboard.h"
+#include "keys_private.h"
+
+using namespace std;
+
+namespace Msp {
+namespace Input {
+
+string Keyboard::get_button_name(unsigned btn) const
+{
+       return Device::get_button_name(btn);
+}
+
+void Keyboard::input_event(const Graphics::Window::Event &event)
+{
+       int type = AInputEvent_getType(event.aevent);
+       if(type!=AINPUT_EVENT_TYPE_KEY)
+               return;
+
+       int action = AKeyEvent_getAction(event.aevent);
+       switch(action)
+       {
+       case AKEY_EVENT_ACTION_DOWN:
+       case AKEY_EVENT_ACTION_UP:
+               if(unsigned key = key_from_sys(AKeyEvent_getKeyCode(event.aevent)))
+                       set_button_state(key, action==AKEY_EVENT_ACTION_DOWN, true);
+               break;
+       default:;
+       }
+}
+
+} // namespace Input
+} // namespace Msp