diff --git a/tuhi/base.py b/tuhi/base.py index 6da96d7..ba9f2e7 100644 --- a/tuhi/base.py +++ b/tuhi/base.py @@ -167,7 +167,10 @@ class TuhiDevice(GObject.Object): self._tuhi_dbus_device.notify_button_press_required() def _on_uuid_updated(self, wacom_device, pspec, bluez_device): - self.config.new_device(bluez_device.address, wacom_device.uuid) + protocol = TuhiConfig.Protocol.SLATE + if wacom_device.is_spark(): + protocol = TuhiConfig.Protocol.SPARK + self.config.new_device(bluez_device.address, wacom_device.uuid, protocol) self.registered = True def _on_listening_updated(self, dbus_device, pspec): @@ -287,7 +290,7 @@ class Tuhi(GObject.Object): if uuid is None: logger.info(f'{bluez_device.address}: device without config, must be registered first') return - logger.debug(f'{bluez_device.address}: UUID {uuid}') + logger.debug(f'{bluez_device.address}: UUID {uuid} protocol: {config["Protocol"]}') # create the device if unknown from us if bluez_device.address not in self.devices: diff --git a/tuhi/config.py b/tuhi/config.py index 8be0bed..4995b75 100644 --- a/tuhi/config.py +++ b/tuhi/config.py @@ -16,6 +16,7 @@ from gi.repository import GObject import xdg.BaseDirectory import os import configparser +import enum import re import logging from .drawing import Drawing @@ -30,6 +31,13 @@ def is_btaddr(addr): class TuhiConfig(GObject.Object): + + class Protocol(enum.Enum): + UNKNOWN = 0 + SPARK = 1 + SLATE = 2 + INTUOS_PRO = 3 + def __init__(self): GObject.Object.__init__(self) try: @@ -67,9 +75,11 @@ class TuhiConfig(GObject.Object): self._purge_drawings(entry) assert config['Device']['Address'] == entry.name + if 'Protocol' not in config['Device']: + config['Device']['Protocol'] = str(TuhiConfig.Protocol.UNKNOWN) self._devices[entry.name] = config['Device'] - def new_device(self, address, uuid): + def new_device(self, address, uuid, protocol): assert is_btaddr(address) assert len(uuid) == 12 @@ -92,6 +102,7 @@ class TuhiConfig(GObject.Object): config['Device'] = { 'Address': address, 'UUID': uuid, + 'Protocol': protocol, } with open(path, 'w') as configfile: