diff --git a/hotkeys.js b/hotkeys.js
index b5bd466..1423c1b 100644
--- a/hotkeys.js
+++ b/hotkeys.js
@@ -157,3 +157,62 @@ resetCameraRot = function()
camera.rotation.y = 0;
camera.rotation.z = 0;
}
+
+
+
+
+/* Gamepad binding */
+
+var gamepad = new Gamepad();
+
+console.log('binding down');
+gamepad.bind(Gamepad.Event.BUTTON_DOWN, function(e) {
+ switch(e.control){
+ case 'Y':
+ game.BARS.toggleWireframe();
+ break;
+ case 'X':
+ game.BARS.toggleWireframe();
+ break;
+ case 'B':
+ console.log('color shift');
+ game.BARS.colorset.push(game.BARS.colorset.shift());
+ for(var xpos = 0; xpos < 12; xpos++ ){
+ game.BARS.objects[xpos].material = new THREE.MeshBasicMaterial( { color: game.BARS.colorset[xpos], wireframe: false, wireframeLinewidth: 3, overdraw: true } );
+ }
+ break;
+ case 'BACK':
+ window.location = window.location;
+ break;
+ }
+});
+
+gamepad.bind(Gamepad.Event.BUTTON_UP, function(e) {
+ switch(e.control){
+ case 'X':
+ game.BARS.toggleWireframe();
+ break;
+ case 'RB':
+ for(b in game.BARS.objects) {
+ game.BARS.objects[b].rotation.x += b/game.BARS.objects.length;
+ }
+ break;
+ case 'LB':
+ for(b in game.BARS.objects) {
+ game.BARS.objects[b].rotation.x -= b/game.BARS.objects.length;
+ }
+ break;
+ case 'DPAD_UP':
+ game.BARS.rotation.speed += 0.01;
+ break;
+ case 'DPAD_DOWN':
+ game.BARS.rotation.speed -= 0.01;
+ break;
+ case 'DPAD_RIGHT':
+ camera.orbit.speed += 10;
+ break;
+ case 'DPAD_LEFT':
+ camera.orbit.speed -= 10;
+ break;
+ }
+});
diff --git a/index.html b/index.html
index 51f5557..e612301 100644
--- a/index.html
+++ b/index.html
@@ -17,6 +17,7 @@
+
@@ -53,9 +54,13 @@
blackAndWhite: false,
colorSetNumber: 0
}
-
+
$(document).ready(function()
{
+ if (!gamepad.init()) {
+ alert('Your browser does not support gamepads, get the latest Google Chrome or Firefox.');
+ }
+
init();
animate();
})