Commit Graph

114 Commits (59db1a28ae60ab8f6b3e97de488efb6321a1c3b0)

Author SHA1 Message Date
Benjamin Tissoires 59db1a28ae wacom: make the slate a subclass of the spark
The Slate is more recent than the Spark. We better have the Spark as a
base class that we will never touch again and make the Slate depend on it.

When adding the Intuos Paper, we should make it a subclass of the Slate,
as the 2 protocols are similar.
2018-02-09 13:31:11 +10:00
Benjamin Tissoires f6e7c72d9d wacom: Split out the Nordic communication protocol in its own class
So the low level bits are not in the same class than the protocols
2018-02-09 13:31:11 +10:00
Peter Hutterer 82e7dbf515 wacom: remove the Spark's 0xb3 opcode from register_connection
This is handled in the subclass now
2018-02-09 13:31:11 +10:00
Benjamin Tissoires d62a97a8cd wacom: have subclasses to distinguish between protocols
The Intuos Pro Paper is close enough to the Slate but with some
subtleties. Instead of having a bunch of ifs, let's have nice subclasses
for the differences in the protocol.
2018-02-09 13:31:11 +10: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 7f230859fe wacom: don't save the current time
This is a write-only value. And for read_time() if we want to compare
timestamps we can just do so with time.time()
2018-02-09 13:31:11 +10:00
Benjamin Tissoires f684a0efb3 wacom: decipher 0xbb command
It's just the name of the device :)
2018-02-09 13:31:11 +10:00
Peter Hutterer 112b689bf8 wacom: drop Orientation from the Tuhi daemon
This isn't something we need in the daemon, it depends too much on what the
client expects so let the client save this data and handle the rotation
accordingly.

Note that the sensor in Sparks and Slates is in landscape format, i.e. every
picture is 90 deg rotated from what you'd expect.

Fixes #33 (wontfix)
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
Benjamin Tissoires 00fbff37ab dbus: fix signal name exported in the dbus introspection
We are using ListeningStopped, not ListenComplete
2018-02-06 15:17:27 +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 1a25163733 config: purge all but the last 10 drawings from the config storage directory
Tuhi is not a permanent storage for drawings, this needs to be handled by the
client(s). To make sure no-one is tempted to use it as permanent storage,
always delete all but the last 10 drawings on startup.

Fixes #45
2018-01-31 06:47:18 +01:00
Peter Hutterer 83852701ec config: use os.path.join on the entry directly 2018-01-31 06:47:18 +01:00
Peter Hutterer 47f7ec104a base: remove leftover debug statement 2018-01-31 11:40:07 +10:00
Benjamin Tissoires 2c8c517c71 wacom: strip out first char of firmwares
The first char is the request, so it should be filtered out to match the
display of Inkspace
2018-01-31 10:21:57 +10:00
Benjamin Tissoires ffd052921a wacom: check for is_spark instead of is_slate
Spark is the past, Slate is the future.
Spark seems to have its own protocol, while the Slate and the Folio are
supposed to have the same firmware. We should probably make Spark the
exception than the other way around.
2018-01-31 10:21:57 +10:00
Benjamin Tissoires 34e08db150 wacom: better differentiate the Slate from the Spark
Relying on the name is a bad idea because:
- the Wacom Inkspace app asks the user to change the name of the device
  on pairing
- the FW should be slightly the same between generations (Folio and Slate
  vs Intuos Pro Paper edition vs Spark)

It appears the Spark doesn't have the "Mysterious characteristics"
mentioned here. And this characteristics seems to send a wacom-like
protocol when pairing to the device or from time to time.

Attempt to differentiate between the Spark and the rest based on that
so we can hope to support the Folio too, and maybe the Intuos Pro Paper
Edition.
2018-01-31 10:21:57 +10:00
Peter Hutterer e647e20426 Export the battery level/charge state 2018-01-30 18:53:55 +10:00
Benjamin Tissoires 9f118bbe15 janitor: convert double quotes into single quotes
Let's the developers of tuhi to consume more energy in their monitor
to light up more pixel when displaying single quotes whereas double
quotes.

It also makes the whole bit more uniform.

Fixes #32
2018-01-29 21:18:06 +10:00
Benjamin Tissoires 04f25a0a38 drop .format(), switch to f{} everywhere
and change some double quotes into single quotes when encountering them.

It's a new project, so force use of Python 3.6 right now

Fixes #29
2018-01-29 21:18:06 +10:00
Peter Hutterer 6ad3851afd wacom: set the device time to UTC time on pairing
And let us handle the local time zone conversions in the client, because
having timestamps in localtime in the daemon is confusing and error-prone (how
is the client supposed to know what localtime was?)
2018-01-29 09:44:50 +01:00
Benjamin Tissoires 56be286d68 tuhi: fix cold plug of devices last seen in pairing mode
fix ca82af78de ("tuhi: handle cold-plugged devices").

The point of deciding whether a device was in the pairing mode was actually
ignored when building the list of available devices.
2018-01-29 09:14:41 +01:00
Peter Hutterer ab385bd981 dbus: update the listening property, not the internal variable
Otherwise the PropertiesChanged never gets sent
2018-01-25 16:02:34 +10:00
Peter Hutterer 3bc88bbbb6 config: store/load device drawing in the device's directory 2018-01-25 14:55:10 +10:00
Peter Hutterer 7a31a994fb dbus: return the drawings as array of timestamps
As we're planning to cache the data locally, the timestamps are a
unique-enough way that makes it possible to access a specific drawing.
And this way we can also delete some drawings without all other indices
shifting around.

Fixes #16
2018-01-25 14:55:10 +10:00
Peter Hutterer 80d214c78f Split the Drawing class out into a separate module
No point having multiple implementations of what a drawing is. Let's have it
in one module.
2018-01-25 14:55:10 +10:00
Peter Hutterer 3d516530c6 wacom: throw the exception (if any) to the "done" handler
Attach an errno to all exceptions, so we can bubble that up to the client
and display a message.

Fixes #24
2018-01-25 14:55:10 +10:00
Peter Hutterer bf3842c150 wacom: use a different logger for the firmware communication
This makes it easier to grep for the raw communication with the device.

Fixes #28
2018-01-25 13:42:01 +10:00
Peter Hutterer 2fd781974f dbus: pass the bus name lost signal up to tuhi
If we're losing the bus name (i.e. we can't get it on startup) there really
isn't much we can do other than fail miserably. But in passing signals around
we can't do exceptions, so we have to move the mainloop to Tuhi so we can
quit() it on error.

Fixes #25
2018-01-25 09:18:59 +10:00
Peter Hutterer cae296e030 dbus: don't unset the searching client until we received the signal from tuhi
The API requires us to send the signal after stop
2018-01-25 09:18:59 +10:00
Peter Hutterer 1e31e6cba7 dbus: add a helper for sending signals 2018-01-25 09:18:59 +10:00
Peter Hutterer ba7c62fc0c dbus: add helper for properties changed signal 2018-01-25 09:18:47 +10:00
Peter Hutterer 584925a0d9 dbus: add a DBus base object
Currently just handling some properties that are common, but will do other
things soon.
2018-01-24 21:40:42 +10:00
Peter Hutterer 1a6071b93d dbus: use self.objpath instead of the hardcoded BASE_PATH in the manager 2018-01-24 21:39:56 +10:00
Peter Hutterer fc8f0f6716 __init__: remove empty line that snuck in during rebasing 2018-01-24 21:39:56 +10:00
Peter Hutterer 8bb971cdcd tuhi: don't use a timeout for searching
We track the searching client now, so the timeout is no longer required
2018-01-24 19:25:00 +10:00
Peter Hutterer cfa4aca2df dbus: limit StartSearch to one client only
Basically copied from the device's Listening approach.

While it's possible to have multiple clients searching at the same time it's a
niche case and the effort at fixing the race conditions that come from that is
likely not worth the effort.

Let's add multiple simultaneous clients when we have a real need for it.
2018-01-24 19:23:20 +10:00
Peter Hutterer cce63d267b dbus: stop discovery when the searching client disappears
This is the single-client version only, we can deal with multiple clients
later.

Fixes #21
2018-01-24 19:23:20 +10:00
Peter Hutterer eb5efd2e1c tuhi: move everything to base.py
Let tuhi.py just be the script that calls main. This way we're somewhat
setup.py compatible.
2018-01-24 19:08:12 +10:00
Peter Hutterer 5e32dc4872 dbus: don't update self.paired unless it changes
TuhDevice.paired is set on every device update (RSSI changes!) and that sends
a GObject.notify() for the property. Filter those, otherwise
we're just spamming dbus with PropertiesChanged notify events even
though nothing has actually changed.
2018-01-23 14:57:00 +10:00
Peter Hutterer 7aa4314c3d wacom: use .format instead of hex to generate the timestring
hex() skips leading zeroes, so 180123 turns into 18, 12, 3
2018-01-23 14:44:01 +10:00
Peter Hutterer 44a2d5e8eb ble: if we connect twice, log the error as debug
We likely get multiple 'udpated' notifications as the RSSI property changes,
all causing a Connect() on the device and an ugly error message (that we used
to catch and print). Make that error message prettier.
2018-01-23 14:22:33 +10:00