mirror of https://github.com/tuhiproject/tuhi.git
wacom: update the dimensions with the point size
Make sure our dimensions are in actual µm. Note that this will mess with any cached JSON files since they are now on a different scale. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>pull/170/head
parent
643dd34476
commit
92fcfd12cc
|
@ -623,8 +623,8 @@ class Fetcher(Worker):
|
||||||
width, height = 100, 100
|
width, height = 100, 100
|
||||||
else:
|
else:
|
||||||
# Original dimensions are too big for SVG Standard
|
# Original dimensions are too big for SVG Standard
|
||||||
# so we normalize them
|
# so we normalize them to mm
|
||||||
width, height = dimensions[0] / 100, dimensions[1] / 100
|
width, height = dimensions[0] / 1000, dimensions[1] / 1000
|
||||||
|
|
||||||
if self.orientation in ['Portrait', 'Reverse-Portrait']:
|
if self.orientation in ['Portrait', 'Reverse-Portrait']:
|
||||||
svg = svgwrite.Drawing(filename=filename, size=(height, width))
|
svg = svgwrite.Drawing(filename=filename, size=(height, width))
|
||||||
|
@ -640,7 +640,7 @@ class Fetcher(Worker):
|
||||||
|
|
||||||
x, y = p['position']
|
x, y = p['position']
|
||||||
# Normalize coordinates too
|
# Normalize coordinates too
|
||||||
x, y = x / 100, y / 100
|
x, y = x / 1000, y / 1000
|
||||||
|
|
||||||
if self.orientation == 'Reverse-Portrait':
|
if self.orientation == 'Reverse-Portrait':
|
||||||
x, y = y, width - x
|
x, y = y, width - x
|
||||||
|
|
|
@ -40,7 +40,7 @@ class JsonSvg(GObject.Object):
|
||||||
else:
|
else:
|
||||||
# Original dimensions are too big for SVG Standard
|
# Original dimensions are too big for SVG Standard
|
||||||
# so we normalize them
|
# so we normalize them
|
||||||
width, height = dimensions[0] / 100, dimensions[1] / 100
|
width, height = dimensions[0] / 1000, dimensions[1] / 1000
|
||||||
|
|
||||||
if self.orientation in ['portrait', 'reverse-Portrait']:
|
if self.orientation in ['portrait', 'reverse-Portrait']:
|
||||||
size = (height, width)
|
size = (height, width)
|
||||||
|
@ -56,7 +56,7 @@ class JsonSvg(GObject.Object):
|
||||||
|
|
||||||
x, y = p['position']
|
x, y = p['position']
|
||||||
# Normalize coordinates too
|
# Normalize coordinates too
|
||||||
x, y = x / 100, y / 100
|
x, y = x / 1000, y / 1000
|
||||||
|
|
||||||
if self.orientation == 'reverse-portrait':
|
if self.orientation == 'reverse-portrait':
|
||||||
x, y = y, width - x
|
x, y = y, width - x
|
||||||
|
|
|
@ -711,10 +711,15 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
||||||
logger.info(f'device name is {name}')
|
logger.info(f'device name is {name}')
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def get_dimensions(self):
|
def update_dimensions(self):
|
||||||
w = self.p.execute(Interactions.GET_WIDTH).width
|
w = self.p.execute(Interactions.GET_WIDTH).width
|
||||||
h = self.p.execute(Interactions.GET_HEIGHT).height
|
h = self.p.execute(Interactions.GET_HEIGHT).height
|
||||||
logger.info(f'dimensions: {w}x{h}')
|
ps = self.p.execute(Interactions.GET_POINT_SIZE).point_size
|
||||||
|
logger.info(f'dimensions: {w}x{h}, point size {ps}µm')
|
||||||
|
self.point_size = ps
|
||||||
|
self.width = w * ps
|
||||||
|
self.height = h * ps
|
||||||
|
self.notify('dimensions')
|
||||||
return w, h
|
return w, h
|
||||||
|
|
||||||
def select_transfer_gatt(self):
|
def select_transfer_gatt(self):
|
||||||
|
@ -790,6 +795,7 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
||||||
self.set_time()
|
self.set_time()
|
||||||
battery, charging = self.get_battery_info()
|
battery, charging = self.get_battery_info()
|
||||||
self.emit('battery-status', battery, charging)
|
self.emit('battery-status', battery, charging)
|
||||||
|
self.update_dimensions()
|
||||||
if self.read_offline_data() == 0:
|
if self.read_offline_data() == 0:
|
||||||
logger.info('no data to retrieve')
|
logger.info('no data to retrieve')
|
||||||
except WacomEEAGAINException:
|
except WacomEEAGAINException:
|
||||||
|
@ -838,6 +844,7 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
drawing = Drawing(self.device.name, (self.width, self.height), timestamp)
|
drawing = Drawing(self.device.name, (self.width, self.height), timestamp)
|
||||||
|
ps = self.point_size
|
||||||
|
|
||||||
while offset < len(data):
|
while offset < len(data):
|
||||||
packet = WacomPacket(data[offset:])
|
packet = WacomPacket(data[offset:])
|
||||||
|
@ -856,6 +863,7 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
||||||
if stroke is None:
|
if stroke is None:
|
||||||
stroke = drawing.new_stroke()
|
stroke = drawing.new_stroke()
|
||||||
|
|
||||||
|
# data is in device units
|
||||||
x, dx, xrel = self.get_coordinate(packet.bitmask, 0, packet.args, x, dx)
|
x, dx, xrel = self.get_coordinate(packet.bitmask, 0, packet.args, x, dx)
|
||||||
y, dy, yrel = self.get_coordinate(packet.bitmask, 1, packet.args, y, dy)
|
y, dy, yrel = self.get_coordinate(packet.bitmask, 1, packet.args, y, dy)
|
||||||
p, dp, prel = self.get_coordinate(packet.bitmask, 2, packet.args, p, dp)
|
p, dp, prel = self.get_coordinate(packet.bitmask, 2, packet.args, p, dp)
|
||||||
|
@ -876,7 +884,8 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
||||||
NORMALIZED_RANGE = 0x10000
|
NORMALIZED_RANGE = 0x10000
|
||||||
return NORMALIZED_RANGE * p / self.pressure
|
return NORMALIZED_RANGE * p / self.pressure
|
||||||
|
|
||||||
stroke.new_abs((x, y), normalize(p))
|
# now convert to actual µm
|
||||||
|
stroke.new_abs((x * ps, y * ps), normalize(p))
|
||||||
|
|
||||||
drawing.seal()
|
drawing.seal()
|
||||||
return drawing
|
return drawing
|
||||||
|
@ -907,6 +916,7 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
||||||
self.read_time()
|
self.read_time()
|
||||||
self.get_name()
|
self.get_name()
|
||||||
self.get_firmware_version()
|
self.get_firmware_version()
|
||||||
|
self.update_dimensions()
|
||||||
|
|
||||||
def live_mode(self, mode, uhid):
|
def live_mode(self, mode, uhid):
|
||||||
try:
|
try:
|
||||||
|
@ -975,8 +985,7 @@ class WacomProtocolSlate(WacomProtocolSpark):
|
||||||
# Slate tablet has two models A5 and A4
|
# Slate tablet has two models A5 and A4
|
||||||
# Here, we read real tablet dimensions before
|
# Here, we read real tablet dimensions before
|
||||||
# starting live mode
|
# starting live mode
|
||||||
self.width, self.height = self.get_dimensions()
|
self.update_dimensions()
|
||||||
self.notify('dimensions')
|
|
||||||
self.x_max = self.width - 1000
|
self.x_max = self.width - 1000
|
||||||
self.y_max = self.height - 500
|
self.y_max = self.height - 500
|
||||||
|
|
||||||
|
@ -990,10 +999,7 @@ class WacomProtocolSlate(WacomProtocolSpark):
|
||||||
self.read_time()
|
self.read_time()
|
||||||
self.select_transfer_gatt()
|
self.select_transfer_gatt()
|
||||||
self.get_name()
|
self.get_name()
|
||||||
|
self.update_dimensions()
|
||||||
w, h = self.get_dimensions()
|
|
||||||
if self.width != w or self.height != h:
|
|
||||||
logger.error(f'incompatible dimensions: {w}x{h}')
|
|
||||||
self.notify('dimensions')
|
self.notify('dimensions')
|
||||||
|
|
||||||
self.get_firmware_version()
|
self.get_firmware_version()
|
||||||
|
@ -1006,9 +1012,7 @@ class WacomProtocolSlate(WacomProtocolSpark):
|
||||||
self.set_time()
|
self.set_time()
|
||||||
battery, charging = self.get_battery_info()
|
battery, charging = self.get_battery_info()
|
||||||
self.emit('battery-status', battery, charging)
|
self.emit('battery-status', battery, charging)
|
||||||
w, h = self.get_dimensions()
|
self.update_dimensions()
|
||||||
self.width = w
|
|
||||||
self.height = h
|
|
||||||
self.notify('dimensions')
|
self.notify('dimensions')
|
||||||
|
|
||||||
self.get_firmware_version()
|
self.get_firmware_version()
|
||||||
|
|
Loading…
Reference in New Issue