Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 09:18:30 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)NativeJoystick: AIR “ANE” extension to support all joysticks that Windows can.
Pages: [1]
Print
Author Topic: NativeJoystick: AIR “ANE” extension to support all joysticks that Windows can.  (Read 1683 times)
Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« on: August 25, 2014, 10:35:25 AM »

Adobe GameInput API is a terrible f*cking sh*t.

First I used StackAndHeap's joystick ANE which is OK but I had to rebuild the dll in release mode to avoid debug dependencies and fix some crashing errors on the AS3 side. It was fine until I needed a fourth axis which wasn't supported.

So I decided to make one from scratch and document the process. 2bam's NativeJoystick ANE now supports any device that Windows detects, with up to 6 axes and 32 buttons. Even with same product/manufacturer ID & USB-serial number as most cheap controllers have. It's not just that I'm a cheap bastard, which I am, but also I believe in inclusion of people which can't afford an Xbox controller and also useful for installations in which controllers tend to break often and become a deal of an investment.

Features
  • Static runtime libs for DLL, release-mode, no dependencies besides system and small size.
  • Not "new"ing anything for each poll, nor dispatching events unless you actually add event listeners.
  • 16 controllers, 6 axes/32 buttons when available
  • Find OEM joystick name in registry.
  • Open source, MPL2.0 licensed

Open source
The library and source can be found on github (links here).

The license is mostly MPL2.0 (except some code from Adobe and FreeGlut) and the graphics are CC-0 (Public domain dedication)

Tutorial
I've collected the experience in screenshots and text for a "Windows ANE from scratch" tutorial.
Still needs some polishing, so it will be released in a couple of weeks.

Logged

Working on HeliBrawl
TheLastBanana
Level 9
****



View Profile WWW
« Reply #1 on: August 26, 2014, 12:46:00 PM »

Super cool. I'll probably give this a shot whenever I get back to working on my game. I somewhat recently implemented controller support, but I was a little worried about non-Xbox controllers... until now! Smiley
Logged
Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #2 on: September 25, 2014, 06:10:13 PM »

Sure Smiley

I found out joystick polling took too much time from using Adobe Scout (profiling). Then tried some profiling on the C++ side.
When there was at least one Xbox360 controller plugged in, at least the first four unconnected joysticks indexes took 3000% the time to poll (approx. 15ms vs 0.5ms). Let me stress out, the unconnected ones took 30x the time.

This seems to be a known issue, so I made a bugfix/workaround:
Poll one unplugged/error joystick only every 312 ms (For 33ms poll intervals, roughly once every 9 polls).
Will take aprox. 5 seconds to detect a joystick in Windows (supports 16) but avoid killer framerate drops.

Logged

Working on HeliBrawl
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic