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:
authorYour Name <you@example.com>2016-07-24 11:19:25 +0300
committerYour Name <you@example.com>2016-07-24 11:19:25 +0300
commite9b6cee25313881e5e637f67bff2d10a2d1bde8f (patch)
treea64b100572fb05b595ba2126eef866238ae4fd1a
parent722f9bf007f98e859cd697a548d1284eb4a7d34d (diff)
Replace single div by zero exception to two to avoid x/y axis from zeroing the other
-rw-r--r--src/events.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/events.py b/src/events.py
index 6f5b386..bca43b3 100644
--- a/src/events.py
+++ b/src/events.py
@@ -221,16 +221,26 @@ class EventMapper(object):
# Compute mean pos
try:
xm_p = int(sum(self._xdq[pos]) / len(self._xdq[pos]))
+ except ZeroDivisionError:
+ xm_p = 0
+
+ try:
ym_p = int(sum(self._ydq[pos]) / len(self._ydq[pos]))
except ZeroDivisionError:
- xm_p, ym_p = 0, 0
+ ym_p = 0
+
self._xdq[pos].append(x)
self._ydq[pos].append(y)
try:
xm = int(sum(self._xdq[pos]) / len(self._xdq[pos]))
+ except ZeroDivisionError:
+ xm = 0
+
+ try:
ym = int(sum(self._ydq[pos]) / len(self._ydq[pos]))
except ZeroDivisionError:
- xm, ym = 0, 0
+ ym = 0
+
if not sci_p.buttons & touch == touch:
xm_p, ym_p = xm, ym