Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » What button is what on your gamepad(s)?

This thread is locked; no one can reply to it. rss feed Print
What button is what on your gamepad(s)?
amber
Member #6,783
January 2006
avatar

I am making a game that uses a gamepad for input so I'd like to get an idea of what button number in Allegro (e.g., 0, 1, 2, etc.) maps to what physical button (e.g., A, B, X, triangle, etc.) on various gamepads. So, I would appreciate it if anyone who uses a gamepad with Allegro wouldn't mind posting what button maps to what physical button on your gamepad.

For example, something like "on my Super NES controller that I somehow managed to plug into my PC button 0 is B, button 1 is Y, button 2 is X ..." and so on.

My PS1 controller with a USB adapter uses the scheme
Button 0 = Triangle
Button 1 = Circle
Button 2 = X
Button 3 = Square
Button 4 = L2
Button 5 = R2
Button 6 = L1
Button 7 = R1
Button 8 = Select
Button 9 = Start
Button 10 = Left Stick Button
Button 11 = Right Stick Button

I find this scheme to be a little strange because I'd usually think of X (or A on an xbox controller) to be the "first" button, but this could just be my impression clashing with how things work internally... hence my curiosity about how the numbers work for other people's devices.

If your controller is not (or doesn't resemble) something used on a popular console, a link to a picture would also be appreciated. ;D

Thank you. :)

l j
Member #10,584
January 2009
avatar

Wow I edit too much

Logitech F510 Rumble(Supports 2 different input modes)
(Using DirectInput)
And is made for use with PCs
Resembles a Xbox360 controller
Except the left joystick and control pad are placed exactly like on a PS controller
Actually, it looks like A PS controller except the buttons have the XBox labels on them

Button 0 = X (Square on PS controller)
Button 1 = A (X on on PS controller)
Button 2 = B (Circle on PS controller)
Button 3 = Y (Triangle on PS controller)
Button 4 = LB (L1)
Button 5 = RB (R1)
Button 6 = LT (L2)
Button 7 = RT (R2)
Button 8 = Back (Select)
Button 9 = Start
Button 10 = Left stick button (L3)
Button 11 = Right stick button (R3)

I've quickly tested this with the Allegro ex_joystick_events example, I think those little squares are in an ascending sequence.
On all the older gamepads that I've used, the Square (Like on PS) was the first button
I've put where the buttons would be located on a PS controller layout between brackets.

I'll put what happens when I use XInput later, still have stuff to do.
But I do know the buttons are mapped differently.

amber
Member #6,783
January 2006
avatar

This is informative, particularly the part about other gamepads also corresponding to this pattern. Perhaps I'm right that my gamepad's layout is rather odd, but wrong that A is the "first" button, and what you have here is more of a "standard" arrangement, at least when using DirectInput.

I don't use XInput at all, so no need to post information on that for my sake, if you're busy.

Thank you for the response! :)

MiquelFire
Member #3,110
January 2003
avatar

I have to wait until I get home to verify this, but the 360 controller might have A as button 0.

I do know, however, that with DirectInput, what would be l2 and r2 are on a single axis (so holding both down at once is the same as not holding them down)

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red | +Me
Windows 8 is a toned, stylish, polished professional athlete. But it’s wearing clown makeup, and that creates a serious image problem. ~PCWorld Article

Oscar Giner
Member #2,207
April 2002
avatar

With Rumble Gamepad F510 working in XInput mode (should be the same as an XBOX360 controller):

Button 0 = A
Button 1 = B
Button 2 = X
Button 3 = Y
Button 4 = LB
Button 5 = RB
Button 6 = Back
Button 7 = Start
Button 8 = Left Stick Button
Button 9 = Right Stick Button

LT and RT are mapped to an axis.

amber
Member #6,783
January 2006
avatar

That Xbox layout is closer to what I expected. Thanks. ;D

MiquelFire
Member #3,110
January 2003
avatar

Oscar, if you were using XInput mode, LT and RT would each be on their own axis, not shared. Just an FYI.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red | +Me
Windows 8 is a toned, stylish, polished professional athlete. But it’s wearing clown makeup, and that creates a serious image problem. ~PCWorld Article

Trent Gamblin
Member #261
April 2000
avatar

Allegro 5 uses DirectInput for joystick handling on Windows. In ex_joystick_events, I get two separate axes for LT and RT or I'm a monkey's uncle. I didn't try it right now, but I will on a $50+ bet.

amber
Member #6,783
January 2006
avatar

According to MSDN, DirectInput puts LT and RT on a shared axis.

Quote:

The combination of the left and right triggers in DirectInput is by design. Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device. However, the Xbox 360 controller was designed to register minimum value, not center, when the triggers are not being held. Older games would therefore assume user interaction.

The solution was to combine the triggers, setting one trigger to a positive direction and the other to a negative direction, so no user interaction is indicative to DirectInput of the 'control' being at center.

(From http://msdn.microsoft.com/en-us/library/ee417014%28v=vs.85%29.aspx )

I don't know if Allegro 5 does something to the input, though.

MiquelFire
Member #3,110
January 2003
avatar

For me, it's on the same axis. Allegro5 was my first exposure to this behavior actually.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red | +Me
Windows 8 is a toned, stylish, polished professional athlete. But it’s wearing clown makeup, and that creates a serious image problem. ~PCWorld Article

Trent Gamblin
Member #261
April 2000
avatar

Well then thanks for not taking that bet because I'm probably wrong :D.

Ben Delacob
Member #6,141
August 2005
avatar

Wii Classic controller connected with MayFlash adapter:

Button 0 = a
Button 1 = b
Button 2 = x
Button 3 = y
Button 4 = l
Button 5 = r
Button 6 = zl
Button 7 = zr
Button 8 = -
Button 9 = +
Button 10 = home
Button 11 = up
Button 12 = left
Button 13 = down
Button 14 = right

__________________________________
Allegro html mockup code thread -website-
"two to the fighting eighth power"

Sirocco
Member #88
April 2000
avatar

Gamecube controller via USB adapter:

0 - A
1 - B
2 - X
3 - Y
4 - L trigger click
5 - R trigger click
6 - Z
7 - Start

-->
Graphic file formats used to fascinate me, but now I find them rather satanic.

Go to: