html5: workaround for echo key events.

(cherry picked from commit 352db6b17e)
This commit is contained in:
hondres 2016-03-04 20:26:39 +01:00 committed by Rémi Verschelde
parent 848c7378fd
commit afd75013f9
3 changed files with 27 additions and 2 deletions

View File

@ -74,6 +74,15 @@ static void _glut_skey(bool pressed,int key) {
case GLUT_KEY_INSERT: ev.key.scancode=KEY_INSERT; break; 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(); uint32_t m = glutGetModifiers();
ev.key.mod.alt=(m&GLUT_ACTIVE_ALT)!=0; ev.key.mod.alt=(m&GLUT_ACTIVE_ALT)!=0;
@ -107,6 +116,16 @@ static void _glut_key(bool pressed,unsigned char key) {
default: { default: {
ev.key.unicode=key; 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;
}
} }

View File

@ -693,7 +693,11 @@ OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, Ope
time_to_save_sync=-1; 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() { OS_JavaScript::~OS_JavaScript() {

View File

@ -56,10 +56,12 @@ public:
Point2 pos; Point2 pos;
}; };
bool skey_pressed[121];
bool key_pressed[256];
private: private:
Vector<TouchPos> touch; Vector<TouchPos> touch;
Point2 last_mouse; Point2 last_mouse;
unsigned int last_id; unsigned int last_id;
GFXInitFunc gfx_init_func; GFXInitFunc gfx_init_func;