• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Gamepad_test_mapping() doesn't align to real buttons?

BarrowBloke

Member
Hi,

Does anyone have any experience of using gamepad_test_mapping() successfully?

I've noticed that the mappings returned by gamepad_get_mapping() and used as input by gamepad_test_mapping() don't align to the buttons used by gamepad_button_value().
Initially I noticed this on Android but I've also verified this on Windows.

E.g I'm testing using an OUYA controller on Windows which has the automatic mapping
36280100000000000000504944564944,OUYA Controller,platform:Windows,a:b0,b:b3,x:b1,y:b2,leftshoulder:b4,rightshoulder:b5,lefttrigger:b12,righttrigger:b13,guide:b15,start:b14,leftstick:b6,rightstick:b7,dpup:b8,dpdown:b9,dpleft:b10,dpright:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4
which would indicate that
a = gp_face1 = button 0
b = gp_face2 = button 3
x = gp_face3 = button 1
y = gp_face4 = button 2

However if I loop through all the buttons and use gamepad_get_value() to see which button numbers are triggered then I see
gp_face1 = button 0 (so this one matches)
gp_face2 = button 1
gp_face3 = button 2
gp_face4 = button 3

If I use these values to create a new mapping string and use gamepad_test_mapping() to implement it then chaos ensues.
It means I can't use this approach of noting the button numbers and creating a new mapping string to solve the situation where a gamepad has no default button mapping available.

Any ideas?
Barrowbloke
 

kburkhart84

Firehammer Games
You will need to specify what issue actually happen. What does "chaos ensues" actually mean.

That said, I don't mess with that system. I just let the player hit the key/button(or move the axis) they want to assign to actions directly, they click a button, and the I tell them to press their new "jump" button, shoot button, etc... This way, I don't care at all what they are using as far as keyboard/gamepads, and my game code works all the same regardless. That's what my input system does for me, along with several other nice things.
 

BarrowBloke

Member
Hi,

When the new mappings are applied and "chaos ensues", the buttons don't operate as I thought they would. E.g the 'B' button which used to be gp_face2 and would register as button 1 now registers as button 3 and gp_face4.
I thought the button IDs were immutable and only the mapping of gp_faceX constants would change but this appears not to be the case.

I think maybe altering the button mappings using gamepad_test_mapping() is not the way to go - the method you describe seems more reliable.
Thanks for the guidance!

Barrowbloke
 

kburkhart84

Firehammer Games
Hi,

When the new mappings are applied and "chaos ensues", the buttons don't operate as I thought they would. E.g the 'B' button which used to be gp_face2 and would register as button 1 now registers as button 3 and gp_face4.
I thought the button IDs were immutable and only the mapping of gp_faceX constants would change but this appears not to be the case.

I think maybe altering the button mappings using gamepad_test_mapping() is not the way to go - the method you describe seems more reliable.
Thanks for the guidance!

Barrowbloke
Yup, I don't like to depend on any automatic systems like that unless I have to. The way I do it, I don't care what is what, and the player directly presses the buttons they want, so it doesn't matter if it is button2 or button 3...it matters that they chose it for the action.
 
Top