- Online Community Forums » Programming Questions » allegro 4 button mapping for xbox 360 controller?

This thread is locked; no one can reply to it. rss feed Print
allegro 4 button mapping for xbox 360 controller?
Member #16,818
March 2018

does anybody have an idea of what the allegro 4 button mapping are for a xbox 360 controller?

me and @ZoriaRPG were discussing problems with detecting things like triggers, dpad, and joypad directions.

Member #16,714
July 2017

The question is: Does anyone here have one, who can confirm what values AG4 reads for its buttons, and its analogue stick(s)?

I do not own one of those controllers--or anything XBox, at all, for that matter--so, I'ven't a way to test it, or otherwise to read from it to see what it outputs, that we can read.

To clarify, what I don't know, is how that specific controller wants to be mapped to joy[]

As a reference:

      typedef struct JOYSTICK_INFO
   int flags;                       - status flags for this
   int num_sticks;                  - how many stick inputs?
   int num_buttons;                 - how many buttons?
   JOYSTICK_STICK_INFO stick[n];    - stick state information
   JOYSTICK_BUTTON_INFO button[n];  - button state information

We use 18 total buttons, and we have config values for the joystick axis as follows:

1 control_state[0]=key[DUkey]||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn)); 2 control_state[1]=key[DDkey]||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn)); 3 control_state[2]=key[DLkey]||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn)); 4 control_state[3]=key[DRkey]||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn)); 5 control_state[4]=key[Akey]||joybtn(Abtn); 6 control_state[5]=key[Bkey]||joybtn(Bbtn); 7 control_state[6]=key[Skey]||joybtn(Sbtn); 8 control_state[7]=key[Lkey]||joybtn(Lbtn); 9 control_state[8]=key[Rkey]||joybtn(Rbtn); 10 control_state[9]=key[Pkey]||joybtn(Pbtn); 11 control_state[10]=key[Exkey1]||joybtn(Exbtn1); 12 control_state[11]=key[Exkey2]||joybtn(Exbtn2); 13 control_state[12]=key[Exkey3]||joybtn(Exbtn3); 14 control_state[13]=key[Exkey4]||joybtn(Exbtn4); 15 16 if(num_joysticks != 0) 17 { 18 control_state[14]= STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION; 19 control_state[15]= STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION; 20 control_state[16]= STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION; 21 control_state[17]= STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION; 22 }

I'm not sure if we need to map more possible buttons, or if the user (shadowblitz) needs to properly map the integer for his stick ID, or both.

Edgar Reynaldo
Major Reynaldo
May 2007

Oscar Giner
Member #2,207
April 2002

I've tried an old Allegro 4 game of mine that supports joypad mapping and this is what it reports with XBox One X controller under Win 10:

Analog inputs:

Dpad is mapped to stick 3. Axis 0 for left/right and axis 1 for up/down.
Left stick is mapped to stick 0. Axis 0 for left/right, axis 1 for up/down
Right stick is weird: it maps rigth/left to stick 2 axis 0, and up/down to stick 1 axis 0.
LT/RT are mapped to stick 0 axis 2 (yes, a single axis for both triggers, that's a known issue when using XBox controllers in Direct Input mode, so avoid using the triggers as analog inputs. For digital input .d2 is LT and .d1 is RT, and you can't detect if both are pressed simultaneously).
For all sticks .d1 is left or up and .d2 is right or down.


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

Go to: