|
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 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
|
Sounds like it may be more of a Windows calibration thing, rather than Allegro specifically. Have you tried re-calibrating the joystick in Windows?
---------------------------------------------------- |
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
|
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.
---------------------------------------------------- |
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: 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.. So I reckon changing that 2000 to 0 might get rid of my deadzone |
Dizzy Egg
Member #10,824
March 2009
|
Oh sweet! I think you may have cracked it
---------------------------------------------------- |
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
|
Awesome, nice one geecab! Would be cool to be able to set that from Allegro.
---------------------------------------------------- |
|