diff Platforms/Wasm/Defaults.cpp @ 327:8716176ff7f0 am-2

added support for arrow keys
author am@osimis.io
date Tue, 16 Oct 2018 15:25:21 +0200
parents 14ef1227120f
children 6cc3ce74dc05
line wrap: on
line diff
--- a/Platforms/Wasm/Defaults.cpp	Tue Oct 16 12:57:38 2018 +0200
+++ b/Platforms/Wasm/Defaults.cpp	Tue Oct 16 15:25:21 2018 +0200
@@ -219,7 +219,8 @@
   }
   
   void EMSCRIPTEN_KEEPALIVE ViewportKeyPressed(ViewportHandle viewport,
-                                               const char* key, 
+                                               int key,
+                                               const char* keyChar, 
                                                bool isShiftPressed, 
                                                bool isControlPressed,
                                                bool isAltPressed)
@@ -235,8 +236,12 @@
     if (isAltPressed) {
       modifiers = static_cast<OrthancStone::KeyboardModifiers>(modifiers + OrthancStone::KeyboardModifiers_Alt);
     }
-    printf("key pressed : %c\n", key[0]);
-    viewport->KeyPressed(key[0], modifiers);
+
+    char c = 0;
+    if (keyChar != NULL && key == OrthancStone::KeyboardKeys_Generic) {
+      c = keyChar[0];
+    }
+    viewport->KeyPressed(static_cast<OrthancStone::KeyboardKeys>(key), c, modifiers);
   }