Re: [AD] Android Joysticks (patch)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 12/22/2014 02:36 PM, Trent Gamblin wrote:
The attached patch adds support for a gamepad on Android. It should work on
OUYA, Fire TV, Google Nexus Player, Bluetooth controllers, SHIELD and many
others. It supports two analog sticks, and 6 buttons (A, B, X, Y, L1, R1).
It does not do anything with D-pads as those are treated like
ALLEGRO_KEY_LEFT etc and there's no way to determine if they're coming from
a gamepad or a keyboard on Android.

This adds a second ALLEGRO_JOYSTICK at index 1, in addition to the
accelerometer on index 0. I'd like to support hotplugging and multiple
gamepads with this (possibly before committing) which is possible.

The drawback of this patch and hotplugging is it requires Android 3.1 for
the analog stick code in AllegroSurface.java. Personally I don't think it
matters as it's been a few years since anyone used anything but Android 4.0.
But I'm requesting feedback nonetheless.

I guess you might fix this when you add support for multiple joysticks, but it'd be nice if the 'if (num > 1)' check in andjoy_get_joystick was implemented in terms of `andjoy_num_joysticks`, just to reduce the number of magic constants.

Also, in terms of syntax, there are a few hard tabs inside the added code.

-SL





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/