AIR Controller Tester

A tester for testing controllers with AIR!

Now running at a smooth 60 frames per second!


Project maintained by brettchalupa Hosted on GitHub Pages — Theme by mattgraham

Welcome to AIR Controller Tester

This is still 100% a work in progress.

Download

Download v0.2.1 of the Controller Input Tester

Features

TODO

Using a Controller With Your AIR Project

This would be your best bet:
An entire post dedicated to adding controller support to your AIR game.

Text Walkthrough:

This tutortial assumes you already have an AIR application setup in FlashDevelop with the proper batch files. If you don't, simply create a new project as an AS3 AIR Projector and go from there.

  1. Download joy-query-flashdevelop.zip
  2. Unzip the file
  3. Drag the lib/ and extension/ folder into the root directory of the AIR FlashDevelop project
  4. Expand the lib folder in FlashDevelop, and right click on joyquery.swc
  5. Select "Add to Library"
  6. Right click on joyquery.swc again
  7. Select "Options..."
  8. In options, select "External Library" and press "OK"
  9. Open the application.xml
  10. Add the following lines of code right before the closing application tag: extendedDesktop extension.JoyQuery.Joystick
  11. Open the Run.bat file
  12. In the line that looks like adl "%APP_XML%" "%APP_DIR%", add -extdir extension/debug/ at the end
  13. Open the bat/Packager.bat file
  14. In the line that looks like adl "call adt -package %OPTIONS% %SIGNING_OPTIONS% -target native %AIR_TARGET% %APP_XML% %FILE_OR_DI, add -extdir extension/release/ at the end
  15. Open PackageApp.bat
  16. In the line that says set AIR_TARGET= change it to set AIR_TARGET=air/ProgramName.exe, where ProgramName is the name of your game!
  17. Open the source code of the game where you want to add joystick support, this could be in your Player class, Input class or wherever really
  18. At the top of your class, you need to import the JoyQuery extension. Add import extensions.JoyQuery.Joystick;
  19. Right before your class constructor, create a variable of type Joystick, it should look something like private var joystick:Joystick = new Joystick();
  20. This is important - you need to call joystick.JoyQuery() at the beginning of every update. This checks for any controller changes or button presses
  21. Use the API below for different calls on your Joystick object. An example would be joystick.buttonIsDown(0, 0), checking to see if Button 1 (Index 0) is being pressed on Controller 1 (Index 0)
  22. If your program executes nicely when you press the Play button or press F5, you're almost there! The next step is to right click on PackageApp.bat and select "Execute" (or just double-click if you're in Windows Explorer). This should created your exe in the air/ directory. You should be good to go! Install it, try it, and enjoy it. :)
The source for that step-by-step walkthrough can be found right here, on github. If you got lost in a step on the walkthrough or it wasn't clear enough, that should give you a little bit more context. :)

The rest is up to you! For the analog controls, I'd suggest setting thresholds or making your movement based upon the analog value of the stick. If you are having trouble figuring out the values for a controller, use AIR-Controller-Tester.

JoyQuery 2.0 API's

Class path: (import extension.JoyQuery.Joystick;) extension.JoyQuery.Joystick

Joystick() Constructor public function Joystick()

Creates a new Joystick instance.

JoyQuery() method public function JoyQuery():void

Query the joysticks to update their possitions for the other functions. Best to call this on an ENTER_FRAME event.

getTotal() method public function getTotal():Number

Returns the total number of connected joysticks.

buttonIsDown() method public function buttonIsDown(joystickNum:Number, buttonNum:Number):Boolean

Returns true if the selected joystick number and button number is down, false if it is up.

getAxis() method public function getAxis(joystickNum:Number, axisNum:Number):Number

Returns the position selected joystick number and axis number. Ranges from -1 to 1.

getTotalButtons() method public function getTotalButtons(joystickNum:Number):Number

Returns the total number of buttons on the selected joystick.

getTotalAxes() method public function getTotalAxes(joystickNum:Number):Number

Returns the total number of axes on the selected joystick.

About

AIR Controller Tester is exactly what it sounds like, an AIR application that is used to get the input values of different buttons and axes of Joysticks. This is useful for figuring out input thresholds and what buttons you need to be checking for.

This currently only support Windows. I'd love to get a Mac (and Linux) version working soon.

AIR Controller Tester uses JoyQuery 2.0 as an extension to support native controller input.

My name is Brett Chalupa, and I want to play all my favorite Flash games with controllers. If you want to integrate this into your game, send me an email. I am working on creating a video and text tutorial for getting it working with FlashDevelop 4.0, Flixel/FlashPunk. If I am too slow for you, just let me know and I can give you all the secrets early.

Thanks