Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Joystick Deadzone

This thread is locked; no one can reply to it. rss feed Print
Joystick Deadzone
geecab
Member #23,749
April 2023

Hi there!

I've noticed when using an analogue joystick to control my game, there is a considerable 'deadzone'. By deadzone, I mean the distance I have to move the joystick from its centre position, to where Allegro first gives me a non-zero reading (and recognizes I've actually moved the stick). Once out of the deadzone, Allegro gives me very accurate stick positions.

I notice this when running Allegro 5.0.10 on Windows (For many years I've been using 5.0.10 Windows binaries downloaded from
https://www.allegro.cc/files/)

On Linux however, using a more recent version of Allegro (5.2), when running the same game with the same joystick, there is no deadzone (The game behaves perfectly).

Does anyone know how I can eliminate the deadzone on windows? I've really like to avoid updating the version of Allegro I'm building with (Because I like my game to run on an old XP PC I have in an arcade machine).

Many thanks,

Ben

Dizzy Egg
Member #10,824
March 2009
avatar

Sounds like it may be more of a Windows calibration thing, rather than Allegro specifically. Have you tried re-calibrating the joystick in Windows?

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

geecab
Member #23,749
April 2023

I know what you mean, I thought so too.

Yes, I've recalibrated it. I'm just using the standard 'USB game controllers' app that's shipped with windows to set it up / calibrate it. There is no additional driver/app shipped with the joystick, its a very simple analog joystick.

Interestingly enough, I can use the 'USB game controllers' app to test the joystick is working, and see the x and y values its reporting as I move the stick. There isn't any deadzone apparent when I do this. I can see the values change in a way I'd expect even with very tiny movements away from the stick's centre position.

I've just rebuilt my game on Windows using Allegro v5.2.9 and its still the same.

Dizzy Egg
Member #10,824
March 2009
avatar

I would say could you post some code, but seeing as it works ok on Linux I'm not sure if that would help! Other than that, will have to wait for some of the other guys to see if they've got experience of this issue.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

geecab
Member #23,749
April 2023

No worries, I think I might be onto something :) Just been looking at the source in github and found this going on in allegro5\src\win\wjoydxnu.cpp and was dubious about what the 2000 value was for:

#SelectExpand
1 DIPROPDWORD property_deadzone = 2 { 3 /* the header */ 4 { 5 sizeof(DIPROPDWORD), // diph.dwSize 6 sizeof(DIPROPHEADER), // diph.dwHeaderSize 7 0, // diph.dwObj 8 DIPH_DEVICE, // diph.dwHow 9 }, 10 11 /* the data */ 12 2000, // dwData 13 }; 14 15hr = IDirectInputDevice8_SetProperty(dinput_device, DIPROP_DEADZONE, &property_deadzone.diph);

Then after googleing DIPROP_DEADZONE I found this...

https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee417929(v=vs.85)

Which explains that DIPROP_DEADZONE..
Sets the value for the dead zone of a joystick, in the range from 0 through 10,000, where 0 indicates that there is no dead zone, 5,000 indicates that the dead zone extends over 50 percent of the physical range of the axis on both sides of center, and 10,000 indicates that the entire physical range of the axis is dead. When the axis is within the dead zone, it is reported as being at the center of its range. This setting can be applied to either the entire device or to a specific axis

So I reckon changing that 2000 to 0 might get rid of my deadzone :)

Dizzy Egg
Member #10,824
March 2009
avatar

Oh sweet! I think you may have cracked it 8-)

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

geecab
Member #23,749
April 2023

I had a bit of a struggle but managed to build allegro 5.2.9 from source. Changed the 2000 thing to 0 and, yes, the that got rid of the deadzone.

I guess a big deadzone is desirable for analog thumb sticks on gamepads. It's not the best though when you need high precision controls (flight yokes or steering wheels).

I'll see if I can raise an issue on github about it and see what happens :)

Dizzy Egg
Member #10,824
March 2009
avatar

Awesome, nice one geecab! Would be cool to be able to set that from Allegro.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Go to: