|
Joystic Lag - false reading |
devo_au
Member #15,282
August 2013
|
Hey there, Sometimes al_get_joystick_state gives me 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 I'm running v5.0.7 mono it wasn't me, it was other kids |
Edgar Reynaldo
Major Reynaldo
May 2007
|
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;}
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
devo_au
Member #15,282
August 2013
|
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). it wasn't me, it was other kids |
l j
Member #10,584
January 2009
|
No joystick is perfect and the issue is likely hardware related but 0.435652 seems a tad high though.
|
devo_au
Member #15,282
August 2013
|
Could be right about hardware, it might be a dodgy controller. Can't find another explanation. It works well 99.9% of the time. it wasn't me, it was other kids |
|