wacom: don't add points to the log until we have an absolute value
On the Intuos Pro at least we sometimes get events that are all relative at first and it can take several events for us to have all three values as absolute. This is likely a parsing error on our side, but meanwhile don't write the data until we have at least one known value for all three axes. And because the SVG writer isn't happy with empty strokes, add a seal() function to the drawing to purge empty strokes. Fixed #92 or at least works around it
This commit is contained in:
parent
6c156efc01
commit
7796d3c110
|
@ -86,6 +86,10 @@ class Drawing(GObject.Object):
|
|||
self.strokes = []
|
||||
self._current_stroke = -1
|
||||
|
||||
def seal(self):
|
||||
# Drop empty strokes
|
||||
self.strokes = [s for s in self.strokes if s.points]
|
||||
|
||||
# The way we're building drawings, we don't need to change the current
|
||||
# stroke at runtime, so this is read-ony
|
||||
@GObject.Property
|
||||
|
|
|
@ -618,6 +618,8 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
|||
|
||||
drawing = Drawing(self.device.name, (self.width, self.height), timestamp)
|
||||
|
||||
have_abs = 0x00 # bitmask 3-bits: pyx
|
||||
|
||||
while offset < len(data):
|
||||
bitmask, opcode, raw_args, args, offset = self.next_pen_data(data, offset)
|
||||
|
||||
|
@ -650,11 +652,27 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
|||
|
||||
if bitmask & 0b00111100 == 0:
|
||||
continue
|
||||
|
||||
if not xrel:
|
||||
have_abs |= 0x1
|
||||
if not yrel:
|
||||
have_abs |= 0x2
|
||||
if not prel:
|
||||
have_abs |= 0x4
|
||||
|
||||
if xrel or yrel or prel:
|
||||
if not stroke.points:
|
||||
if have_abs == 0x7:
|
||||
logger.info('Forcing first point to be absolute')
|
||||
stroke.new_abs((x, y), p)
|
||||
else:
|
||||
logger.warning('First point in stroke is relative, skipping')
|
||||
continue
|
||||
stroke.new_rel((dx, dy), dp)
|
||||
else:
|
||||
stroke.new_abs((x, y), p)
|
||||
|
||||
drawing.seal()
|
||||
return drawing
|
||||
|
||||
def read_offline_data(self):
|
||||
|
|
Loading…
Reference in New Issue