Is it possible to detect the brand/name/etc. of gamepad?

56 views
Skip to first unread message

BluShine

unread,
May 13, 2015, 3:34:38 AM5/13/15
to haxef...@googlegroups.com
So, I've been working on adding gamepad support to a local multiplayer game. I've been making my own custom mappings for some of the unsupported controllers I own (mostly USB adapters for retro consoles, and USB retro controller replicas). Right now, I let the player toggle between different controller mappings by pressing any button on the controller. I'm also planning on having a screen to manually map controllers.

But ideally, I'd have some way to detect why type of controller is plugged-in and automatically apply some button-mappings. As far as I can tell, this isn't currently possible, but maybe I'm missing something. Any ideas or tips? If I was to hack in support, what would be a good place to start (I assume I'd have to go to some lower-level library and not Flixel). Or maybe I should just stick to the mapping/preset approach?

Chase de Languillette

unread,
May 14, 2015, 3:52:38 PM5/14/15
to haxef...@googlegroups.com
I found this in FlxGamepad.hx, which might help steer you in the right direction - 

public function getYAxis(AxisID:Int):Float
{
var axisValue = getAxisValue(AxisID);
// the y axis is inverted on the Xbox gamepad in flash for some reason - but not in Chrome!
// WARNING: this causes unnecessary string allocations - we should remove this hack when possible.
#if flash
if ((_device != null) && _device.enabled && (_device.name.indexOf("Xbox") != -1) && 
  (Capabilities.manufacturer != "Google Pepper"))
{
axisValue = -axisValue;
}
#end
return axisValue;

Gama11

unread,
May 14, 2015, 5:47:45 PM5/14/15
to haxef...@googlegroups.com, chase.dela...@gmail.com
The gamepad name is currently only available on flash afaik.
Reply all
Reply to author
Forward
0 new messages