aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2012-05-18 17:29:04 -0400
committerEhsan Akhgari <ehsan.akhgari@gmail.com>2012-05-22 15:44:16 -0400
commita431ee57217c68ecbf47eb8932d09718c38e0cc9 (patch)
tree95d50b786406151cf5c00239ba9231ec055aa542
parent1be33be6cab36fd056feb812bcc4999682b3425f (diff)
Save the state of the mouse button as we're creating a C event for it
-rw-r--r--src/library_sdl.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index eac68600..85a04d27 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -293,13 +293,6 @@ var LibrarySDL = {
pageX: event.pageX,
pageY: event.pageY
};
- } else if (event.type == 'mousedown') {
- // SDL_BUTTON(x) is defined as (1 << ((x)-1)). SDL buttons are 1-3,
- // and DOM buttons are 0-2, so this means that the below formula is
- // correct.
- SDL.buttonState |= 1 << event.button;
- } else if (event.type == 'mouseup') {
- SDL.buttonState = 0;
}
SDL.events.push(event);
if (SDL.events.length >= 10000) {
@@ -357,7 +350,17 @@ var LibrarySDL = {
break;
}
- case 'mousedown': case 'mouseup': case 'mousemove': {
+ case 'mousedown': case 'mouseup':
+ if (event.type == 'mousedown') {
+ // SDL_BUTTON(x) is defined as (1 << ((x)-1)). SDL buttons are 1-3,
+ // and DOM buttons are 0-2, so this means that the below formula is
+ // correct.
+ SDL.buttonState |= 1 << event.button;
+ } else if (event.type == 'mouseup') {
+ SDL.buttonState = 0;
+ }
+ // fall through
+ case 'mousemove': {
var x = event.pageX - Module['canvas'].offsetLeft;
var y = event.pageY - Module['canvas'].offsetTop;
if (event.type != 'mousemove') {