diff options
author | kozec <kozec@kozec.com> | 2017-01-01 14:01:39 +0300 |
---|---|---|
committer | kozec <kozec@kozec.com> | 2017-01-01 14:01:39 +0300 |
commit | 30b403b1510d61ed12476b329d8e80900f5ef011 (patch) | |
tree | f32aa0d3393e12035de4a13638422dfdea1f15ed | |
parent | 99852e6114a6ccc3324efab3b65219d2f2ba6469 (diff) |
Turned uinput device version from hardcoded number to parameter
-rw-r--r-- | src/uinput.c | 3 | ||||
-rw-r--r-- | src/uinput.py | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/uinput.c b/src/uinput.c index e28110a..6232f0a 100644 --- a/src/uinput.c +++ b/src/uinput.c @@ -44,6 +44,7 @@ int uinput_init( int keyboard, __u16 vendor, __u16 product, + __u16 version, char * name) { struct uinput_user_dev uidev; @@ -60,7 +61,7 @@ int uinput_init( uidev.id.bustype = BUS_USB; uidev.id.vendor = vendor; uidev.id.product = product; - uidev.id.version = 1; + uidev.id.version = version; /* Key Event initialisation */ if (key_len > 0 && ioctl(fd, UI_SET_EVBIT, EV_KEY) < 0) { diff --git a/src/uinput.py b/src/uinput.py index 8ab8d25..7894bc2 100644 --- a/src/uinput.py +++ b/src/uinput.py @@ -184,7 +184,7 @@ class UInput(object): """ - def __init__(self, vendor, product, name, keys, axes, rels, keyboard=False): + def __init__(self, vendor, product, version, name, keys, axes, rels, keyboard=False): self._lib = None self._k = keys if not axes or len(axes) == 0: @@ -196,6 +196,7 @@ class UInput(object): self.vendor = vendor self.product = product self.name = name + self.version = version self.keyboard = keyboard self._fd = None @@ -235,6 +236,7 @@ class UInput(object): 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) @@ -251,6 +253,7 @@ class UInput(object): c_keyboard, c_vendor, c_product, + c_version, c_name) @@ -366,6 +369,7 @@ class Gamepad(UInput): def __init__(self): super(Gamepad, self).__init__(vendor=0x045e, product=0x028e, + version=1, name=b"Microsoft X-Box 360 pad", keys=[Keys.BTN_START, Keys.BTN_MODE, @@ -413,6 +417,7 @@ class Mouse(UInput): def __init__(self): super(Mouse, self).__init__(vendor=0x28de, product=0x1142, + version=1, name=b"Steam Controller Mouse", keys=[Keys.BTN_LEFT, Keys.BTN_RIGHT, @@ -692,6 +697,7 @@ class Keyboard(UInput): def __init__(self): super(Keyboard, self).__init__(vendor=0x28de, product=0x1142, + version=1, name=b"Steam Controller Keyboard", keys=Scans.keys(), axes=[], |