Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the number of bytes written from all mouse commands #76

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rivalcfg/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"]:
Expand Down Expand Up @@ -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

Expand Down