- Online Community Forums » Programming Questions » [A5] Joystick Input (lag) vs Keyboard input (no lag)

This thread is locked; no one can reply to it. rss feed Print
[A5] Joystick Input (lag) vs Keyboard input (no lag)
Member #16,572
October 2016

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 ( )for control Keyboard & Gamepad at the same time, for test the synchronisation.

Neil Roy
Member #2,229
April 2002

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.

“I love you too.” - last words of Wanda Roy

Member #16,572
October 2016

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 ?

Go to: