Skip sensorIdx in getSensorDpiList response

This commit is contained in:
Peter Wu 2016-03-24 15:13:06 +01:00
parent dd2755909d
commit aa7d1b6410
1 changed files with 4 additions and 3 deletions

View File

@ -26,6 +26,7 @@ from . import hidpp20 as _hidpp20
from .common import ( from .common import (
bytes2int as _bytes2int, bytes2int as _bytes2int,
NamedInts as _NamedInts, NamedInts as _NamedInts,
unpack as _unpack,
) )
from .settings import ( from .settings import (
KIND as _KIND, KIND as _KIND,
@ -171,12 +172,12 @@ def _feature_adjustable_dpi_choices(device):
assert reply, 'Oops, DPI list cannot be retrieved!' assert reply, 'Oops, DPI list cannot be retrieved!'
dpi_list = [] dpi_list = []
step = None step = None
for offset in range(0, 14, 2): for val in _unpack('!B7H', reply)[1:]:
val = _bytes2int(reply[offset:offset+2])
if val == 0: if val == 0:
break break
if val >> 13 == 0b111: if val >> 13 == 0b111:
assert offset == 2, 'Invalid DPI list item: %r' % val assert step is None and len(dpi_list) == 1, \
'Invalid DPI list item: %r' % val
step = val & 0x1fff step = val & 0x1fff
else: else:
dpi_list.append(val) dpi_list.append(val)