Joystic Lag - false reading
devo_au

Hey there,

Sometimes al_get_joystick_state gives me
false axis readings. Eg sometimes when I release the analog
the player will continue to travel in the last direction it was heading.
I checked the rest of the loop,

#SelectExpand
1 al_get_joystick_state(joy, &joyState); 2 axvalX = joyState.stick[0].axis[0]; 3 axvalY = joyState.stick[0].axis[1]; 4 5 //TEST X AXIS 6 if(axvalX < 0)//left 7 { 8 keys[LEFT] = true; 9 keys[RIGHT] = false; 10 } 11 else if(axvalX > 0)//right 12 { 13 keys[LEFT] = false; 14 keys[RIGHT] = true; 15 } 16 else //center 17 { 18 keys[LEFT] = false; 19 keys[RIGHT] = false; 20 }

the issue seems to be coming straight
after al_get_joystick_state.

I'm running v5.0.7 mono
VC 2010 express on win7 32
& Logitech F310 switched to directinput
Cheers

Edgar Reynaldo

Your stick might not be in a totally neutral position. Try using a small epsilon to test for centeredness :

double epsilon = 0.05;

if (axis < -epsilon) {left = true;}
else if (axis > epsilon) {right = true;}
else {center = true;}

devo_au

Thanks for reply. Normally the stick is 0.00000 center. When bugging the stick is reading 0.435652 when it has physically returned to the center. It works ok most the time, so I haven't worked out what is triggering it, only that I can debug the false read back to al_get_joystick_state(joy, &joyState).

l j

No joystick is perfect and the issue is likely hardware related but 0.435652 seems a tad high though.

devo_au

Could be right about hardware, it might be a dodgy controller. Can't find another explanation. It works well 99.9% of the time.

Thread #613482. Printed from Allegro.cc