Android: Fixes for iPega PG-9017 support

Hello,

Some small fixes to improve autodetection of iPega PG-9017 bluetooth controller in RetroArch Android.

This comes with a small question: In general, I think most bluetooth controllers look similar to a SNES controller. When autodetecting them, do you generally assign buttons in the SNES layout? For example, look at this screenshot:

http://img.dxcdn.com/productimages/sku_172963_9.jpg

You will see the iPega has the X button to the left of Y, and A to the left of B. This is the opposite of SNES layout. In my change, I have made sure that the physical buttons are laid out like in the SNES, so the button labeled X on the iPega is actually mapped to the Y button input in RetroArch, so that the SNES emulator sees it as the Y button. I think that's what you did for other controllers too.

But what happens for example with the Genesis emulators? If you treat every controller as having an SNES layout, where do the Genesis A, B and C buttons fall on an SNES controller?

It's a minor thing, and I've tried a Genesis game or two and it seems A=SNES_Y, B=SNES_B and C=SNES_A, which is logical and comfortable, but I just wanted to make sure that was the intention and that it works for all controllers.

Back to my change. I fixed two small bugs that affected the selection of iCade profiles when a device called "Broadcom Bluetooth HID" was detected. There were two separate off-by-one errors that meant that to use the iPega on the first detected pad, iCade profile for pad 3 had to be set to iPega! :-)

I also fixed the button assignments as mentioned above to match the SNES physical layout. And I added some logging and an accurate controller name when detecting generic "iCade profile" controllers, so we know a bit more what's going on.

With those fixed, I can use my iPega by setting iCade profile for pad 1 to "iPega PG-9017". The last thing that doesn't work is the d-pad, I mention that in a comment in my code change. I don't know how to fix that, because when I turn on input debugging, I see that the d-pad seems to be sending motion events (it goes in the `if (type_event == AINPUT_EVENT_TYPE_MOTION)` branch) but with an axis value of 0 for every axis. No button events are sent, whether using the autodetection or a custom mapping. I don't understand that at all, because in other emulators on Android (for example SNESdroid) I can do custom mapping, set the values for the dpad buttons, and they work fine. Note that even in RetroArch, the dpad works well when in the ROM selection interface, just not when in a libretro core. That kind of hints to some setting being changed when the libretro core is loaded, leading to the dpad sending motion events instead of button press events? Or the Android API converting the dpad's button events to motion events behind our back before sending the events to our app? I don't know enough about how Android interfaces with the controller to know what that might be. But it's a major bummer!

Last thing: Actually I think it may be more accurate to change the term "iCade profile" to "generic bluetooth controller profile", because iCade is used for other things (among others, the iPega has an iCade-specific mode) and using the term iCade there might lead to some confusion (users thinking they need to use the iPega in iCade mode, which is not the case). But I'll leave that open for discussion, it can be modified later if you agree to change the term.

So here are the changes, let me know if you have any comments or want me to change anything.


`android/native/jni/input_android.c`:

- Fixed off-by-one when using g_settings.input.icade_count to index in array of icade profiles. It has just been incremented...
- Added setting actual device names instead of generic "Broadcom Bluetooth HID" so the libretro menu shows it. Also added a bit of logging when detecting generic devices and selecting an icade profile.
- Fixed some wrong button assignments for iPega controller.
- Added a note about the dpad buttons not working, it's the next thing I want to fix.

`android/phoenix/res/xml/prefs.xml`:

- Fixed key names for icade profiles, input_autodetect_icade_profile_pad0 does not exist in the config as given in the root settings.c file, they start at 1.