Commit Graph

152 Commits (a8d864144299c95d4ba760a7d1b2bdab37edb298)

Author SHA1 Message Date
Peter Hutterer fa888b742f wacom: switch to the new protocol stroke parsers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 07dba6c892 wacom: store the default orientation for each tablet
Not actually used at this point, but this way we have default
width/height/orientation etc. all in one place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer e420b04fda protocol: add stroke parsing
This is a slightly different model as the messages, primarily because it's not
quite as model-specific. So there's only one parse function and it can handle
both file types that we currently support (intuos pro and the spark/slate
bits).

All wrapped into their own classes to make future extensions a bit easier.
It's not a 1:1 implementation of the tuhi/wacom.py bits either because we now
know about a few extra bits like the flags in stroke headers.

Most importantly though, this can be easily tested now, with one test case
searching for raw logs in $XDG_DATA_HOME/tuhi/raw and parsing all of those. So
the more files are sitting in there (i.e. the more the tablet is used), the
better the test suite becomes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 541077a65b Add a utility function module
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 91203701cf wacom: group the list2hex output
Group by size 8 by default.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 244b4f5994 wacom: make the parents for the raw log directory too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 14:04:23 +10:00
Peter Hutterer 92fcfd12cc wacom: update the dimensions with the point size
Make sure our dimensions are in actual µm.

Note that this will mess with any cached JSON files since they are now on a
different scale.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-20 12:02:30 +10:00
Peter Hutterer 6d718f16b5 wacom: rework the file data prefix handling
We know how it's supposed to look like, so let's hardcode it a bit better.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 15:46:50 +02:00
Peter Hutterer 116589d28d wacom: pen data first four bytes are the internal file format
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 15:46:50 +02:00
Peter Hutterer be6d57562a Switch to pathlib everywhere
gresources and svgwrite don't (yet?) take a Path though, so we have to use
os.fspath() to convert those.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 14:11:36 +10:00
Peter Hutterer 32091d9a7b wacom: improve a timestamp debug message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:21:24 +10:00
Peter Hutterer e5375a55dd wacom: name an argument to make it more obvious what the magic 5 means
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:21:24 +10:00
Peter Hutterer 790d8c5e31 wacom: fix pressure range for the IntuosPro
8191 seems to be the max value

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:05:49 +10:00
Peter Hutterer 85f2e3c67a wacom: fix the dimensions for the Spark
The reachable range is 2100x14800, highest pressure is 1023. Unlike the slate
the paper block still affords to address almost the whole range even though
the paper is slightly narrower than the range - but it can slide left/right by
about 5mm.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:05:49 +10:00
Peter Hutterer bd6278a305 wacom: change the raw log file name to include the timestamp
Because it's annoying when there's an issue with the timestamp in the file and
you have to grep for the file name.

And while we're there, change the human readable date to be actually readable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer 35acce3ea6 wacom: log the raw yaml data into a subdirectory
It gets a bit too confusing otherwise with all the weirdly named files around

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer 6bf7715e83 wacom: write just the timestamp to the log file
Easier to parse than a strftime. And we can just add that one in a comment
anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer 7f8222b351 wacom: add missing linebreaks to the yml log file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer c014393adb wacom: time_to_bytes is obsolete now
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 1ea89d2f09 protocol: split GET_DIMENSIONS up into two messages
It's the same message with a different argument, let's try not to do
gymnastics in the Msg code just so we can return a tuple.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 73bc782a53 protocol: 0xec is simply the GATT selection for file transfers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer c39c20ede2 protocol: drop the UNKNOWN_B1 class
0xb1 is the SetMode command, the rest is just the argument for which mode we
want

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 5e4ab89f41 Drop the semi-duplicate separate Protocol class
We can hook into the ProtocolVersion here, so let's de-duplicate this.
Should be backwards-compatible for config files but new config files will have
the uppercase name written now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 552e06a0fc wacom: drop the now-obsolete send_nordic_command_sync
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer b34f8794e4 wacom: switch registering the device to the new protocol handling
This is still a bit awkward because the communication of the spark especially
is so strange. It sends a (rejected) uuid, then a single command to register
that UUID. The Slate and the IntuosPro are more sensible, they seem to have a
special message to register a UUID - that one either fails or succeeds.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 6e20faa737 protocol: add a timeout argument to the new protocol handlers
The default timeout is too short for registering a button, let's control this
from the message.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer f68ffa6733 wacom: pass the timestamp in seconds down parse_pen_data
We don't carea about the struct time here

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer a08aa02607 wacom: drop a bunch of now-duplicate functions
This is all handled by the matching Msg now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 023decb1d4 wacom: use the new protocol implemenation for all "normal" messages
This is an in-situ replacement of the old functionality vs the new one,
resulting in a bit of duplication. Now that the Protocol takes care of the
device-specifics most of our functions look identical. This will be fixed in a
follow-up commit.

Missing from the conversion here is the initial register handling (too
convoluted right now) and the parsing of the pen data.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer bcbb0982c8 wacom: drop our NordicData, use the one from the protocol
Same thing anyway, this is just namespace handling

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 910bea8898 wacom: add another nordic function that just takes and returns data
This function doesn't process the data beyond the logging required. It simply
sends the request and returns the reply, whatever that is.

Currently unused, this is prep work for later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer fd02453279 wacom: allow for "no specific requested opcode" where we just return the data
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 341b91349e wacom: fix the data logger being off by one
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer 96df9fc416 wacom: make sure we only return the data packet size we want
If we have more data than our packet [1], let's not return the whole data
array. Slice it to size instead.

[1] this never happens with the current code, we don't work asynchronously

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer eacc03b6ea wacom: rename a function to make it more obvious
We're not checking for data here, we're taking the next message.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer 075fae13f9 flake 8 fixes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer 6e27d70517 wacom: de-duplicate an opcode check
we don't need the same-ish check twice, we can just pop our non-list into a
list an go from there.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer c84f3f8c63 wacom: error code 0x05 is an unrecognized command
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer d3726420cf wacom: add a comment describing where to we store stuff
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer b009ea3c96 wacom: rename the mysterious bits to sysevent
These bits are used for system notifications

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer cda4300388 wacom: visually align the UUIDs
And add # NOQA to shut up flake8

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-02 09:30:36 +02:00
Peter Hutterer 764ad45ca2 wacom: normalize the pressure to the advertised [0, 0xffff] range
This requires adjusting the svg conversion in kete as well, afaict the 1000
range there was chosen because it's (almost) the midpoint of the Bamboo series
with 2048 pressure grades. So let's use half of 0x10000 instead, which is
approximately 0x8000 as the crow flies.

Fixes #142
2019-07-30 14:05:01 +10:00
Peter Hutterer db08e1a82f wacom: improve a debug message 2019-07-17 18:25:40 +10:00
Peter Hutterer bc612f9e0e wacom: fix the firmware version retrieval for the base protocol
Introduced in dbd60675a9
2019-07-17 18:25:36 +10:00
Peter Hutterer 48a339c3b7 wacom: device time must be interpreted as UTC 2019-07-15 09:38:19 +02:00
Peter Hutterer a1e3e8eafb wacom: move device state debugging to the functions themselves 2019-07-15 09:38:19 +02:00
Peter Hutterer aff38c26a3 wacom: fetch both dimensions in one go
No need for the caller to call this twice everywhere, let's just do this here.
2019-07-15 09:38:19 +02:00
Peter Hutterer dbd60675a9 wacom: fetch firmware data in one go
No need for the caller to call this twice everywhere, let's just do this here.
2019-07-15 09:38:19 +02:00
Peter Hutterer bf5e53b62b wacom: simplify the battery state debug message 2019-07-15 09:38:19 +02: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