From 764ad45ca2c0c549443baed1270cb32b8490c3e2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 19 Jul 2019 13:49:36 +1000 Subject: [PATCH] wacom: normalize the pressure to the advertised [0, 0xffff] range This requires adjusting the svg conversion in kete as well, afaict the 1000 range there was chosen because it's (almost) the midpoint of the Bamboo series with 2048 pressure grades. So let's use half of 0x10000 instead, which is approximately 0x8000 as the crow flies. Fixes #142 --- tools/kete.py | 3 ++- tuhi/wacom.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/kete.py b/tools/kete.py index 9810c7d..751493a 100755 --- a/tools/kete.py +++ b/tools/kete.py @@ -629,7 +629,8 @@ class Fetcher(Worker): elif self.orientation == 'Reverse-Landscape': x, y = width - x, height - y - delta = (p['pressure'] - 1000.0) / 1000.0 + # Pressure normalized range is [0, 0xffff] + delta = (p['pressure'] - 0x8000) / 0x8000 stroke_width = 0.4 + 0.20 * delta points_with_sk_width.append((x, y, stroke_width)) diff --git a/tuhi/wacom.py b/tuhi/wacom.py index 67eaf24..9ca68f9 100644 --- a/tuhi/wacom.py +++ b/tuhi/wacom.py @@ -963,7 +963,11 @@ class WacomProtocolBase(WacomProtocolLowLevelComm): if packet.bitmask & 0b00111100 == 0: continue - stroke.new_abs((x, y), p) + def normalize(p): + NORMALIZED_RANGE = 0x10000 + return NORMALIZED_RANGE * p / self.pressure + + stroke.new_abs((x, y), normalize(p)) drawing.seal() return drawing