Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ynsta/steamcontroller.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Cronce <mike@quadra-tec.net>2017-02-18 02:40:09 +0300
committerMike Cronce <mike@quadra-tec.net>2017-02-18 02:40:09 +0300
commita765fc842e3a2a47ad3143dcb652ca86454a9503 (patch)
treec8fa9fc23c81d7ce50d9e9faef73409042dfefbf
parent62f30cd366e660bed698eaa191f1dca8f1a056a8 (diff)
src/events.py: Whoops...gotta take deadzone into account
-rw-r--r--src/events.py79
1 files changed, 42 insertions, 37 deletions
diff --git a/src/events.py b/src/events.py
index cfa9895..37bf179 100644
--- a/src/events.py
+++ b/src/events.py
@@ -340,47 +340,52 @@ class EventMapper(object):
rmode, rev = self._pad_evts[pos][3]
distance = math.hypot(xm, ym)
-
- # For whatever reason, the "extremes" on the pads (in
- # radians), are approximately:
- # up: 0.6pi
- # left: -0.9pi
- # down: -0.4pi
- # right: 0.1pi
- # Because of this, we subtract 0.1 from them to
- # normalize.
- angle = math.atan2(float(ym), float(xm)) - (0.1 * math.pi)
- sin = math.sin(angle)
-
- # TODO: Figure out whether it's faster to calculate
- # both sine and cosine here and have simple
- # conditionals, or to only figure out one and have
- # half the conditionals look like (e.g.) this:
- # xm < 0 and sin <= 0.839 and sin >= 0.839
- cos = math.cos(angle)
-
- # top
- if(sin >= 0.383):
- haptic |= _keypressed(tmode, tev)
+ if(distance >= dzone):
+ # For whatever reason, the "extremes" on the pads (in
+ # radians), are approximately:
+ # up: 0.6pi
+ # left: -0.9pi
+ # down: -0.4pi
+ # right: 0.1pi
+ # Because of this, we subtract 0.1 from them to
+ # normalize.
+ angle = math.atan2(float(ym), float(xm)) - (0.1 * math.pi)
+ sin = math.sin(angle)
+
+ # TODO: Figure out whether it's faster to calculate
+ # both sine and cosine here and have simple
+ # conditionals, or to only figure out one and have
+ # half the conditionals look like (e.g.) this:
+ # xm < 0 and sin <= 0.839 and sin >= 0.839
+ cos = math.cos(angle)
+
+ # top
+ if(sin >= 0.383):
+ haptic |= _keypressed(tmode, tev)
+ else:
+ haptic |= _keyreleased(tmode, tev)
+
+ # left
+ if(cos <= -0.383):
+ haptic |= _keypressed(lmode, lev)
+ else:
+ haptic |= _keyreleased(lmode, lev)
+
+ # bottom
+ if(sin <= -0.383):
+ haptic |= _keypressed(bmode, bev)
+ else:
+ haptic |= _keyreleased(bmode, bev)
+
+ # right
+ if(cos >= 0.383):
+ haptic |= _keypressed(rmode, rev)
+ else:
+ haptic |= _keyreleased(rmode, rev)
else:
haptic |= _keyreleased(tmode, tev)
-
- # left
- if(cos <= -0.383):
- haptic |= _keypressed(lmode, lev)
- else:
haptic |= _keyreleased(lmode, lev)
-
- # bottom
- if(sin <= -0.383):
- haptic |= _keypressed(bmode, bev)
- else:
haptic |= _keyreleased(bmode, bev)
-
- # right
- if(cos >= 0.383):
- haptic |= _keypressed(rmode, rev)
- else:
haptic |= _keyreleased(rmode, rev)
elif len(self._pad_evts[pos]) == 2: