Skip to content

Commit

Permalink
Added deadzone for whammy and formatted code
Browse files Browse the repository at this point in the history
Added a function to set the joystick within range -127 to 127 for better formatting.

Dead zone for whammy bar added. Prevents star power from being charged from star sustains.
  • Loading branch information
ArlanPrado committed Apr 10, 2021
1 parent 5b752a1 commit 07c8fc8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions code.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@
buttons = {5 : btn_green, 2 : btn_red, 6 : btn_yellow, 1 : btn_blue,
9 : btn_orange, 3 : btn_star, 4 : btn_plus, 7 : btn_minus, 13 : btn_up, 14 : btn_down}

def setToJoyStickRange(stickVal):
return int(stickVal * 127 * 2 -127)

def whammyDeadZone(whammyVal):
whammyDeadZoneVal = -90
whammyVal = setToJoyStickRange(whammyVal)
if(whammyVal < whammyDeadZoneVal):
return whammyDeadZoneVal
else:
return whammyVal

while True:
for gamenum, button in buttons.items():
if button.value:
Expand All @@ -91,9 +102,9 @@
# make limit -127 to 127
# adjust your joystick until limits are -127 to 127

gamepad.move_joysticks(int(ana_joy_x.value/64000 * 127 * 2 - 127),
int(ana_joy_y.value/65000 * 127 * 2 - 127),
int((ana_whammy.value-30000)/25000 * 127 * 2 - 127), None)
gamepad.move_joysticks(setToJoyStickRange(ana_joy_x.value/64000),
setToJoyStickRange(ana_joy_y.value/65000),
whammyDeadZone((ana_whammy.value-30000)/25000), None)

#time.sleep(0.1)
#print(((ana_whammy.value-30000)/25000))
Expand Down

0 comments on commit 07c8fc8

Please sign in to comment.