Skip to content
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