Airxbc Update

Woohoo! I finally had time to sit down and update the Airxbc native extension for Windows! If you aren't familiar with the extension, it allows you to accept input via an Xbox 360 controller for your Adobe AIR games.

With this latest release, my major goal was to wrap up the controller definition in a real class. If you'll recall, the original version simply gave back a generic ActionScript object. The new version returns a com.rhuno.X360Gamepad object that wraps up a lot of the controller functionality nicely, exposes some helpful methods and contains some constants for controller buttons. New functionality includes the ability to check if a button was just released and also to get the trigger values as a percentage or as a value. Below is an example of how to use the new extension.

import com.rhuno.Airxbc;
import com.rhuno.X360Gamepad;

var ext:Airxbc = new Airxbc();
var gpad:X360Gamepad;

// pollGamePad now returns an X360Gamepad object
gpad = ext.pollGamePad();

// various ways of checking for button presses

// ways of checking for button releases

// get trigger value
var value:int = gpad.leftTrigger;

// get trigger percentage (0 thru 1)
var percent:Number = gpad.leftTriggerAsPercent;

// NOTE: you still use the extension to set vibration
ext.setVibration(30000, 30000);

You can download an updated example project and the new ANE below. Enjoy!

NOTE: This post is out of date, for latest on Airxbc, go here!

Airxbc 0.9 example project
Airxbc 0.9 ANE

Bookmark and Share

6 Responses to “Airxbc Update”

  1. DeVNull says:

    Cool thing, got it running.

    How can I add a “_gamepad.wasAPressed())” check to the class? (so it doesn’t autofire or retrigger)

    Quite handy to have that to only check whether the key was just pressed. I could work around it by using my own boolean for it but I thought that could get messy so why not ask if you could stick that in there too? =)

    What’s the licence? Free to use?

    Thanks a lot!

  2. Rhuno says:

    You could use wasAReleased to fire on the button up event or, as you mentioned, you could create a boolean. Set it to true if isAButtonDown returns a non-zero value, and then reset it to false if that function returns 0.

    It is free to use; thanks for checking it out.

  3. DeVNull says:

    Yeah, thats what I thought. I built it into my flixel game and flixel has that state and I thought I might mention it.

    Another thing for practical use would be the check if there is a controller connected at all (at the moment you just check if an instance of the extension has loaded, am I right?) because then I could skip the controller handling on systems without (important for the menu navigation too)

    Seriously cool stuff man! I was looking for ages for something like this! Annoying that the official Gameinput for AIR is currently TV profile only =/

    But this seems like THE solution atm so all thanks to you!

  4. Rhuno says:

    Definitely good feedback! I’ll see about putting it in the next release and the same goes for checking for connected controllers.

    Currently the pollGamePad function will throw an error if no controllers are connected. When you’re initializing the game, you could make a call to the function and wrap it in a try/catch. If it errors on you, you could set a global/static variable for whether or not to handle controller input.

    It may not be the best solution, but it is a serviceable work around for the time being. It’s probably not a bad idea to wrap a call to pollGamePad in a try/catch block anyway in case the user removes the controller during gameplay.

  5. DeVNull says:

    Oh, sorry.

    _ext = new Airxbc();
    if (_ext)

    does the check, right?

  6. DeVNull says:

    ah cool, yeah. I’ll do that. Thanks! (Sorry I’m an Artist coding – hehe)

Leave a Reply

Subscribe to RSS feed FGS5 Badge