Fix some mouse bugs in WebAssembly/asm.js
- Emit mouse wheel release events - Set button masks, fixes #5092
This commit is contained in:
parent
a6ae3204fb
commit
30e9ea5a82
3 changed files with 17 additions and 5 deletions
|
@ -66,11 +66,12 @@ static void _glut_mouse_button(int button, int state, int x, int y) {
|
|||
|
||||
if (ev.mouse_button.button_index<4) {
|
||||
if (ev.mouse_button.pressed) {
|
||||
_mouse_button_mask|=1<<ev.mouse_button.button_index;
|
||||
_mouse_button_mask |= 1 << (ev.mouse_button.button_index-1);
|
||||
} else {
|
||||
_mouse_button_mask&=~(1<<ev.mouse_button.button_index);
|
||||
_mouse_button_mask &= ~(1 << (ev.mouse_button.button_index-1));
|
||||
}
|
||||
}
|
||||
ev.mouse_button.button_mask=_mouse_button_mask;
|
||||
|
||||
uint32_t m = glutGetModifiers();
|
||||
ev.mouse_button.mod.alt=(m&GLUT_ACTIVE_ALT)!=0;
|
||||
|
@ -79,6 +80,11 @@ static void _glut_mouse_button(int button, int state, int x, int y) {
|
|||
|
||||
os->push_input(ev);
|
||||
|
||||
if (ev.mouse_button.button_index==BUTTON_WHEEL_UP || ev.mouse_button.button_index==BUTTON_WHEEL_DOWN) {
|
||||
// GLUT doesn't send release events for mouse wheel, so send manually
|
||||
ev.mouse_button.pressed=false;
|
||||
os->push_input(ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,7 +168,6 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
glutMouseFunc(_glut_mouse_button);
|
||||
glutMotionFunc(_glut_mouse_motion);
|
||||
glutMotionFunc(_glut_mouse_motion);
|
||||
glutPassiveMotionFunc(_glut_mouse_motion);
|
||||
|
||||
|
||||
|
|
|
@ -299,13 +299,15 @@ bool OS_JavaScript::is_mouse_grab_enabled() const {
|
|||
//*sigh* technology has evolved so much since i was a kid..
|
||||
return false;
|
||||
}
|
||||
|
||||
Point2 OS_JavaScript::get_mouse_pos() const {
|
||||
|
||||
return Point2();
|
||||
return input->get_mouse_pos();
|
||||
}
|
||||
|
||||
int OS_JavaScript::get_mouse_button_state() const {
|
||||
|
||||
return 0;
|
||||
return last_button_mask;
|
||||
}
|
||||
|
||||
void OS_JavaScript::set_window_title(const String& p_title) {
|
||||
|
@ -427,6 +429,9 @@ void OS_JavaScript::push_input(const InputEvent& p_ev) {
|
|||
if (ev.type==InputEvent::MOUSE_MOTION) {
|
||||
input->set_mouse_pos(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
|
||||
}
|
||||
else if (ev.type==InputEvent::MOUSE_BUTTON) {
|
||||
last_button_mask = ev.mouse_button.button_mask;
|
||||
}
|
||||
input->parse_input_event(p_ev);
|
||||
}
|
||||
|
||||
|
@ -765,6 +770,7 @@ OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, Get
|
|||
|
||||
gfx_init_func=p_gfx_init_func;
|
||||
gfx_init_ud=p_gfx_init_ud;
|
||||
last_button_mask=0;
|
||||
main_loop=NULL;
|
||||
last_id=1;
|
||||
gl_extensions=NULL;
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
|
||||
Vector<TouchPos> touch;
|
||||
Point2 last_mouse;
|
||||
int last_button_mask;
|
||||
unsigned int last_id;
|
||||
GFXInitFunc gfx_init_func;
|
||||
void*gfx_init_ud;
|
||||
|
|
Loading…
Reference in a new issue