Created
November 25, 2014 06:12
-
-
Save ansimuz/b84dc5770080f9c5fefa to your computer and use it in GitHub Desktop.
Ouya gamepad untested
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ig.module( | |
| 'game.plugins.ouya-gamepad' | |
| ) | |
| .requires( | |
| 'impact.input', | |
| 'impact.game' | |
| ) | |
| .defines(function(){ | |
| // Assign some values to the Gamepad buttons. We use an offset of 512 | |
| // here so we don't collide with the keyboard buttons when binding. | |
| ig.OUYA_OFFSET = 512; | |
| ig.OUYA = { | |
| AXIS_LS_X: 0+OUYA_OFFSET, | |
| AXIS_LS_Y: 1+OUYA_OFFSET, | |
| AXIS_RS_X: 11+OUYA_OFFSET, | |
| AXIS_RS_Y: 14+OUYA_OFFSET, | |
| AXIS_L2: 17+OUYA_OFFSET, | |
| AXIS_R2: 18+OUYA_OFFSET, | |
| BUTTON_O: 96+OUYA_OFFSET, | |
| BUTTON_U: 99+OUYA_OFFSET, | |
| BUTTON_Y: 100+OUYA_OFFSET, | |
| BUTTON_A: 97+OUYA_OFFSET, | |
| BUTTON_L1: 102+OUYA_OFFSET, | |
| BUTTON_R1: 103+OUYA_OFFSET, | |
| BUTTON_L3: 106+OUYA_OFFSET, | |
| BUTTON_R3: 107+OUYA_OFFSET, | |
| BUTTON_DPAD_UP: 19+OUYA_OFFSET, | |
| BUTTON_DPAD_DOWN: 20+OUYA_OFFSET, | |
| BUTTON_DPAD_RIGHT: 22+OUYA_OFFSET, | |
| BUTTON_DPAD_LEFT: 21+OUYA_OFFSET, | |
| BUTTON_MENU: 82+OUYA_OFFSET, | |
| MAX_CONTROLLERS: 4 | |
| }; | |
| ig.Input.inject({ | |
| ouyaButtonDown: function(button) { | |
| var action = this.bindings[button + ig.OUYA_OFFSET]; | |
| if( action ) { | |
| this.actions[action] = true; | |
| if( !this.locks[action] ) { | |
| this.presses[action] = true; | |
| this.locks[action] = true; | |
| } | |
| } | |
| }, | |
| ouyaButtonUp: function(button) { | |
| var action = this.bindings[button + ig.OUYA_OFFSET]; | |
| if( action ) { | |
| this.delayedKeyup[action] = true; | |
| } | |
| } | |
| }); | |
| // Global callbacks for the OUYA SDK | |
| window.onKeyDown = function(playerNum, button) { | |
| if( !ig.input ) { return; } // game hasn't started yet. nothing to do. | |
| ig.input.ouyaButtonDown( button ); | |
| }; | |
| window.onKeyUp = function(playerNum, button) { | |
| if( !ig.input ) { return; } // game hasn't started yet. nothing to do. | |
| ig.input.ouyaButtonUp( button ); | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment