Skip to content

Commit 47fd9b2

Browse files
author
goncalopp
committed
move suinput_open() to module-level function
1 parent 2dc4654 commit 47fd9b2

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def _error_handler(result, fn, args):
8080
raise RuntimeError("unexpected return value: %s" % result)
8181
return result
8282

83+
def fdopen():
84+
return _libsuinput.suinput_open()
85+
8386
_libsuinput_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "_libsuinput" + sysconfig.get_config_var("SO")))
8487
_libsuinput = ctypes.CDLL(_libsuinput_path, use_errno=True)
8588
_libsuinput.suinput_open.errcheck = _open_error_handler
@@ -172,7 +175,7 @@ def __init__(self, events, name="python-uinput",
172175
user_dev.id.vendor = vendor
173176
user_dev.id.product = product
174177
user_dev.id.version = version
175-
self.__uinput_fd = fd or self.create_uinput_fd()
178+
self.__uinput_fd = fd or fdopen()
176179
for ev_spec in self.__events:
177180
ev_type, ev_code = ev_spec[:2]
178181
_libsuinput.suinput_enable_event(self.__uinput_fd, ev_type, ev_code)
@@ -185,10 +188,6 @@ def __init__(self, events, name="python-uinput",
185188

186189
_libsuinput.suinput_create(self.__uinput_fd, ctypes.pointer(user_dev))
187190

188-
@staticmethod
189-
def create_uinput_fd():
190-
return _libsuinput.suinput_open()
191-
192191
def syn(self):
193192
"""Fire all emitted events.
194193

0 commit comments

Comments
 (0)