Dive Board



Gamepad Support

Gamepad Support

by Sephiroth on May 2nd, 2014 11:40 AM

Carrying on the post from here in a seperate thread.

I've been testing the InControl plugin for Unity (there is a free version on GitHub as well if you Google it but Asset Store is convenient and supports the developers :) )

Really nice plugin but turns out Android support in it is a bit lacking. It works by detecting the gamepad's name, then searches an array for a closely matching name to load the keymapping for the device. Though from what I can see so far by default it only has mapping for a 'generic' bluetooth gamepad on Android phones/tablet. For some reason the Moga Pro has mapping for Windows, Mac, Linux and OUYA but not Android phones/tablets, which is really weird.

Fortunately it is really easy to add new profiles. The generic mapping seems like a good catch-all, but it is worth writing mapping for specific controllers. I should be able to add Moga, iDroid:con,PS3,PS4 and xbox 360 support to it. Any other gamepad suggestions?

Sephiroth

Posts: 45

Joined: 17.03.2014

dive-owner


Re: Gamepad Support

by jpslara on May 2nd, 2014 17:32 PM

Hi, i will check to prepare a map for generic usb gamepad as soon as i return on vacation, for this moment i only have a little phone conection and it is almost imposie to do anything from here.

jpslara

Posts: 80

Joined: 27.12.2013

dive-owner


Re: Gamepad Support

by Sephiroth on May 2nd, 2014 22:54 PM

Turns out the chinese PS3 clone I had was a really bizarre mapping and identified itself as "hid-keyboard" even though it wasn't simulating a keyboard. I've added it to my copy of InControl and have also added one that should work for the iDroid:con but I need to know what the controller identifies itself as.

I've made a gamepad simulator to help test the mappings which can be downloaded here -> https://www.mediafire.com/?5f9o9l2lvwmlb56



The first line shows what the controller identifies itself as. I need to know this to assign the mapping to it.

The second line shows which mapping profile InControl is using for the controller.

The third line is the identity of the button pressed to help map it if it isn't recognised properly.

The buttons turn green when it detects they have been pressed.

If anyone has an iDroid or any other controller they want to test or have mapped give the app a go and let me know :) This should work well for giving us a more or less universal gamepad compatibility.

So far I have the Moga Pro and the weird generic PS3 type controller confirmed as working, and the iDroid may work too.

Sephiroth

Posts: 45

Joined: 17.03.2014

dive-owner


Re: Gamepad Support

by jpslara on May 4th, 2014 11:45 AM

JoystickCodes.pngHi, I am using a generic cheap USB gamepad named PRITECH
using program Key Test Android, I get those codes. This gamepad have not power button, but in these place there are a button named "ANALOG", on PC When this button is active, those joysticks work as analog ones, if this is not active,
the joysticks work as buttons 1,2,3,4, the right joystick, and as up,down, left, right
the left Joystick. On android it look like left joystick always work as buttons,
and left joystick only work when analog is not active.

button Keycode scancode metacode flags DISPID joystickbutton
1 -> 188 KEYCODE_BUTTON_1 288 0 0x8 0 15
2 189 KEYCODE_BUTTON_2 289 0 0x8 0 16
3 190 KEYCODE_BUTTON_3 290 0 0x8 0 17
4 191 KEYCODE_BUTTON_4 291 0 0x8 0 18
UP 19 KEYCODE_DPAD_UP 0 0 0x400 -1
DOWN 20 KEYCODE_DPAD_DOWN 0 0 0x400 -1
LEFT 21 KEYCODE_DPAD_LEFT 0 0 0x400 -1
RIGHT 22 KEYCODE_DPAD_RIGHT 0 0 0x400 -1
RFU(R1) 192 KEYCODE_BUTTON_5 292 0 0x8 0 19
RFD(R2) 194 KEYCODE_BUTTON_7 294 0 0x8 0
RFT(R3) 198 KEYCODE_BUTTON_11 298 0 0x8 0
LFU(L1) 193 KEYCODE_BUTTON_6 293 0 0x8 0
LFD(L2) 195 KEYCODE_BUTTON_8 295 0 0x8 0
LFT(L3) 199 KEYCODE_BUTTON_12 299 0 0x8 0
SELECT 196 KEYCODE_BUTTON_9 296 0 0x8 0
START 197 KEYCODE_BUTTON_10 297 0 0x8 0

the program GamapadTest see all buttons keycodes from this gamapad.

Now, In my test with Unity and this gamepad, I get only pressed buton 1,2,3,4 and L1
in may gamepad button 1,2,3,4 are buttons on the right cross (and with right joystick you get same codes)
Buttons up,down,rigth,left and left joystic work, but you don't get any code.

Your application only detect buttons 1,2,3,4 and L1 as JoystickButton15, JoystickButton16, JoystickButton17, JoystickButton18 and JoystickButton19

There are something that I don't understand, why Unity only detect some of the buttons, when other android programs show scancodes for all buttons.

jpslara

Posts: 80

Joined: 27.12.2013

dive-owner


Re: Gamepad Support

by Sephiroth on May 5th, 2014 11:26 AM

What does "Found" and "Mapping" say on the GamepadTest app?

Sephiroth

Posts: 45

Joined: 17.03.2014

dive-owner


Re: Gamepad Support

by jpslara on May 5th, 2014 16:37 PM

"Sephiroth" wrote:
What does "Found" and "Mapping" say on the GamepadTest app?



I don't know why, but attached picture is not load into board, that image show you old Mapping get.

Well, this are that I get:

Found: Microntek USB Joystick
Mapping: Unknow Devide (Microntek USB Joystick )
Pressed: .............

Righ Button
UP ------> JoystickButton15
Right-----> JoystickButton16
Down-----> JoystickButton17
Left------> JoystickButton18

L1 -------> JoystickButton19


The rest of the buttons don't pruduce any pressed.

jpslara

Posts: 80

Joined: 27.12.2013

dive-owner


Re: Gamepad Support

by Sephiroth on May 5th, 2014 18:03 PM

The mapping for your controller looks almost identical to an iDroid controller. I have added it to the iDroid mapping on InControl in the Gamepad Test app.

http://www.mediafire.com/download/5f9o9 ... adTest.apk

Only thing is the left and right side seem to be backwards :? Not sure if that is a mistake so see how it goes. :)

Sephiroth

Posts: 45

Joined: 17.03.2014

dive-owner


Re: Gamepad Support

by jpslara on May 5th, 2014 19:15 PM

"Sephiroth" wrote:
The mapping for your controller looks almost identical to an iDroid controller. I have added it to the iDroid mapping on InControl in the Gamepad Test app



I have test the new app, and I have not seen any change, the image gamepad don't show any button active, and message press show the same joystickbuttons that in my previous message.

jpslara

Posts: 80

Joined: 27.12.2013

dive-owner


Re: Gamepad Support

by Sephiroth on May 5th, 2014 20:12 PM

That's weird. It still says Unknown Device?

Sephiroth

Posts: 45

Joined: 17.03.2014

dive-owner


Re: Gamepad Support

by jpslara on May 6th, 2014 16:17 PM

"Sephiroth" wrote:
That's weird. It still says Unknown Device?


Yes, the program say "Unknown device" yet.

jpslara

Posts: 80

Joined: 27.12.2013

dive-owner


STATISTICS


Total posts: 171536


Total topics: 41569


Total members: 44828


Newest member: Daniel G.