From b427882227c5934660b4dc284e177643e4eac39f Mon Sep 17 00:00:00 2001 From: Edward Wright Date: Thu, 19 Aug 2021 22:06:56 -0400 Subject: [PATCH] TestConsole axis tests now ramp up/down to/from idle position --- joystick_xl/tools.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/joystick_xl/tools.py b/joystick_xl/tools.py index 1e69351..4b18193 100644 --- a/joystick_xl/tools.py +++ b/joystick_xl/tools.py @@ -123,6 +123,13 @@ def ValidateIndex(i: int, limit: int, name: str) -> int: else: return i - si + def MoveAxis(axis: int, stop: int, step: int) -> None: + for i in range(Axis.IDLE, stop, step): + js.update_axis((axis, i)) + for i in range(stop, Axis.IDLE, -step): + js.update_axis((axis, i)) + js.update_axis((axis, Axis.IDLE)) + print("\nJoystickXL", __version__, "- Test Console\n") print("Using 1-based indexing.") print("Button Clicks = 0.25s") @@ -157,19 +164,19 @@ def ValidateIndex(i: int, limit: int, name: str) -> int: i = ValidateIndex(num, js.num_axes, "axis") if i < 0: continue - elif cmd.endswith("+"): - operation = "MAX" + elif cmd.endswith("u"): + operation = "UP" value = Axis.MAX - elif cmd.endswith("-"): - operation = "MIN" + step = 3 + elif cmd.endswith("d"): + operation = "DOWN" value = Axis.MIN + step = -3 else: print(INVALID_OPERATION) continue print("> Axis", i + si, operation) - js.update_axis((i, value)) - time.sleep(pt) - js.update_axis((i, Axis.IDLE)) + MoveAxis(i, value, step) # button functions elif cmd.startswith("b"): @@ -252,9 +259,9 @@ def ValidateIndex(i: int, limit: int, name: str) -> int: # help elif cmd.startswith("?"): - print(" a = axis (ex. `a2+`, `a1-`, `at`)") + print(" a = axis (ex. `a2u`, `a1d`, `at`)") print(" b = button (ex. `b13`, `bt`)") - print(" h = hat (ex. `h1u`, `h1d`, `h1l`, `h1r`, `ht`)") + print(" h = hat (ex. `h1u`, `h1d`, `h1ul`, `h1dr`, `ht`)") print(" t = test all") print(" 0 = 0-based indexing (button 1 = 0)") print(" 1 = 1-based indexing (button 1 = 1)")