don't use notification flags with HID++ 2.0 devices

This commit is contained in:
Daniel Pavel 2013-06-01 15:07:39 +02:00
parent 788fb145af
commit 83a29328c7
3 changed files with 13 additions and 3 deletions

View File

@ -177,6 +177,11 @@ def get_firmware(device):
def get_notification_flags(device):
if device.kind:
p = device.protocol
if p is None or p >= 2.0:
return
flags = device.request(0x8100)
if flags is not None:
assert len(flags) == 3
@ -184,6 +189,11 @@ def get_notification_flags(device):
def set_notification_flags(device, *flag_bits):
if device.kind:
p = device.protocol
if p is None or p >= 2.0:
return
flag_bits = sum(int(b) for b in flag_bits)
result = device.request(0x8000, 0xFF & (flag_bits >> 16), 0xFF & (flag_bits >> 8), 0xFF & flag_bits)
return result is not None

View File

@ -40,7 +40,7 @@ FEATURE = _NamedInts(
ROOT=0x0000,
FEATURE_SET=0x0001,
FEATURE_INFO=0x0002,
DEVICE_FW_VERSION=0x0003,
DEVICE_FW_VERSION=0x0003,
DEVICE_NAME=0x0005,
DEVICE_GROUPS=0x0006,
DFUCONTROL=0x00C0,
@ -129,7 +129,7 @@ class FeatureCallError(_KwException):
class FeaturesArray(object):
"""A sequence of features supported by a HID++ 2.0 device."""
__slots__ = ('supported', 'device', 'features')
assert int(FEATURE.ROOT) == 0x0000
assert FEATURE.ROOT == 0x0000
def __init__(self, device):
assert device is not None

View File

@ -167,7 +167,7 @@ class PairedDevice(object):
def enable_notifications(self, enable=True):
"""Enable or disable device (dis)connection notifications on this
receiver."""
if not self.receiver or not self.receiver.handle:
if not self.receiver or not self.receiver.handle or self.protocol >= 2.0:
return False
if enable: