wacom: insert proper ranges for X and Y in the uhid device

Also fix the pressure range to be 2047
pull/77/head
Benjamin Tissoires 2018-02-13 20:01:56 +01:00 committed by Peter Hutterer
parent 99a2f7bdc5
commit 422045e2fd
1 changed files with 22 additions and 5 deletions

View File

@ -77,21 +77,30 @@ wacom_live_rdesc_template = [
0x55, 0x0e, # ..Unit Exponent (-2) 51
0x65, 0x11, # ..Unit (Centimeter,SILinear) 53
0x46, 0xec, 0x09, # ..Physical Maximum (2540) 55
0x26, 0x80, 0x25, # ..Logical Maximum (9600) 58
'width', # ..Logical Maximum (TBD) 58
0x81, 0x02, # ..Input (Data,Var,Abs) 61
0x09, 0x31, # ..Usage (Y) 63
0x46, 0x9d, 0x06, # ..Physical Maximum (1693) 65
0x26, 0x20, 0x1c, # ..Logical Maximum (7200) 68
'height', # ..Logical Maximum (TBD) 68
0x81, 0x02, # ..Input (Data,Var,Abs) 71
0x05, 0x0d, # ..Usage Page (Digitizers) 73
0x09, 0x30, # ..Usage (Tip Pressure) 75
0x26, 0x00, 0x01, # ..Logical Maximum (256) 77
0x26, 0xff, 0x07, # ..Logical Maximum (2047) 77
0x81, 0x02, # ..Input (Data,Var,Abs) 80
0xc0, # .End Collection 82
0xc0, # End Collection 83
]
def flatten(items):
'''flatten an array of mixed int and arrays into a simple array of int'''
for item in items:
if isinstance(item, int):
yield item
else:
yield from flatten(item)
def signed_char_to_int(v):
return int.from_bytes([v], byteorder='little', signed=True)
@ -437,13 +446,21 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
arguments=args)
def start_live(self, fd):
w = self.get_dimensions('width')
h = self.get_dimensions('height')
self.send_nordic_command_sync(command=0xb1,
expected_opcode=0xb3)
logger.debug(f'Starting wacom live mode on fd: {fd}')
rdesc = wacom_live_rdesc_template
rdesc = wacom_live_rdesc_template[:]
for i, v in enumerate(rdesc):
if v == 'width':
rdesc[i] = [0x26, list(int.to_bytes(w, 2, 'little', signed=True))]
elif v == 'height':
rdesc[i] = [0x26, list(int.to_bytes(h, 2, 'little', signed=True))]
uhid_device = UHIDDevice(fd)
uhid_device.rdesc = rdesc
uhid_device.rdesc = list(flatten(rdesc))
uhid_device.name = self.device.name
uhid_device.info = (5, 0x056a, 0x0001)
uhid_device.create_kernel_device()