[A5] Joystick Input (lag) vs Keyboard input (no lag)

I have a problem with joystick/gamepad input, I tested with many gamepad (logitech , x360, ...)

I always have a lag with gamepad controller. you can test the test program :


I don't know why, how do you get the Joystick input ? I want to say the best way, with the best performance.


Keyboard : Arrow key (UP , DOWN , LEFT , RIGHT)
GamePad : POV (UP , DOWN , LEFT , RIGHT)

NOTE : use joyToKey ( http://joytokey.net/en/download )for control Keyboard & Gamepad at the same time, for test the synchronisation.

Neil Roy

In my own code I just check the events (Allegro 5) like I do for keyboard and mouse. Code inside my event loop looks similar to...

   else if(event.type == ALLEGRO_EVENT_JOYSTICK_BUTTON_UP) {
      if(event.joystick.button == 0) done = true;  // Button 0 = A (green, like pressing ENTER)
      if(event.joystick.button == 1) return true;  // Button 1 = B (red, used like pressing ESC)
      // Button 7 = Start (unused here)

   else if(event.type == ALLEGRO_EVENT_JOYSTICK_AXIS) {
      done = true;


//... etc...

Though right now, I have this commented out. I had it in my Deluxe Pacman 2 game code, but there was a reason why I removed support for joysticks and I honestly cannot remember why. Could be a problem with it, I forget now. I'll have to check my notes. (checked notes)Yeah, there seemed to be some sort of bug with the joystick support in Allegro 5 which I couldn't resolved. In my notes I noted that the digital input is flaky and I was getting random crashes. I ended up removing joystick support. I think the digital input was laggy or something and other problems I forget now, it's been a while.


In my case, I use al_get_joystick_state(_joystick[0], &_joyState) for getting joystick state, I already used joystick event and I have the same lag.

Well, it's possible to use another library for manage joystick input,
Maybe use directInput directly ?

Thread #616627. Printed from Allegro.cc