Guest User

AS3 Gamepad Controls

a guest
Apr 11th, 2017
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.ui.GameInput;
  2.  
  3. var gameInput:GameInput = new GameInput();
  4. this.addEventListener(Event.ENTER_FRAME,update);
  5.  
  6. function update(e:Event):void
  7. {
  8.     if(GameInput.numDevices > 0)
  9.     {
  10.         var gpad = GameInput.getDeviceAt(0); gpad.enabled = true;
  11.         trace("Device: " + gpad.name);
  12.         for(var i = 0; i < gpad.numControls; i++)
  13.         {
  14.             var cont = gpad.getControlAt(i);
  15.             trace(cont.id+" | "+cont.minValue+" | "+cont.maxValue);
  16.         }
  17.         this.removeEventListener(Event.ENTER_FRAME,update);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment