device: pass protocol to base request so that SW ID can be done right

This commit is contained in:
Peter F. Patel-Schneider 2021-08-25 13:40:50 -04:00
parent a7ddb3efdd
commit c02a1b820b
2 changed files with 4 additions and 4 deletions

View File

@ -381,7 +381,7 @@ def acquire_timeout(lock, handle, timeout):
# a very few requests (e.g., host switching) do not expect a reply, but use no_reply=True with extreme caution
def request(handle, devnumber, request_id, *params, no_reply=False, return_error=False, long_message=False):
def request(handle, devnumber, request_id, *params, no_reply=False, return_error=False, long_message=False, protocol=1.0):
"""Makes a feature call to a device and waits for a matching reply.
:param handle: an open UR handle.
:param devnumber: attached device number.
@ -395,7 +395,7 @@ def request(handle, devnumber, request_id, *params, no_reply=False, return_error
with acquire_timeout(handle_lock(handle), handle, 10.):
assert isinstance(request_id, int)
if devnumber != 0xFF and request_id < 0x8000:
if (devnumber != 0xFF or protocol >= 2.0) and request_id < 0x8000:
# For HID++ 2.0 feature requests, randomize the SoftwareId to make it
# easier to recognize the reply for this request. also, always set the
# most significant bit (8) in SoftwareId, to make notifications easier

View File

@ -433,7 +433,6 @@ class Device(object):
return None
def request(self, request_id, *params, no_reply=False):
if self:
return _base.request(
self.handle or self.receiver.handle,
@ -441,7 +440,8 @@ class Device(object):
request_id,
*params,
no_reply=no_reply,
long_message=self.bluetooth or self.protocol >= 2.0
long_message=self.bluetooth or self.protocol >= 2.0,
protocol=self.protocol
)
def feature_request(self, feature, function=0x00, *params, no_reply=False):