From a336facf6fd53ba73fc812c2b3c507c01c8f8111 Mon Sep 17 00:00:00 2001 From: Demon000 Date: Mon, 18 Feb 2019 14:10:57 +0200 Subject: [PATCH] Return the number of bytes written from all mouse commands --- rivalcfg/mouse.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rivalcfg/mouse.py b/rivalcfg/mouse.py index 557b96c5..684514d2 100644 --- a/rivalcfg/mouse.py +++ b/rivalcfg/mouse.py @@ -44,6 +44,8 @@ def _device_write(self, bytes_, report_type=usbhid.HID_REPORT_TYPE_OUTPUT): :param bytes bytes_: bytes to write :param int report_type: the HID Repport Type (0x02: output (default), 0x03: feature) + + :returns int: the number of bytes written, or -1 on failure. """ report_id = 0x00 if debug.DEBUG: @@ -55,7 +57,7 @@ def _device_write(self, bytes_, report_type=usbhid.HID_REPORT_TYPE_OUTPUT): report_function = getattr( self._device, REPORT_TYPE_TO_HIDAPI_FUNCTION[report_type]) - report_function(bytearray(bytes_)) + return report_function(bytearray(bytes_)) def __getattr__(self, name): if name not in self.profile["commands"]: @@ -86,7 +88,7 @@ def __getattr__(self, name): def _exec_command(*args): bytes_ = getattr(command_handlers, handler)(command, *args) bytes_ = helpers.merge_bytes(bytes_, suffix) - self._device_write(bytes_, report_type) + return self._device_write(bytes_, report_type) return _exec_command