diff --git a/tuhi.py b/tuhi.py index 7eb8c05..811ee91 100755 --- a/tuhi.py +++ b/tuhi.py @@ -48,10 +48,10 @@ class TuhiDrawing(object): d[key] = val return d - def __init__(self, name, dimensions): + def __init__(self, name, dimensions, timestamp): self.name = name self.dimensions = dimensions - self.timestamp = 0 + self.timestamp = timestamp self.strokes = [] def json(self): @@ -61,6 +61,7 @@ class TuhiDrawing(object): 'version': JSON_FILE_FORMAT_VERSION, 'devicename': self.name, 'dimensions': list(self.dimensions), + 'timestamp': self.timestamp, 'strokes': [s.to_dict() for s in self.strokes] } return json.dumps(json_data) @@ -95,7 +96,7 @@ class TuhiDevice(GObject.Object): def _on_drawing_received(self, device, drawing): logger.debug('Drawing received') - d = TuhiDrawing(device.name, (0, 0)) + d = TuhiDrawing(device.name, (0, 0), drawing.timestamp) for s in drawing: stroke = TuhiDrawing.Stroke() lastx, lasty, lastp = None, None, None diff --git a/tuhi/wacom.py b/tuhi/wacom.py index b9b1eed..511f21a 100644 --- a/tuhi/wacom.py +++ b/tuhi/wacom.py @@ -461,10 +461,15 @@ class WacomDevice(GObject.Object): return v, dv, is_rel def parse_pen_data(self, data, timestamp): + """ + :param timestamp: a tuple with 9 entries, corresponding to the + local time + """ offset = 0 x, y, p = 0, 0, 0 dx, dy, dp = 0, 0, 0 + timestamp = int(time.mktime(timestamp)) drawings = [] drawing = None stroke = None