15 #define VK_USE_PLATFORM_ANDROID_KHR
17 #include <vsg/app/Window.h>
18 #include <vsg/ui/KeyEvent.h>
20 #include <android/input.h>
21 #include <android/native_window.h>
32 using AKeyCodeToKeySymbolMap = std::map<uint32_t, vsg::KeySymbol>;
34 bool getKeySymbol(uint32_t keycode, uint32_t metastate, vsg::KeySymbol& keySymbol, vsg::KeySymbol& modifiedKeySymbol, vsg::KeyModifier& keyModifier)
36 auto itr = _keycodeMap.find(keycode);
37 if (itr == _keycodeMap.end())
return false;
39 keySymbol = itr->second;
40 modifiedKeySymbol = keySymbol;
42 uint16_t modifierMask = 0;
44 if (metastate & AMETA_ALT_ON) modifierMask |= vsg::KeyModifier::MODKEY_Alt;
45 if (metastate & AMETA_CTRL_ON) modifierMask |= vsg::KeyModifier::MODKEY_Control;
46 if (metastate & AMETA_SHIFT_ON) modifierMask |= vsg::KeyModifier::MODKEY_Shift;
47 if (metastate & AMETA_CAPS_LOCK_ON) modifierMask |= vsg::KeyModifier::MODKEY_CapsLock;
48 if (metastate & AMETA_NUM_LOCK_ON) modifierMask |= vsg::KeyModifier::MODKEY_NumLock;
50 keyModifier = (vsg::KeyModifier)modifierMask;
58 AKeyCodeToKeySymbolMap _keycodeMap;
85 const char* instanceExtensionSurfaceName()
const override {
return "VK_KHR_android_surface"; }
87 bool valid()
const override {
return _window; }
91 void resize()
override;
93 bool handleAndroidInputEvent(AInputEvent* anEvent);
98 void _initSurface()
override;
100 ANativeWindow* _window;
102 int64_t _first_android_timestamp = 0;
103 vsg::clock::time_point _first_android_time_point;
Definition: Android_Window.h:78
bool pollEvents(vsg::UIEvents &events) override
get the list of events since the last pollEvents() call by splicing bufferEvents with polled windowin...
KeyboardMap maps Android keyboard events to vsg::KeySymbol.
Definition: Android_Window.h:28