Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Locked

OUYA controller support

New Here ,
Jun 26, 2013 Jun 26, 2013

Copy link to clipboard

Copied

Hello,

I'm using the GameInput class on OUYA to use the controllers. When calling GameInput.numDevices, I get 1 (for the controller I have connected), but when asking GameInput.getDeviceAt(0), I get a null.

I've tried with AIR 3.7 and 3.8 beta. Is there anything I can do to fix this?

Thank you in advance!

TOPICS
Air beta

Views

6.4K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Jun 26, 2013 Jun 26, 2013
Could you please share your code. Could it be that the GameInput object is goiing out of scope and garbage collected?

Likes

Translate

Translate
Explorer ,
Aug 22, 2013 Aug 22, 2013

Copy link to clipboard

Copied

Yep, even a 1ms delay will prevent the DEVICE_ADDED from being fired. Basically, a Frame 1 thing I guess...

It's good that there's a workaround, but clearly a bug within the GameInput API, if numDevices = 1, getDeviceAt(0) should obviously not be getting GC'd.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 22, 2013 Aug 22, 2013

Copy link to clipboard

Copied

Wow, I'm seeing HUGE performance issues coming from GameInput.

http://f.cl.ly/items/120o150g3d3s0S2H220p/Image%202013-08-22%20at%203.51.49%20PM.png

The red spikes are a TIMER event, seemingly coming from GameInput. The Red line is my Frame Budget of 16ms... you guys are using 65ms inside your Timer handler...  if anyone is counting, that's 4 entire frames dropped.

This manifests in-game as a horrible jerkiness, every 1 second, my game skips a beat and all characters jump into different positions.

It seems to only happen on Desktop, which is a bit of a saving grace I suppose.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 22, 2013 Aug 22, 2013

Copy link to clipboard

Copied

Ohhh that's great to know. Thanks for the research guys! There's a few ways I think I can work around this on my code, will have to try it out. Trying to avoid explicity calling it in my document class, will try in the static initializer of a class.

About the timer/delays: yes it's a ridiculous waste of CPU. And yes it's only in the desktop version (thankfully). Adobe is aware of the problem but nothing has been done so far I think.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 22, 2013 Aug 22, 2013

Copy link to clipboard

Copied

Thanks zeh, I found your class this morning and it's brilliant! After instanciating it in my document class, everything works great.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 23, 2013 Aug 23, 2013

Copy link to clipboard

Copied

@shawnb81: you killed it, that was exactly the problem. If the GameInput listening instance is not initialized in frame 1 (maybe it's a timing thing), it never works. It doesn't dispatch events, and the device list is never valid.

---

If you're interested, I've updated my KeyActionBinder class to help somewhat with that. The problem is still there, but at least now the GameInput listener instance is created on a static initializer. That means that you don't have to necessarily create a KeyActionBinder instance, but merely refer to it. On my game prototype, I simply have this in my SWF document class:

// Refer to input binding class to force initialization
KeyActionBinder;

And now it works. It's hacky but... it's something until it's fixed.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2013 Aug 23, 2013

Copy link to clipboard

Copied

Nice, I decided to add a static initialization function to your class, that I just call in my Constructor.

Btw, where did yhour Donate button go?? I wanted to show my appreciation with some free beers

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 20, 2014 Jan 20, 2014

Copy link to clipboard

Copied

LATEST

I recently tried using GameInput in a single frame .FLA (with no Document Class), compiled with Flash CS6 and Adobe AIR 4.0.0.1390 set as target, and tested by side loading with adb to NVIDIA Shield, and the GameInputEvent.DEVICE_ADDED event was not being fired when the GameInput instance and GameInputEvent listeners were placed in a function such as start() that was being triggered later by user interaction.

I too have confirmed during my own testing that GameInput must be instantiated (along with GameInputEvent listeners added to it) on the first frame, or the event does not fire...

By moving the code immediately after the imports, it started working as expected:

import flash.display.*;

import flash.events.*;

import flash.system.Capabilities;

import flash.ui.*;

 

gameInput = new GameInput();

gameInput.addEventListener(GameInputEvent.DEVICE_ADDED, deviceCheck);

gameInput.addEventListener(GameInputEvent.DEVICE_REMOVED, deviceCheck);

If you are using a Document Class, make sure it's in the Document Class constructor.

If you aren't using a Document Class, make sure it's on frame 1 immediately after your imports.

And Zeh, nice job with your GameInput testing interface and KeyActionBinder library — super awesome work!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
    • 1
    • 2