aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas T. Crosher <dtc-moz@scieneer.com>2013-07-10 22:47:54 +1000
committerDouglas T. Crosher <dtc-moz@scieneer.com>2013-07-10 22:47:54 +1000
commitf3f2eabd377c84860934cca9f8057cc77b98cf5c (patch)
tree9bc2022bda9dc287d169581e27545c9d1c195987 /src
parent4158ce9871d88c2856fe2d47a85ea283e534c7bc (diff)
Add basic touch support that translates to mouse events.
Diffstat (limited to 'src')
-rw-r--r--src/library_sdl.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 176a2fae..ce98ce5c 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -361,8 +361,48 @@ var LibrarySDL = {
SDL.surfaces[surf] = null;
},
+ touchX:0, touchY: 0,
+
receiveEvent: function(event) {
switch(event.type) {
+ case 'touchstart':
+ event.preventDefault();
+ var touch = event.touches[ 0 ];
+ touchX = touch.pageX;
+ touchY = touch.pageY;
+ var event = {
+ type: 'mousedown',
+ button: 0,
+ pageX: touchX,
+ pageY: touchY
+ };
+ SDL.DOMButtons[0] = 1;
+ SDL.events.push(event);
+ break;
+ case 'touchmove':
+ event.preventDefault();
+ var touch = event.touches[ 0 ];
+ touchX = touch.pageX;
+ touchY = touch.pageY;
+ event = {
+ type: 'mousemove',
+ button: 0,
+ pageX: touchX,
+ pageY: touchY
+ };
+ SDL.events.push(event);
+ break;
+ case 'touchend':
+ event.preventDefault();
+ event = {
+ type: 'mouseup',
+ button: 0,
+ pageX: touchX,
+ pageY: touchY
+ };
+ SDL.DOMButtons[0] = 0;
+ SDL.events.push(event);
+ break;
case 'mousemove':
if (Browser.pointerLock) {
// workaround for firefox bug 750111