summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2016-03-05 13:05:49 +0100
committerRémi Verschelde <remi@verschelde.fr>2016-03-05 13:05:49 +0100
commit6b1ca582f94b23e000e8c930586bf980e12e622c (patch)
treebcc798ce24953cd7a45bc4c865e071f571773e5d
parent5a9b18b665b250b54c0d8eb80354dc08e363377c (diff)
parent352db6b17eaed84fef930723a67c6fba40a4b099 (diff)
Merge pull request #3920 from Hinsbart/js_echo_keys
html5: workaround for echo key events.
-rw-r--r--platform/javascript/javascript_main.cpp19
-rw-r--r--platform/javascript/os_javascript.cpp6
-rw-r--r--platform/javascript/os_javascript.h4
3 files changed, 27 insertions, 2 deletions
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp
index e66110b655..632ef2b6b2 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -74,6 +74,15 @@ static void _glut_skey(bool pressed,int key) {
case GLUT_KEY_INSERT: ev.key.scancode=KEY_INSERT; break;
}
+ if (pressed) {
+ if (os->skey_pressed[key])
+ ev.key.echo = true;
+ else
+ os->skey_pressed[key] = true;
+ }
+ else {
+ os->skey_pressed[key] = false;
+ }
uint32_t m = glutGetModifiers();
ev.key.mod.alt=(m&GLUT_ACTIVE_ALT)!=0;
@@ -107,6 +116,16 @@ static void _glut_key(bool pressed,unsigned char key) {
default: {
ev.key.unicode=key;
}
+
+ if (pressed) {
+ if (os->key_pressed[key])
+ ev.key.echo = true;
+ else
+ os->key_pressed[key] = true;
+ }
+ else {
+ os->key_pressed[key] = false;
+ }
}
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 562733ab89..413d88ee23 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -693,7 +693,11 @@ OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, Ope
time_to_save_sync=-1;
-
+ for (int i = 0; i < 256; i++) {
+ key_pressed[i] = false;
+ if (i < 121)
+ skey_pressed[i] = false;
+ }
}
OS_JavaScript::~OS_JavaScript() {
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index ec3a6cf911..4a8265b9d9 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -56,10 +56,12 @@ public:
Point2 pos;
};
+ bool skey_pressed[121];
+ bool key_pressed[256];
+
private:
Vector<TouchPos> touch;
-
Point2 last_mouse;
unsigned int last_id;
GFXInitFunc gfx_init_func;