@@ -60,12 +60,16 @@ def get_connected_tablets(self):
60
60
pass
61
61
self .__get_libwacom_data ()
62
62
self .tablets = {}
63
- for device in detected .keys ():
63
+ for device , inputs in detected .iteritems ():
64
64
if device [- 4 :] == '(WL)' :
65
65
dev_type = device [:- 5 ]
66
66
else :
67
67
dev_type = device
68
- devID = self .device_data [dev_type ]['devID' ]
68
+ try :
69
+ devID = self .device_data [dev_type ]['devID' ]
70
+ except :
71
+ dev_type = dev_type .replace ("Pro" , "Pro 2" )
72
+ devID = self .device_data [dev_type ]['devID' ]
69
73
if self .device_data [dev_type ]['devID' ] not in self .tablets .keys ():
70
74
self .tablets [devID ] = []
71
75
# assume if it's the same device it has the same inputs for all connected
@@ -74,7 +78,7 @@ def get_connected_tablets(self):
74
78
idx = self .tablets [devID ].__len__ ()
75
79
self .tablets [devID ].append (copy .deepcopy (self .device_data [dev_type ]))
76
80
self .tablets [devID ][idx ]['cname' ] = device
77
- for dev_input in detected [ dev_type ] :
81
+ for dev_input in inputs :
78
82
idx = self .tablets [devID ].__len__ () - detected [device ][dev_input ]['id' ].__len__ ()
79
83
for instance in sorted (detected [device ][dev_input ]['id' ]):
80
84
self .tablets [devID ][idx ][dev_input ]['id' ] = instance
@@ -235,11 +239,30 @@ def pretty_svg(self, device):
235
239
if elem .attrib ['id' ] in self .device_data [device ]['pad' ]['buttons' ].keys ():
236
240
but_info = self .device_data [device ]['pad' ]['buttons' ][elem .attrib ['id' ]]
237
241
if but_info ['orient' ] in ['Left' , 'Right' ]:
238
- self .device_data [device ]['pad' ]['buttons' ][elem .attrib ['id' ]]['pos' ] = \
239
- "%06.f" % float (elem .attrib ['y' ])
242
+ if 'y' in elem .attrib .keys ():
243
+ self .device_data [device ]['pad' ]['buttons' ][elem .attrib ['id' ]]['pos' ] = \
244
+ "%06.f" % float (elem .attrib ['y' ])
245
+ elif 'd' in elem .attrib .keys ():
246
+ d = elem .attrib ['d' ].split (' ' )
247
+ if d [1 ].find (',' ) != - 1 :
248
+ elem .attrib ['y' ] = d [1 ].split (',' )[1 ]
249
+ else :
250
+ elem .attrib ['y' ] = d [2 ]
251
+ self .device_data [device ]['pad' ]['buttons' ][elem .attrib ['id' ]]['pos' ] = \
252
+ "%06.f" % float (elem .attrib ['y' ])
240
253
else :
241
- self .device_data [device ]['pad' ]['buttons' ][elem .attrib ['id' ]]['pos' ] = \
242
- "%06.f" % float (elem .attrib ['x' ])
254
+ if 'x' in elem .attrib .keys ():
255
+ self .device_data [device ]['pad' ]['buttons' ][elem .attrib ['id' ]]['pos' ] = \
256
+ "%06.f" % float (elem .attrib ['x' ])
257
+ elif 'd' in elem .attrib .keys ():
258
+ d = elem .attrib ['d' ].split (' ' )
259
+ if d [1 ].find (',' ) != - 1 :
260
+ elem .attrib ['x' ] = d [1 ].split (',' )[0 ]
261
+ else :
262
+ elem .attrib ['x' ] = d [1 ]
263
+ elem .attrib ['x' ] = elem .attrib ['d' ].split (' ' )[1 ]
264
+ self .device_data [device ]['pad' ]['buttons' ][elem .attrib ['id' ]]['pos' ] = \
265
+ "%06.f" % float (elem .attrib ['x' ])
243
266
elif elem .tag .split ('}' )[1 ] == 'circle' :
244
267
svg = '%s\n \t \t <circle' % svg
245
268
# get attr
@@ -298,54 +321,62 @@ def pretty_svg(self, device):
298
321
if yshift > 0 :
299
322
svg_write = ''
300
323
for line in svg .split ('\n ' ):
301
- if 'y="' in line and 'ry' not in line :
302
- val = line .split ('"' )
303
- svg_write = "%s\n %s\" %d\" " % (svg_write , val [0 ], float (val [1 ]) - yshift )
304
- elif 'd="' in line and 'id="' not in line :
305
- val = line .split ('"' )
306
- points = val [1 ].split ()
307
- subs = [" " .join (points [i :i + 3 ]) for i in range (0 , len (points ), 3 )]
308
- d = "%s\" " % val [0 ]
309
- for sub in subs :
310
- if sub [0 ] == 'M' or sub [0 ] == 'L' :
311
- attrs = sub .split ()
312
- attrs [2 ] = str (float (attrs [2 ]) - float (yshift ))
313
- d = "%s %s" % (d , " " .join (attrs ))
314
- else :
315
- d = "%s %s" % (d , sub )
316
- d = "%s\" " % d
317
- svg_write = "%s\n %s" % (svg_write , d )
318
- else :
324
+ if 'sodipodi' in line :
325
+ line = "sodipodi:%s" % line .split ('}' )[1 ]
319
326
svg_write = "%s\n %s" % (svg_write , line )
327
+ else :
328
+ if 'y="' in line and 'ry' not in line :
329
+ val = line .split ('"' )
330
+ svg_write = "%s\n %s\" %d\" " % (svg_write , val [0 ], float (val [1 ]) - yshift )
331
+ elif 'd="' in line and 'id="' not in line :
332
+ val = line .split ('"' )
333
+ points = val [1 ].split ()
334
+ subs = [" " .join (points [i :i + 3 ]) for i in range (0 , len (points ), 3 )]
335
+ d = "%s\" " % val [0 ]
336
+ for sub in subs :
337
+ if sub [0 ] == 'M' or sub [0 ] == 'L' :
338
+ attrs = sub .split ()
339
+ attrs [2 ] = str (float (attrs [2 ]) - float (yshift ))
340
+ d = "%s %s" % (d , " " .join (attrs ))
341
+ else :
342
+ d = "%s %s" % (d , sub )
343
+ d = "%s\" " % d
344
+ svg_write = "%s\n %s" % (svg_write , d )
345
+ else :
346
+ svg_write = "%s\n %s" % (svg_write , line )
320
347
svg = svg_write
321
348
# shift x values if it is too wide
322
349
if xmax >= 500 :
323
350
xshift = 300 # shift over by 200 units in the x coord
324
351
svg_write = ''
325
352
for line in svg .split ('\n ' ):
326
- if 'x="' in line and 'rx' not in line :
327
- val = line .split ('"' )
328
- if float (val [1 ]) >= 500.0 :
329
- svg_write = "%s\n %s\" %d\" " % (svg_write , val [0 ], float (val [1 ]) - xshift )
330
- else :
331
- svg_write = "%s\n %s\" %d\" " % (svg_write , val [0 ], float (val [1 ]))
332
- elif 'd="' in line and 'id="' not in line :
333
- val = line .split ('"' )
334
- points = val [1 ].split ()
335
- subs = [" " .join (points [i :i + 3 ]) for i in range (0 , len (points ), 3 )]
336
- d = "%s\" " % val [0 ]
337
- for sub in subs :
338
- if sub [0 ] == 'M' or sub [0 ] == 'L' :
339
- attrs = sub .split ()
340
- if float (attrs [1 ]) >= 500.0 :
341
- attrs [1 ] = str (float (attrs [1 ]) - float (xshift ))
342
- d = "%s %s" % (d , " " .join (attrs ))
343
- else :
344
- d = "%s %s" % (d , sub )
345
- d = "%s\" " % d
346
- svg_write = "%s\n %s" % (svg_write , d )
347
- else :
353
+ if 'sodipodi' in line :
354
+ line = "sodipodi:%s" % line .split ('}' )[1 ]
348
355
svg_write = "%s\n %s" % (svg_write , line )
356
+ else :
357
+ if 'x="' in line and 'rx' not in line :
358
+ val = line .split ('"' )
359
+ if float (val [1 ]) >= 500.0 :
360
+ svg_write = "%s\n %s\" %d\" " % (svg_write , val [0 ], float (val [1 ]) - xshift )
361
+ else :
362
+ svg_write = "%s\n %s\" %d\" " % (svg_write , val [0 ], float (val [1 ]))
363
+ elif 'd="' in line and 'id="' not in line :
364
+ val = line .split ('"' )
365
+ points = val [1 ].split ()
366
+ subs = [" " .join (points [i :i + 3 ]) for i in range (0 , len (points ), 3 )]
367
+ d = "%s\" " % val [0 ]
368
+ for sub in subs :
369
+ if sub [0 ] == 'M' or sub [0 ] == 'L' :
370
+ attrs = sub .split ()
371
+ if float (attrs [1 ]) >= 500.0 :
372
+ attrs [1 ] = str (float (attrs [1 ]) - float (xshift ))
373
+ d = "%s %s" % (d , " " .join (attrs ))
374
+ else :
375
+ d = "%s %s" % (d , sub )
376
+ d = "%s\" " % d
377
+ svg_write = "%s\n %s" % (svg_write , d )
378
+ else :
379
+ svg_write = "%s\n %s" % (svg_write , line )
349
380
# write top of svg file
350
381
if xmax >= 500 :
351
382
svg = """<svg
0 commit comments