Skip to main content
Participant
July 4, 2013
Question

GameInput.DEVICE_ADDED not getting called

  • July 4, 2013
  • 1 reply
  • 944 views

Why does GameInput DEVICE_ADDED never get called on my OUYA Air application? 

I have made everything static.  GameInput.isSupported is true and GameInput.numDevices is 1.  Are there any other possibilities?

                    public static var gameInput:GameInput;

                    private static var _device:GameInputDevice;

 

                    public function GameController(stage:MovieClip)

                    {

                              this.stage = stage;

                              stage.stage.addEventListener(Event.ENTER_FRAME, onFrame);

                              stage.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey);

                              stage.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);

 

                              Main.trace("" + GameInput.isSupported);

                              Main.trace("" + GameInput.numDevices);

 

                              gameInput = new GameInput();

                              gameInput.addEventListener(GameInputEvent.DEVICE_ADDED, handleDeviceAttached);

                              //gameInput.addEventListener(GameInputEvent.DEVICE_REMOVED, handleDeviceRemovedEvent);

 

                              keyboardController = new KeyboardController();

                    }

 

                    protected static function handleDeviceAttached(e:GameInputEvent):void

                    {

                              Main.trace("Device is added\n");

                              GameInputControlName.initialize(e.device);

 

 

                              for(var k:Number=0;k<GameInput.numDevices;k++){

                                        _device = GameInput.getDeviceAt(k);

                                        var _controls:Vector.<String> = new Vector.<String>;

                                        _device.enabled = true;

 

                                        for (var i:Number = 0; i < _device.numControls; i++) {

                                                  var control:GameInputControl = _device.getControlAt(i);

                                                  control.addEventListener(Event.CHANGE,onChange);

                                                  _controls = control.id;

                                        }

 

                                        _device.startCachingSamples(30, _controls);

                              }

 

                              for(var j:int=0; j<_controls.length; j++)

                              {

                                        Main.trace(""+_controls);

                              }

 

                              //stage.addEventListener(Event.ENTER_FRAME, getCachedSamples);

                    }

 

                    protected static function onChange(event:Event):void

                    {

                              var control:GameInputControl = event.target as GameInputControl;

                              Main.trace("" + control.name);

                              Main.trace("" + control.value);

                    }

Thanks!

Chris

This topic has been closed for replies.

1 reply

Adobe Employee
July 4, 2013

Could you please share the platform, OS version you are using. I have attached .apk at https://www.dropbox.com/sh/0e4tef1wh1zdhlj/xozQLrNJJE and a sample project which is using GameInputEvent.DEVICE_ADDED listener, you can give a try once and see if this will resolve your issue.

Regards,

Nimit

Participant
July 4, 2013

Thank you so much for your reply, Nimit!

I'm compiling on Windows 7 Home Premium, using Flex 4.6 and Air SDK 3.8.

I tried to install the provided APK to my OUYA - when I run it from "Make/Software" it simply gives me a blank, black screen and does nothing.

Thanks,

Chris