aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--src/library_sdl.js40
2 files changed, 41 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index 229a9cad..752e7593 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -86,3 +86,4 @@ a license to everyone to use it as detailed in LICENSE.)
* David Barksdale <david.barksdale@adcedosolutions.com>
* Manfred Manik Nerurkar <nerurkar*at*made-apps.biz> (copyright owned by MADE, GmbH)
* Joseph Gentle <me@josephg.com>
+* Douglas T. Crosher <dtc-moz@scieneer.com> (copyright owned by Mozilla Founcation)
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 646aa54c..b64a34ef 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