Commit Graph

62 Commits (d295e123106aa615cec93c5dabe3a9054c88c5a2)

Author SHA1 Message Date
Benjamin Tissoires d295e12310 wacom: create a uhid device on live mode
uhid code taken from https://github.com/bentiss/hid-tools and stripped out
from the not required parts here
2018-02-14 06:23:25 +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 7ff760dcbf wacom: add support for a set_name on the Spark
Part of #82
2018-02-13 15:23:05 +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 0d825e2e3c wacom: replace the signal forwarders with lambdas
We're doing nothing but forwarding the signal here, so let's just replace them
with lambdas so it's immediately obvious what we do with the signal.
2018-02-13 14:51:32 +01:00
Peter Hutterer de033c3b6a wacom: 0x05 appears to be the error for 'invalid opcode' 2018-02-12 15:30:16 +10:00
Peter Hutterer c9d48ed4b2 wacom: document the signals we send 2018-02-12 15:30:14 +10:00
Peter Hutterer 7cd9a89f3b wacom: prettify the 'returned time' debug message 2018-02-12 12:49:48 +10:00
Peter Hutterer 60535a6859 wacom: remove unused define 2018-02-12 09:41:54 +10:00
Peter Hutterer 6cff3b8f79 wacom: split the time parsing functions out
Doesn't gain us that much, but we can re-use it when parsing stroke data
lateron.

This also will be useful for the Intuos Pro support
2018-02-09 10:39:18 +01:00
Peter Hutterer b5e6ad6559 wacom: make room for a more diverse register_device
Fold register_connection into register_device and (with comments) handle the
spark and slate here. This makes it easier to handle the Intuos Pro paper
later.
2018-02-09 10:31:37 +01:00
Peter Hutterer b45977c2d2 wacom: fix typo 2018-02-09 10:31:37 +01:00
Peter Hutterer bc95a0b414 wacom: prettify a debug message 2018-02-09 10:31:37 +01:00
Peter Hutterer 654dea6810 wacom: pass the uuid up to the slate's super() constructor 2018-02-09 10:31:37 +01:00
Benjamin Tissoires c2bba6bd43 wacom: move protocol instantiation into a class
During the first attempt to register, we might not know before hand
the protocol of the device. Have a special class for it, and then
instantiate the correct protocol before continuing.

This makes the 'Protocol' entry in the config file mandatory
2018-02-09 13:31:11 +10:00
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 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 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 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
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 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 4ee07a18b6 Hook up UUID changes to be written in the config file
Make the uuid property a GObject.Property so we can listen to it. Notify about
the uuid change at the end of the pairing process, then write that value into
the device's config file.
2018-01-19 16:17:44 +10:00
Peter Hutterer 8e50421f2e wacom: generate the uuid on pairing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-01-19 16:17:44 +10:00
Peter Hutterer d4405cc1ef Hook up a ButtonPressRequired signal
When the nordic communication requires us to notify the user to press the
button, emit a signal and pass that up.
2018-01-19 13:40:26 +10:00
Peter Hutterer f6519016f9 wacom: rename the register* calls to pair* calls
Because that's what we call them everywhere else
2018-01-19 13:40:26 +10:00
Peter Hutterer 81033c3139 wacom: drop the multiple definitions of SMARTPAD_UUID
Let's use deadbeef for now until we have the generation code in place.
2018-01-19 13:40:26 +10:00
Benjamin Tissoires 06e8d69e9d Implement pairing of a new device
This includes the new pairing code for the Spark which is slightly different
to the one from the Slate
2018-01-19 13:40:26 +10:00
Peter Hutterer f9756a71ce Add commandline arguments to enable verbose mode
Create a logger hierarchy, that way we only need to set the root logger to
DEBUG and the rest goes along with it.
2018-01-17 13:41:35 +01:00
Benjamin Tissoires 8a81b1c245 Make sure we retrieve the data atomically
Ignore any requests to sync the device while the previous sync is still
ongoing. This should be the exception anyway, we shouldn't get another
"connected" signal from the device while we're syncing.
2018-01-17 13:41:35 +01:00
Benjamin Tissoires f88a5b2222 wacom: disconnect when we have finished retrieving the data
There is no point keeping the connection alive just to drain the battery.
2018-01-17 13:41:35 +01:00
Benjamin Tissoires f30f47d454 wacom: fix from_bytes little/big endianness
Looks like they are all the wrong way but the time_offset one.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-01-17 13:41:35 +01:00
Peter Hutterer 1841508c33 Pass the timestamps to the json file 2018-01-15 16:15:35 +10:00
Peter Hutterer 3a23610e08 Connect the WacomDevice drawings to the TuhiDrawings
And fixing a few issues with pressure, etc. on the way
2018-01-15 16:15:35 +10:00