Skip to content

Commit b7733f5

Browse files
authored
Add files via upload
Fixed bug with xsetwacom listing Intuos Pro 2 tablets as Intuos Pro. Also attempted to fix svg parsing for intuos pro 2 tablets as they are using an ancient format; still has some graphical defects.
1 parent 7321e5c commit b7733f5

File tree

1 file changed

+78
-47
lines changed

1 file changed

+78
-47
lines changed

wacom-gui/wacom_data.py

+78-47
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,16 @@ def get_connected_tablets(self):
6060
pass
6161
self.__get_libwacom_data()
6262
self.tablets = {}
63-
for device in detected.keys():
63+
for device, inputs in detected.iteritems():
6464
if device[-4:] == '(WL)':
6565
dev_type = device[:-5]
6666
else:
6767
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']
6973
if self.device_data[dev_type]['devID'] not in self.tablets.keys():
7074
self.tablets[devID] = []
7175
# assume if it's the same device it has the same inputs for all connected
@@ -74,7 +78,7 @@ def get_connected_tablets(self):
7478
idx = self.tablets[devID].__len__()
7579
self.tablets[devID].append(copy.deepcopy(self.device_data[dev_type]))
7680
self.tablets[devID][idx]['cname'] = device
77-
for dev_input in detected[dev_type]:
81+
for dev_input in inputs:
7882
idx = self.tablets[devID].__len__() - detected[device][dev_input]['id'].__len__()
7983
for instance in sorted(detected[device][dev_input]['id']):
8084
self.tablets[devID][idx][dev_input]['id'] = instance
@@ -235,11 +239,30 @@ def pretty_svg(self, device):
235239
if elem.attrib['id'] in self.device_data[device]['pad']['buttons'].keys():
236240
but_info = self.device_data[device]['pad']['buttons'][elem.attrib['id']]
237241
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'])
240253
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'])
243266
elif elem.tag.split('}')[1] == 'circle':
244267
svg = '%s\n\t\t<circle' % svg
245268
# get attr
@@ -298,54 +321,62 @@ def pretty_svg(self, device):
298321
if yshift > 0:
299322
svg_write = ''
300323
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]
319326
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)
320347
svg = svg_write
321348
# shift x values if it is too wide
322349
if xmax >= 500:
323350
xshift = 300 # shift over by 200 units in the x coord
324351
svg_write = ''
325352
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]
348355
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)
349380
# write top of svg file
350381
if xmax >= 500:
351382
svg = """<svg

0 commit comments

Comments
 (0)