Skip to content

Commit c119081

Browse files
authored
Merge pull request #137 from tlalexander/master
Add missing return codes to os.strerror() calls and fix force feedback example in docs.
2 parents 862c411 + 148e6e0 commit c119081

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

docs/tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,13 @@ Create ``uinput`` device capable of receiving FF-effects
385385
# Wait for an EV_UINPUT event that will signal us that an
386386
# effect upload/erase operation is in progress.
387387
if event.type != ecodes.EV_UINPUT:
388-
pass
388+
continue
389389

390390
if event.code == ecodes.UI_FF_UPLOAD:
391391
upload = device.begin_upload(event.value)
392392
upload.retval = 0
393393

394-
print(f'[upload] effect_id: {upload.effect_id}, type: {upload.effect.type}')
394+
print(f'[upload] effect_id: {upload.effect.id}, type: {upload.effect.type}')
395395
device.end_upload(upload)
396396

397397
elif event.code == ecodes.UI_FF_ERASE:

evdev/uinput.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,26 +229,30 @@ def begin_upload(self, effect_id):
229229
upload = ff.UInputUpload()
230230
upload.effect_id = effect_id
231231

232-
if self.dll._uinput_begin_upload(self.fd, ctypes.byref(upload)):
233-
raise UInputError('Failed to begin uinput upload: ' + os.strerror())
232+
ret = self.dll._uinput_begin_upload(self.fd, ctypes.byref(upload))
233+
if ret:
234+
raise UInputError('Failed to begin uinput upload: ' + os.strerror(ret))
234235

235236
return upload
236237

237238
def end_upload(self, upload):
238-
if self.dll._uinput_end_upload(self.fd, ctypes.byref(upload)):
239-
raise UInputError('Failed to end uinput upload: ' + os.strerror())
239+
ret = self.dll._uinput_end_upload(self.fd, ctypes.byref(upload))
240+
if ret:
241+
raise UInputError('Failed to end uinput upload: ' + os.strerror(ret))
240242

241243
def begin_erase(self, effect_id):
242244
erase = ff.UInputErase()
243245
erase.effect_id = effect_id
244246

245-
if self.dll._uinput_begin_erase(self.fd, ctypes.byref(erase)):
246-
raise UInputError('Failed to begin uinput erase: ' + os.strerror())
247+
ret = self.dll._uinput_begin_erase(self.fd, ctypes.byref(erase))
248+
if ret:
249+
raise UInputError('Failed to begin uinput erase: ' + os.strerror(ret))
247250
return erase
248251

249252
def end_erase(self, erase):
250-
if self.dll._uinput_end_erase(self.fd, ctypes.byref(erase)):
251-
raise UInputError('Failed to end uinput erase: ' + os.strerror())
253+
ret = self.dll._uinput_end_erase(self.fd, ctypes.byref(erase))
254+
if ret:
255+
raise UInputError('Failed to end uinput erase: ' + os.strerror(ret))
252256

253257
def _verify(self):
254258
'''

0 commit comments

Comments
 (0)