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:
authorBuildTools <unconfigured@null.spigotmc.org>2015-12-08 22:00:38 +0300
committerBuildTools <unconfigured@null.spigotmc.org>2015-12-08 22:00:38 +0300
commitdb7b12a765bb6ffc07ae83d447b0bd85d888d676 (patch)
tree07e1b6c59507f4e83b4a442b7e66498215443b29 /src
parent074ccf2642b69173ac2c37767e15c65bff74eaf9 (diff)
changed get_so_extension to get_so_extensions to yield all possible extenstions. refactored uinput.py to take first vaild so extension
Diffstat (limited to 'src')
-rw-r--r--src/tools.py4
-rw-r--r--src/uinput.py33
2 files changed, 26 insertions, 11 deletions
diff --git a/src/tools.py b/src/tools.py
index fd2197b..be9b0ff 100644
--- a/src/tools.py
+++ b/src/tools.py
@@ -36,8 +36,8 @@ def static_vars(**kwargs):
return func
return decorate
-def get_so_extension():
+def get_so_extensions():
"""Return so file extenstion compatible with python and pypy"""
for ext, _, typ in imp.get_suffixes():
if typ == imp.C_EXTENSION:
- return ext
+ yield ext
diff --git a/src/uinput.py b/src/uinput.py
index 80a5050..6a92ba6 100644
--- a/src/uinput.py
+++ b/src/uinput.py
@@ -29,7 +29,7 @@ from math import pi, copysign, sqrt
from enum import IntEnum
from steamcontroller.cheader import defines
-from steamcontroller.tools import get_so_extension
+from steamcontroller.tools import get_so_extensions
from collections import deque
@@ -183,7 +183,6 @@ class UInput(object):
def __init__(self, vendor, product, name, keys, axes, rels, keyboard=False):
-
self._lib = None
self._k = keys
if not axes or len(axes) == 0:
@@ -192,13 +191,29 @@ class UInput(object):
self._a, self._amin, self._amax, self._afuzz, self._aflat = zip(*axes)
self._r = rels
-
- lib = os.path.abspath(
- os.path.normpath(
- os.path.join(
- os.path.dirname(__file__),
- '..',
- 'libuinput' + get_so_extension())))
+ possible_paths = []
+ for extension in get_so_extensions():
+ possible_paths.append(
+ os.path.abspath(
+ os.path.normpath(
+ os.path.join(
+ os.path.dirname(__file__),
+ '..',
+ 'libuinput' + extension
+ )
+ )
+ )
+ )
+ lib = None
+ for path in possible_paths:
+ if os.path.exists(path):
+ lib = path
+ break
+ if not lib:
+ raise OSError('Cant find linuinput. searched at:\n {}'.format(
+ '\n'.join(possible_paths)
+ )
+ )
self._lib = ctypes.CDLL(lib)
c_k = (ctypes.c_uint16 * len(self._k))(*self._k)