diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 92a8780..fc0e3e0 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -385,13 +385,13 @@ Create ``uinput`` device capable of receiving FF-effects # Wait for an EV_UINPUT event that will signal us that an # effect upload/erase operation is in progress. if event.type != ecodes.EV_UINPUT: - pass + continue if event.code == ecodes.UI_FF_UPLOAD: upload = device.begin_upload(event.value) upload.retval = 0 - print(f'[upload] effect_id: {upload.effect_id}, type: {upload.effect.type}') + print(f'[upload] effect_id: {upload.effect.id}, type: {upload.effect.type}') device.end_upload(upload) elif event.code == ecodes.UI_FF_ERASE: diff --git a/evdev/uinput.py b/evdev/uinput.py index 8b9a597..0dc5f89 100644 --- a/evdev/uinput.py +++ b/evdev/uinput.py @@ -229,26 +229,30 @@ def begin_upload(self, effect_id): upload = ff.UInputUpload() upload.effect_id = effect_id - if self.dll._uinput_begin_upload(self.fd, ctypes.byref(upload)): - raise UInputError('Failed to begin uinput upload: ' + os.strerror()) + ret = self.dll._uinput_begin_upload(self.fd, ctypes.byref(upload)) + if ret: + raise UInputError('Failed to begin uinput upload: ' + os.strerror(ret)) return upload def end_upload(self, upload): - if self.dll._uinput_end_upload(self.fd, ctypes.byref(upload)): - raise UInputError('Failed to end uinput upload: ' + os.strerror()) + ret = self.dll._uinput_end_upload(self.fd, ctypes.byref(upload)) + if ret: + raise UInputError('Failed to end uinput upload: ' + os.strerror(ret)) def begin_erase(self, effect_id): erase = ff.UInputErase() erase.effect_id = effect_id - if self.dll._uinput_begin_erase(self.fd, ctypes.byref(erase)): - raise UInputError('Failed to begin uinput erase: ' + os.strerror()) + ret = self.dll._uinput_begin_erase(self.fd, ctypes.byref(erase)) + if ret: + raise UInputError('Failed to begin uinput erase: ' + os.strerror(ret)) return erase def end_erase(self, erase): - if self.dll._uinput_end_erase(self.fd, ctypes.byref(erase)): - raise UInputError('Failed to end uinput erase: ' + os.strerror()) + ret = self.dll._uinput_end_erase(self.fd, ctypes.byref(erase)) + if ret: + raise UInputError('Failed to end uinput erase: ' + os.strerror(ret)) def _verify(self): '''