Skip to content

Bugfix zerodivisionerror #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions XInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,20 @@ def get_thumb_values(state):
magL = sqrt(LX*LX + LY*LY)
magR = sqrt(RX*RX + RY*RY)

normLX = LX / magL
normLY = LY / magL
normRX = RX / magR
normRY = RY / magR
if magL != 0:
normLX = LX / magL
normLY = LY / magL
else: # if magL == 0 the stick is centered, there is no direction
normLX = 0
normLY = 0

if magR != 0:
normRX = RX / magR
normRY = RY / magR
else: # if magR == 0 the stick is centered, there is no direction
normRX = 0
normRY = 0


normMagL = 0
normMagR = 0
Expand Down Expand Up @@ -396,8 +406,12 @@ def get_events():

magL = sqrt(LX*LX + LY*LY)

normLX = LX / magL
normLY = LY / magL
if magL != 0:
normLX = LX / magL
normLY = LY / magL
else: # if magL == 0 the stick is centered, there is no direction
normLX = 0
normLY = 0

normMagL = 0

Expand Down Expand Up @@ -429,8 +443,12 @@ def get_events():

magR = sqrt(RX*RX + RY*RY)

normRX = RX / magR
normRY = RY / magR
if magR != 0:
normRX = RX / magR
normRY = RY / magR
else: # if magR == 0 the stick is centered, there is no direction
normRX = 0
normRY = 0

normMagR = 0

Expand Down