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
path: root/src
diff options
context:
space:
mode:
authorStany MARCEL <stanypub@gmail.com>2015-11-12 02:48:00 +0300
committerStany MARCEL <stanypub@gmail.com>2015-11-12 02:48:00 +0300
commitb5d70096c18b2179a99d3075de94d9750143756a (patch)
tree706f2bfcf8df292ce88b605ce4f72f187c88046d /src
parent83af1b71d9d8f784c410f4394b36b6ff0797bc3a (diff)
Clean code from pylint output
Signed-off-by: Stany MARCEL <stanypub@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/daemon.py14
-rw-r--r--src/uinput.py25
2 files changed, 24 insertions, 15 deletions
diff --git a/src/daemon.py b/src/daemon.py
index 3ff247e..91d60a1 100644
--- a/src/daemon.py
+++ b/src/daemon.py
@@ -3,7 +3,11 @@
# Adapted from http://www.jejik.com/files/examples/daemon3x.py
# thanks to the original author
-import sys, os, time, atexit, signal
+import sys
+import os
+import time
+import atexit
+import signal
class Daemon(object):
"""A generic daemon class.
@@ -56,7 +60,7 @@ class Daemon(object):
atexit.register(self.delpid)
pid = str(os.getpid())
- with open(self.pidfile,'w+') as f:
+ with open(self.pidfile, 'w+') as f:
f.write(pid + '\n')
def delpid(self):
@@ -67,7 +71,7 @@ class Daemon(object):
# Check for a pidfile to see if the daemon already runs
try:
- with open(self.pidfile,'r') as pf:
+ with open(self.pidfile, 'r') as pf:
pid = int(pf.read().strip())
except IOError:
@@ -88,7 +92,7 @@ class Daemon(object):
# Get the pid from the pidfile
try:
- with open(self.pidfile,'r') as pf:
+ with open(self.pidfile, 'r') as pf:
pid = int(pf.read().strip())
except IOError:
pid = None
@@ -110,7 +114,7 @@ class Daemon(object):
if os.path.exists(self.pidfile):
os.remove(self.pidfile)
else:
- print (str(err.args))
+ print(str(err.args))
sys.exit(1)
def restart(self):
diff --git a/src/uinput.py b/src/uinput.py
index 1e10723..08bc83e 100644
--- a/src/uinput.py
+++ b/src/uinput.py
@@ -25,7 +25,8 @@
import os
import ctypes
import time
-from math import pi, copysign, sqrt, pow
+from math import pi, copysign, sqrt
+from math import pow as mpow
from enum import IntEnum
from steamcontroller.cheader import defines
@@ -35,16 +36,16 @@ from distutils.sysconfig import get_config_var
_def = defines('/usr/include', 'linux/uinput.h')
# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
-Keys = IntEnum('Keys', { i: _def[i] for i in _def.keys() if (i.startswith('KEY_') or
- i.startswith('BTN_')) })
+Keys = IntEnum('Keys', {i: _def[i] for i in _def.keys() if (i.startswith('KEY_') or
+ i.startswith('BTN_'))})
# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
-KeysOnly = IntEnum('KeysOnly', { i: _def[i] for i in _def.keys() if (i.startswith('KEY_')) })
+KeysOnly = IntEnum('KeysOnly', {i: _def[i] for i in _def.keys() if i.startswith('KEY_')})
# Axes enum contains all axes from linux/uinput.h (ABS_*)
-Axes = IntEnum('Axes', { i: _def[i] for i in _def.keys() if (i.startswith('ABS_')) })
+Axes = IntEnum('Axes', {i: _def[i] for i in _def.keys() if i.startswith('ABS_')})
# Rels enum contains all rels from linux/uinput.h (REL_*)
-Rels = IntEnum('Rels', { i: _def[i] for i in _def.keys() if (i.startswith('REL_')) })
+Rels = IntEnum('Rels', {i: _def[i] for i in _def.keys() if i.startswith('REL_')})
# Scan codes for each keys (taken from a logitech keyboard)
@@ -343,6 +344,8 @@ class Mouse(UInput):
Rels.REL_HWHEEL])
self._dx = 0.0
self._dy = 0.0
+ self._xvel = 0.0
+ self._yvel = 0.0
self._lastTime = time.time()
self.updateParams()
@@ -439,7 +442,7 @@ class Mouse(UInput):
self._dx -= int(self._dx)
self._dy -= int(self._dy)
- return sqrt(pow(dx, 2) + pow(dy, 2))
+ return sqrt(mpow(dx, 2) + mpow(dy, 2))
class Keyboard(UInput):
@@ -465,7 +468,7 @@ class Keyboard(UInput):
self._dx = 0.0
self._pressed = set()
- def pressEvent(self, keys=[]):
+ def pressEvent(self, keys):
"""
Generate key press event with corresponding scan codes.
Events are generated only for new keys.
@@ -481,12 +484,14 @@ class Keyboard(UInput):
self.synEvent()
self._pressed |= set(new)
- def releaseEvent(self, keys=[]):
+ def releaseEvent(self, keys=None):
"""
Generate key release event with corresponding scan codes.
Events are generated only for keys that was pressed
- @param list of Keys keys keys to release
+
+ @param list of Keys keys keys to release, give None or empty list
+ to release all
"""
if keys and len(keys):
rem = [k for k in keys if k in self._pressed]