Commit ae696dba authored by Benjamin Tissoires's avatar Benjamin Tissoires

HID: allow null main usages to be out of logical bounds

We still check if we can represent the number with the given bits.
Signed-off-by: Benjamin Tissoires's avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
parent 2b5d434c
......@@ -844,7 +844,12 @@ class HidField(object):
for idx in range(self.count):
v = data[idx]
if self.usage_name not in ['Contact Id', 'Contact Max', 'Contact Count']:
if self.is_null:
# FIXME: handle the signed case too
if v >= (1 << self.size):
raise RangeError(self, v)
elif self.usage_name not in ['Contact Id', 'Contact Max', 'Contact Count']:
if v < self.logical_min or v > self.logical_max:
raise RangeError(self, v)
if self.logical_min < 0:
......@@ -865,6 +870,13 @@ class HidField(object):
"""
return self.type & (0x1 << 0)
@property
def is_null(self):
"""
``True`` if this HID field is null
"""
return self.type & (0x1 << 6)
@property
def usage_page_name(self):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment