Commit Graph

60 Commits (master)

Author SHA1 Message Date
Peter Hutterer 27164aba52 Fix flake8 errors - f-string without placeholders
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-22 17:09:27 +10:00
Niclas Hoyer 67eb54c908 Add company ID for Augmented Paper 2020-01-03 10:34:25 +10:00
Peter Hutterer 3e0ba27856 base: set up the loggers a bit more sensibly
Both handlers need to be set up to log at debug level, the logger itself will
filter correctly anyway where verbose isn't given. And we want them both to
log in the same format, so let's re-use the formatter.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:05:17 +10:00
Peter Hutterer e030b0b3ea base: add an argument to peek at the first drawing only
Use --peek to download the first (oldest) drawing on the device but do not
delete it. This is primarily intended as a debugging option, so we can debug
the tablet handling without having to draw new drawings (which cause the
protocol messages to change slightly).

Since the tablet only has a "download oldest file" command this isn't very
useful to end users. If there are two or more files on the tablet, we can only
ever retrieve the oldest one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 09:59:14 +10:00
Peter Hutterer 23989e4291 config: make the TuhiConfig a singleton object too
We only ever have one of those anyway, so let's make it a singleton. This
patch keeps the self.config assignment and config passing to keep the churn at
at a minimum. But this way we can assign runtime options to the config and
have those as globally accessible options.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 09:59:14 +10:00
Peter Hutterer f742779c1a tuhi: log the tuhi server session data to a file
Storage is $XDG_DATA_HOME/tuhi/session-logs/tuhi-$DATE.log
Because it's really useful to have the logs of an old session around when
something goes wrong. Even for simple things like "what uuid was I using
again?"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 15:43:01 +02:00
Peter Hutterer 9ef4002b39 Move the default config setting to the entry points
Have this in the effective main() methods (or close to that anyway) instead of
hidden away in the config implementations.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 15:43:01 +02:00
Peter Hutterer be9b3c02cc base: allow for a None vendor ID
Unsure how to trigger this case but I have all my devices (not recently
connected) with a vendor ID of None.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 15:41:10 +02:00
Peter Hutterer 16c22a95ec base: add a flag to control the config directory
For testing it's a lot easier to just provide a /tmp/ directory than having to
clear out the normal one that may contain useful drawings for debugging.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-13 19:12:53 +10:00
Peter Hutterer ee5640b783 Merge branch 'master' into wip/tuhigui 2019-08-09 15:22:07 +10:00
Peter Hutterer 28cb94bc89 base: fix failing registration of new devices
Regression introduced in e1a3675439

Where a device has no config entry, the e1a367 change would return early. This
is fine for devices previously seen and still lingering in the config but for
completely new devices, we'll never get past that KeyError.

Return to the old behaviour: where we don't have a stored UUID we continue
with the None UUID.

Fixes #148

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-09 15:18:00 +10:00
Peter Hutterer 92a9628adf base: drop the separate function for bluez updates
A lambda does the job here without increasing the class profile
2019-07-30 14:06:49 +10:00
Peter Hutterer 08e3ec532e base: drop the extra function for checking if the device is in register mode
Now that it's just a one-liner, we don't need an extra function
2019-07-30 14:06:49 +10:00
Peter Hutterer 37b9b2eefa base: simplify check for in register mode
With a "or []" we can force this to be at least a 0-length list, obsoleting
the None check.
2019-07-30 14:06:49 +10:00
Peter Hutterer e1a3675439 base: ignore anything not from the known vendor IDs
We don't want to accidentally start talking to a device and brick it.
2019-07-30 14:06:49 +10:00
Peter Hutterer deb2c3ad2f base: rename the hotplugged argument
This one is a bit confusing, because most of the time it's not a hotplug
event, it's just the RSSI property updating.
2019-07-30 14:06:49 +10:00
Peter Hutterer 5b73c8ea2d Add a few more comments to the codebase 2019-07-30 14:06:49 +10:00
Peter Hutterer 4b3914d49c tuhi: take the mainloop out of Tuhi
If we want to integrate this with TuhiGui, we can't have multiple mainloops.
And there's nothing with Tuhi that needs it anyway, it's all about how it is
being called. Which means we can just move this to the main method.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-18 12:19:29 +10:00
Peter Hutterer 498a867558 Revert "base: once the device is registered, we're done"
This broke device initialization in some cases (not sure why it worked until
today though). Where a device is in register mode but the ManufacturerData has
not yet updated to the 4-byte string (i.e. a device previously known
normally), the device would now always call listen(). The firmware - in
register mode - would start initializing the connection though and get
rejected, leaving us with a device that cannot be registered.

This reverts commit a061240b11.
2019-07-15 21:57:24 +10:00
Peter Hutterer 5d53ec8005 Bubble up the width/height from the protocol to the dbus interface
Fixes #135
2019-07-15 09:38:19 +02:00
Peter Hutterer bcdf730a72 base: make sure we only connect once to the bluez connect/disconnect signals
This was getting stacked - once on init and once whenever we actually made a
connecting, resulting in the signal never getting disconnected properly and
some races because we tried to sync twice.

The whole "listen()" vs "listening" vs "connected" etc. is a bit of a mess and
should be reworked for a proper fix to this. But for now this will do.

This may fix #124
2019-07-15 09:38:19 +02:00
Peter Hutterer b16a16abde Add a SyncState signal to the DBus interface
Propagated whenever we start talking to the device (and then again when we
stop). The purpose of this signal is merely that a UI can show e.g. a progress
bar while we're talking to the device to ensure the user something is
happening.

Fixes #138
2019-07-15 09:38:19 +02:00
Peter Hutterer a061240b11 base: once the device is registered, we're done
This method is called whenever a bluez property changes, don't prompt the user
(in the logs) to register the device we just finished registering.
2019-07-15 09:38:19 +02:00
Peter Hutterer de3386a88d base: add a helpful comment
This it's more obvious that add_device can really be called every second or so
2019-07-15 10:43:35 +10:00
Peter Hutterer caa52e0c51 base: when search is turned off, remove unregistered devices again
This is what the dbusserver module does as well, so we end up with a weird
mismatch: to the base module the device is still known and unregistered on the
next search start. So when we see the bluez properties float past, we don't
add a new devices.

To the dbusserver the device is gone though and since we don't add it again in
the base module, we never send a signal for it.

Since there's a reasonable assumption that if we don't register the device, we
don't want it anyway, let's delete it from the base device list too.

This doesn't fix the issue of a device timing out while waiting for a button
press. That device will count as known until the next search stop. But at
least now we don't have to restart tuhi.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-08 10:52:39 +02:00
Peter Hutterer 4b02a6f51c Fix flake8-3 complaints
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-05 10:58:21 +02:00
Peter Hutterer 82b81b1c34 base: add timestamps to the logs
Fixes #127

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-05 10:54:44 +02:00
Peter Hutterer 7e751d45c8 base: if gi.repository fails to import, warn
We need python 3.6 but old Ubuntus only have 3.5. 3.6 can be installed (and
thus we get past the 3.6 sys.version check), but the gi.repository backports
are in various states of disarray (see #103 and #104).

And Python (and in particular gi) makes it hard for users to distinguish
between "the dependencies are a mess" and "this is a bug in tuhi".

So let's catch any error during gi.repository import and print a warning to
the user, in the hope of getting less bugs caused by Ubuntu frankenpythons.
Still won't fix issues like #104, but I'm not sure how to test for those
errors.

Related to #103
2018-03-06 09:33:17 +01:00
Peter Hutterer 138497a73b wacom: add support for the Intuos Pro 2 paper 2018-02-14 15:03:02 +10:00
Benjamin Tissoires 1a6d0205df tuhi: hook up live mode
Currently just enable/disable live mode.
The int parameter is doomed to be an opened fd to the uhid node
2018-02-14 06:23:25 +10:00
Peter Hutterer ad0e81b395 base: push the mode down to the TuhiDevice
A device isn't registered or not, it's merely in a *state* of being
registering or not. Pass the current mode down to the TuhiDevice instead of a
boolean for 'registered'. The 'registered' gobject property is left in-place
for now, the dbus server needs it.
2018-02-13 14:51:40 +01:00
Peter Hutterer 720955db7c tuhi: try to register even if the device is not in register mode
Let's throw an exception when trying to connect.
2018-02-13 14:51:40 +01:00
Peter Hutterer 393056d5e8 base: remove another register_mode in favour of DeviceMode 2018-02-13 14:51:40 +01:00
Peter Hutterer 637f539194 ble: drop the 'event' argument from device-added
An 'event' boolean is less than obvious ('is-event' may be better). This
signalled the difference between a device-added during Manager startup and the
device-added at runtime (i.e. device goes online).

We don't need that differentiation. The manager adds all existing devices
immediately after connnect_to_bluez(). All we have to do is run through the
device list, add them locally and then subscribe to the signal.

This keeps the is-event confusion within one file only instead of spreading it
across two and an internal API. And we can re-name it to hotplugged.
2018-02-13 14:51:40 +01:00
Peter Hutterer 2ff4f8bca6 base: make the register/listen call handling more literal
Calling listen on an unregistered device currently triggers a register on the
device. This can happen when the device has been registered but the
ManufacturerData has not yet been updated.

Disentangle this by only calling the right function based on what we're trying
to get. This also requires that the connected/disconnected signals are only
handled when we're actually trying to do something with them.

Fixes #79 (multiple patches required)
2018-02-13 14:51:40 +01:00
Peter Hutterer 4661cf9ae8 wacom: remove state-based decision of whether to listen or register
Previously, we set self._mode and used that to determine what connection to
attempt. This can sometimes lead to a device attempting to register in
response to a listen() request (and vice versa).

Make this dependent on the caller arguments only. So when listen() is
requested do exactly that and generate the right exception if the device is in
the wrong mode.

Fixes #79 (multiple patches required)
2018-02-13 14:51:40 +01:00
Peter Hutterer 3cbbfbf056 base: remove write-only variable registering_mode 2018-02-12 09:41:54 +10:00
Peter Hutterer 46ec85d718 ble: make manufacturer_data a property
We only ever used it in conjunction with vendor_id, so we can just make this a
normal property and send GObject notifies when it changes. This allows us to
listen for the MD to change when it finished registration.

[BT: do not add the second indirection by calling vendor_id]
2018-02-09 11:34:42 +01:00
Benjamin Tissoires 1f843b1434 wacom: split out the low level protocol from the interface with Tuhi
We are already handling 2 protocols, one for the Spark, and one for
the Slate. That's one too many, and given that there are some subtleties
in the Intuos Pro Paper (see #56), we better start splitting the protocol
from the interface, so we can have different protocols for different
devices instead of having a bunch of 'ifs'
2018-02-09 13:31:11 +10:00
Benjamin Tissoires 4b494917b1 wacom: load the protocol of the device from the config file
We can store this once for all, which will allow to keep the logic
of detecting the protocol while registering only
2018-02-09 13:31:11 +10:00
Benjamin Tissoires ecd99ea9b6 config: store the protocol used by the device in the config file
Instead of having to detect the protocol multiple times, we should just
store it once so we can detect oddities when they arrive.
2018-02-09 13:31:11 +10:00
Peter Hutterer 8f2ad50fa5 base: allow for multiple company IDs
The Intuos Paper uses a different one, because of course it does.
The 'company ID' from the Paper will be added while adding support for it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-09 13:31:11 +10:00
Peter Hutterer ad145cc078 base: require Python 3.6
Instead of failing with a syntax error on format strings, actually bail out
instead. Likewise for setup.py, require 3.6 and add this to the classifiers
too while we're there.

Related to #71
2018-02-07 09:18:11 +01:00
Peter Hutterer 5e82d1b378 Rename "pair" to "register"
"pair" is alrady taken by Bluetooth and since we have a bluetooth device here,
it can cause confusion. Use "register" instead, with an explanation in the
README for the more paranoid of us.

Fixes #67
2018-02-02 09:23:08 +01:00
Benjamin Tissoires fc219e4c57 janitor: silence deprecated warnings
While running the app in flatpak, there are a few deprecation warnings
coming in:
PyGIDeprecationWarning: GObject.SIGNAL_RUN_FIRST is deprecated;
	use GObject.SignalFlags.RUN_FIRST instead
PyGIDeprecationWarning: GObject.property is deprecated;
	use GObject.Property instead
PyGIDeprecationWarning: GObject.MainLoop is deprecated;
	use GLib.MainLoop instead
2018-02-02 10:46:47 +10:00
Benjamin Tissoires 3f75c927dc tuhi: do not stop discovering if search is on
If a client requested both listen and search, on listen off on the device,
the discovery was stopped too which lead to some unbalanced state in
the client.
2018-02-02 08:13:30 +10:00
Peter Hutterer 31e1f2ad3b Export the Bluez device's object path
Rather than proxying all metadata (name, address, ...) add a reference to the
bluez device instead.

Fixes #60
2018-02-01 10:13:39 +10:00
Peter Hutterer 9cecc1b535 Replace @property with @GObject.property
Let's stick to just one for consistency
2018-02-01 10:13:22 +10:00
Peter Hutterer 2a3b32a4fe base: update the battery state to unknown after 5 minutes
If we don't get battery updates for too long, we don't really know anymore
what the battery is like.

Fixes #47
2018-01-31 06:48:59 +01:00
Peter Hutterer 47f7ec104a base: remove leftover debug statement 2018-01-31 11:40:07 +10:00