aboutsummaryrefslogtreecommitdiff
path: root/src/library_glut.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-06 10:15:24 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-06 10:15:24 -0700
commitece05869dba8c7d2fe28612f2e535c2bfdb9447e (patch)
tree403288d63bbc7cbb424781a2746b7c0646545210 /src/library_glut.js
parentdc898cd7f2287766d47fd7fad1e66bdad8ec5f17 (diff)
parent096b56b5c5432d022e7e1a011609c727de12e591 (diff)
Merge pull request #349 from prenaux/develop
to incoming: Added GLUT.glutMotionFunc ; GLUT.getSpecialKey handles modifier keys ;
Diffstat (limited to 'src/library_glut.js')
-rw-r--r--src/library_glut.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/library_glut.js b/src/library_glut.js
index 5d9fb672..d538cc7a 100644
--- a/src/library_glut.js
+++ b/src/library_glut.js
@@ -36,6 +36,15 @@ var LibraryGLUT = {
},
onMousemove: function(event) {
+ /* Pierre: Send motion event only if the motion changed, prevents
+ * spamming our app with uncessary callback call. It does happen in
+ * Chrome on Windows.
+ */
+ var newX = event['clientX'] - Module['canvas'].offsetLeft;
+ var newY = event['clientY'] - Module['canvas'].offsetTop;
+ if (newX == GLUT['lastX'] && newY == GLUT['lastY'])
+ return;
+
GLUT.savePosition(event);
if (GLUT.buttons == 0 && event.target == Module["canvas"] && GLUT.passiveMotionFunc) {
event.preventDefault();
@@ -72,6 +81,30 @@ var LibraryGLUT = {
case 0x24 /*DOM_VK_HOME*/: key = 106 /* GLUT_KEY_HOME */; break;
case 0x23 /*DOM_VK_END*/: key = 107 /* GLUT_KEY_END */; break;
case 0x2d /*DOM_VK_INSERT*/: key = 108 /* GLUT_KEY_INSERT */; break;
+
+ case 16 /*DOM_VK_SHIFT*/:
+ case 0x05 /*DOM_VK_LEFT_SHIFT*/:
+ key = 112 /* GLUT_KEY_SHIFT_L */;
+ break;
+ case 0x06 /*DOM_VK_RIGHT_SHIFT*/:
+ key = 113 /* GLUT_KEY_SHIFT_R */;
+ break;
+
+ case 17 /*DOM_VK_CONTROL*/:
+ case 0x03 /*DOM_VK_LEFT_CONTROL*/:
+ key = 114 /* GLUT_KEY_CONTROL_L */;
+ break;
+ case 0x04 /*DOM_VK_RIGHT_CONTROL*/:
+ key = 115 /* GLUT_KEY_CONTROL_R */;
+ break;
+
+ case 18 /*DOM_VK_ALT*/:
+ case 0x02 /*DOM_VK_LEFT_ALT*/:
+ key = 116 /* GLUT_KEY_ALT_L */;
+ break;
+ case 0x01 /*DOM_VK_RIGHT_ALT*/:
+ key = 117 /* GLUT_KEY_ALT_R */;
+ break;
};
return key;
},