• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Joystick Deadzone?

  • Thread starter Skyler Ochsenbein
  • Start date
S

Skyler Ochsenbein

Guest
Hello,

I just purchased this USB NES Controller and started testing it out. Unfortunately, this does not work with the gamepad functions, it only works with the joystick functions.

The issue I am having, is when my character is idle, he slowly shifts up and to the left every few frames. Kind of like when you do not set a deadzone for a gamepad. It doesn't look like there is a function to set a deadzone for the joystick nor can you do something like "joystick_xpos(1) > 0.5".

My Code:
Code:
/// Controls
// Joystick Input
dpadHorz = joystick_xpos(1);
dpadVert = joystick_ypos(1);

// Input Actions
x += spd * dpadHorz;
y += spd * dpadVert;
The odd thing is, when the dpad is pressed, the character moves to the spd i have it at = 3. However, the shifting is just 1 pixel at a time every few steps. I tested the controller with an emulator and it works just fine. Is anyone familiar with this issue?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
The dpad is a binary on/off switch so your "spd" variable is being multiplied by 1 giving 3... however the joystick is a linear value from 0 to 1, so if it is 0.2 it'll give a speed of 0.6 (for example). Simply check the joystick value before applying it as you suggest yourself.
 
I

icuurd12b42

Guest
-1 to 0 to 1 so you want to do abs()... you would also want to lerp .5 to 1 back to 0 to 1... so that the character does not "boost" the moment the stick is out the dead zone.

[edit] Fixed brain fart typos
 
Last edited by a moderator:
S

Skyler Ochsenbein

Guest
The dpad is a binary on/off switch so your "spd" variable is being multiplied by 1 giving 3... however the joystick is a linear value from 0 to 1, so if it is 0.2 it'll give a speed of 0.6 (for example). Simply check the joystick value before applying it as you suggest yourself.
Yup, you were right, no idea what I had done beforehand to make it not work. Thanks, brother.
 
Top