Skip to content

Commit

Permalink
TestConsole axis tests now ramp up/down to/from idle position
Browse files Browse the repository at this point in the history
  • Loading branch information
fasteddy516 committed Aug 20, 2021
1 parent ee00f07 commit b427882
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions joystick_xl/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"):
Expand Down Expand Up @@ -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)")
Expand Down

0 comments on commit b427882

Please sign in to comment.