Example #1
0
    def createDevice(self):
        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 libuinput. searched at:\n {}'.format(
                '\n'.join(possible_paths)
            )
        )

        self._lib = ctypes.CDLL(lib)

        c_k        = (ctypes.c_uint16 * len(self._k))(*self._k)
        c_a        = (ctypes.c_uint16 * len(self._a))(*self._a)
        c_amin     = (ctypes.c_int32  * len(self._amin ))(*self._amin )
        c_amax     = (ctypes.c_int32  * len(self._amax ))(*self._amax )
        c_afuzz    = (ctypes.c_int32  * len(self._afuzz))(*self._afuzz)
        c_aflat    = (ctypes.c_int32  * len(self._aflat))(*self._aflat)
        c_r        = (ctypes.c_uint16 * len(self._r))(*self._r)
        c_vendor   = ctypes.c_uint16(self.vendor)
        c_product  = ctypes.c_uint16(self.product)
        c_version  = ctypes.c_uint16(self.version)
        c_keyboard = ctypes.c_int(self.keyboard)

        c_name = ctypes.c_char_p(self.name)
        self._fd = self._lib.uinput_init(ctypes.c_int(len(self._k)),
                                         c_k,
                                         ctypes.c_int(len(self._a)),
                                         c_a,
                                         c_amin,
                                         c_amax,
                                         c_afuzz,
                                         c_aflat,
                                         ctypes.c_int(len(self._r)),
                                         c_r,
                                         c_keyboard,
                                         c_vendor,
                                         c_product,
                                         c_version,
                                         c_name)
Example #2
0
    def createDevice(self):
        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 libuinput. searched at:\n {}'.format(
                '\n'.join(possible_paths)
            )
        )

        self._lib = ctypes.CDLL(lib)

        c_k        = (ctypes.c_uint16 * len(self._k))(*self._k)
        c_a        = (ctypes.c_uint16 * len(self._a))(*self._a)
        c_amin     = (ctypes.c_int32  * len(self._amin ))(*self._amin )
        c_amax     = (ctypes.c_int32  * len(self._amax ))(*self._amax )
        c_afuzz    = (ctypes.c_int32  * len(self._afuzz))(*self._afuzz)
        c_aflat    = (ctypes.c_int32  * len(self._aflat))(*self._aflat)
        c_r        = (ctypes.c_uint16 * len(self._r))(*self._r)
        c_vendor   = ctypes.c_uint16(self.vendor)
        c_product  = ctypes.c_uint16(self.product)
        c_keyboard = ctypes.c_int(self.keyboard)

        c_name = ctypes.c_char_p(self.name)
        self._fd = self._lib.uinput_init(ctypes.c_int(len(self._k)),
                                         c_k,
                                         ctypes.c_int(len(self._a)),
                                         c_a,
                                         c_amin,
                                         c_amax,
                                         c_afuzz,
                                         c_aflat,
                                         ctypes.c_int(len(self._r)),
                                         c_r,
                                         c_keyboard,
                                         c_vendor,
                                         c_product,
                                         c_name)
Example #3
0
    def __init__(self, vendor, product, name, keys, axes, rels, keyboard=False):
        self._lib = None
        self._k = keys
        if not axes or len(axes) == 0:
            self._a, self._amin, self._amax, self._afuzz, self._aflat = [[]] * 5
        else:
            self._a, self._amin, self._amax, self._afuzz, self._aflat = zip(*axes)

        self._r = rels
        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)
        c_a = (ctypes.c_uint16 * len(self._a))(*self._a)
        c_amin = (ctypes.c_int32 * len(self._amin))(*self._amin)
        c_amax = (ctypes.c_int32 * len(self._amax))(*self._amax)
        c_afuzz = (ctypes.c_int32 * len(self._afuzz))(*self._afuzz)
        c_aflat = (ctypes.c_int32 * len(self._aflat))(*self._aflat)
        c_r = (ctypes.c_uint16 * len(self._r))(*self._r)
        c_vendor = ctypes.c_uint16(vendor)
        c_product = ctypes.c_uint16(product)
        c_keyboard = ctypes.c_int(keyboard)

        c_name = ctypes.c_char_p(name)
        self._fd = self._lib.uinput_init(
            ctypes.c_int(len(self._k)),
            c_k,
            ctypes.c_int(len(self._a)),
            c_a,
            c_amin,
            c_amax,
            c_afuzz,
            c_aflat,
            ctypes.c_int(len(self._r)),
            c_r,
            c_keyboard,
            c_vendor,
            c_product,
            c_name,
        )
Example #4
0
    def __init__(self,
                 vendor,
                 product,
                 name,
                 keys,
                 axes,
                 rels,
                 keyboard=False):
        self._lib = None
        self._k = keys
        if not axes or len(axes) == 0:
            self._a, self._amin, self._amax, self._afuzz, self._aflat = [[]
                                                                         ] * 5
        else:
            self._a, self._amin, self._amax, self._afuzz, self._aflat = zip(
                *axes)

        self._r = rels
        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)
        c_a = (ctypes.c_uint16 * len(self._a))(*self._a)
        c_amin = (ctypes.c_int32 * len(self._amin))(*self._amin)
        c_amax = (ctypes.c_int32 * len(self._amax))(*self._amax)
        c_afuzz = (ctypes.c_int32 * len(self._afuzz))(*self._afuzz)
        c_aflat = (ctypes.c_int32 * len(self._aflat))(*self._aflat)
        c_r = (ctypes.c_uint16 * len(self._r))(*self._r)
        c_vendor = ctypes.c_uint16(vendor)
        c_product = ctypes.c_uint16(product)
        c_keyboard = ctypes.c_int(keyboard)

        c_name = ctypes.c_char_p(name)
        self._fd = self._lib.uinput_init(ctypes.c_int(len(self._k)), c_k,
                                         ctypes.c_int(len(self._a)), c_a,
                                         c_amin, c_amax, c_afuzz, c_aflat,
                                         ctypes.c_int(len(self._r)), c_r,
                                         c_keyboard, c_vendor, c_product,
                                         c_name)