Hi!
I'm fairly new to messing with WebAssembly, so sorry for any inacuracy or misunderstanding on my part.
I compiled a fairly simple raylib game with emscripten and tried emedding it in a blog article. Everything worked fine, except that the game was grabbing all browser events, so when ie scrolling the page up or down with the arrow keys, the game would also respond to the same inputs, which quickly got annoying.
Digging in, I found out that the js wrapper generated was attaching some event listeners to the window object, and some others to the canvas (see
|
window.addEventListener('gamepadconnected', GLFW.onGamepadConnected, true); |
). I attached them all to the canvas and this fixed my issue.
Once again, I'm pretty clueless about this environment, so I don't want to presume there's not a good reason why those get set on the window, but I thought I'd mention it in case my hack is considered acceptable. And if not, is there some cleaner way to override the behaviour without messing with the generated wrapper ?
Thanks,
Raphi.
Hi!
I'm fairly new to messing with WebAssembly, so sorry for any inacuracy or misunderstanding on my part.
I compiled a fairly simple raylib game with emscripten and tried emedding it in a blog article. Everything worked fine, except that the game was grabbing all browser events, so when ie scrolling the page up or down with the arrow keys, the game would also respond to the same inputs, which quickly got annoying.
Digging in, I found out that the js wrapper generated was attaching some event listeners to the window object, and some others to the canvas (see
emscripten/src/lib/libglfw.js
Line 1432 in 926047d
Once again, I'm pretty clueless about this environment, so I don't want to presume there's not a good reason why those get set on the window, but I thought I'd mention it in case my hack is considered acceptable. And if not, is there some cleaner way to override the behaviour without messing with the generated wrapper ?
Thanks,
Raphi.