diff options
author | BuildTools <unconfigured@null.spigotmc.org> | 2015-12-08 22:00:38 +0300 |
---|---|---|
committer | BuildTools <unconfigured@null.spigotmc.org> | 2015-12-08 22:00:38 +0300 |
commit | db7b12a765bb6ffc07ae83d447b0bd85d888d676 (patch) | |
tree | 07e1b6c59507f4e83b4a442b7e66498215443b29 | |
parent | 074ccf2642b69173ac2c37767e15c65bff74eaf9 (diff) |
changed get_so_extension to get_so_extensions to yield all possible extenstions. refactored uinput.py to take first vaild so extension
l--------- | include/python2.7 | 1 | ||||
m--------- | local | 6 | ||||
-rw-r--r-- | src/tools.py | 4 | ||||
-rw-r--r-- | src/uinput.py | 33 |
4 files changed, 33 insertions, 11 deletions
diff --git a/include/python2.7 b/include/python2.7 new file mode 120000 index 0000000..ad4ca80 --- /dev/null +++ b/include/python2.7 @@ -0,0 +1 @@ +/usr/include/python2.7
\ No newline at end of file diff --git a/local b/local new file mode 160000 +Subproject 074ccf2642b69173ac2c37767e15c65bff74eaf 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) |