add configurable dead-zone and tester program

This commit is contained in:
Brendan Robert 2024-03-06 16:47:43 -06:00
parent bba6a81d4a
commit abc32325de
2 changed files with 10 additions and 0 deletions

View File

@ -93,6 +93,8 @@ public class Joystick extends Device {
public boolean useDPad = false;
@ConfigurableField(name = "Timer resolution", shortName = "timerres", description = "How many ticks until we poll the buttons again?")
public static long TIMER_RESOLUTION = TimedDevice.NTSC_1MHZ / 15; // 15FPS resolution reads when joystick is not used
@ConfigurableField(name = "Dead Zone", shortName = "deadZone", description = "Dead zone for joystick (0-1)")
public static float deadZone = 0.1f;
Integer controllerNumber = null;
@ -192,6 +194,12 @@ public class Joystick extends Device {
y = 0;
}
}
if (Math.abs(x) < deadZone) {
x = 0;
}
if (Math.abs(y) < deadZone) {
y = 0;
}
joyX = (int) (x * 128.0 + 128.0);
joyY = (int) (y * 128.0 + 128.0);

View File

@ -0,0 +1,2 @@
0 REM Joystick test, shows X and Y position of joystick and button state
10 ? pdl(0), pdl(1), peek(49249)>127; " "; peek(49250)>127:goto 10