Commit Graph

352 Commits (master)

Author SHA1 Message Date
Martin Owens 0b02f5f9c2 Change SVG export to use paths instead of line segments 2022-02-01 16:42:11 +10:00
Peter Hutterer 4ff7da5d41 protocol: handle the pen id packet correctly
We were re-using the header byte of the stroke header to count the bits.
Where that header is anything but 0xff we got out of sync and raised an
error. Fix this by renaming things so we don't accidentally use the
wrong fields.

Fixes #283

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-01-31 12:29:31 +10:00
Peter Hutterer 643099b858 Fix flake8 errors - ambiguous variable name 'l'
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-22 17:09:27 +10:00
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
Peter Hutterer eef877d6ce tuhi: use a Gtk.FileChooserNative dialog
This one hooks into the correct portal APIs, hopefully fixing the issue with
the Flatpak version not saving files correctly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-26 11:03:26 +10:00
Peter Hutterer ba0424c6df gui: fix a flake8 complaint
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-26 11:03:26 +10:00
Peter Hutterer 59dfce5b8d gui: add an expanding label to the end, but don't expand flowboxes
pack_end, introduced in 29761204a9 means they
align to the bottom of the window. Where there aren't enough drawings to fill
the window, everything is bottom aligned. Hack around this by adding an empty
label to the bottom that expands to the maximum available size and stop
expanding the rest. This new label thus pushes everything up to the top
position.

Fixes 29761204a9

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-26 10:33:07 +10:00
Peter Hutterer 29761204a9 gui: pack the flowboxes with pack_end
The first drawings we load are from disk. If we sync a drawing from the device
with a different key (i.e. created in a different month), the new flowbox for
that drawing was appended to the list and in last place. This caused
out-of-order sorting (though a restart of Tuhi would fix it).

So simply change the behavior to sort by oldest timestamp first and pack_end()
for all of them. If we pack all our flowboxes with pack_end, they are
effectively in reverse order, i.e. last one added is first in the list.

Fixes #244

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-26 09:34:08 +10:00
Taihsiang Ho (tai271828) 3c1a84e1ab protocol: rm unused class WacomPacket 2020-04-21 15:23:44 +10:00
Peter Hutterer 53e2cebaf8 protocol: fix a flake8 issue
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-08 10:08:36 +10:00
Niclas Hoyer f5ea08f171 Add support for long device names
If the device name is longer than one reply, the registration will crash.
This adds support for a variable number of replies until the reply ends
with `0x0a`.
2020-01-07 11:05:13 +10:00
Niclas Hoyer a0566e0dc0 Workaround for Spark register problems
This is a workaround for registering problems with Spark.
The registration hangs at "Connecting to device...".

Internally the `GENERAL_ERROR` occurs, which is expected
when registering a Spark device, but this should also
raise an AuthorizeException, but it instead reaches the
handler as DeviceError.

It is currently unclear why the `GENERAL_ERROR` passes to
this handler, so this catches any `GENERAL_ERROR` while
registering a Spark device.
2020-01-07 11:00:11 +10:00
Niclas Hoyer 67eb54c908 Add company ID for Augmented Paper 2020-01-03 10:34:25 +10:00
Peter Hutterer d5cb1930e5 export: drop unused import
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-30 18:05:39 +10:00
Ishak BELAHMAR ea1dc798b1 Remove unused svg module 2019-09-30 09:50:03 +02:00
Ishak BELAHMAR bbff179a4d Add png export feature 2019-09-30 09:50:03 +02:00
Peter Hutterer cb72111910 gui: make the app menu translatable
Fixes #216

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-10 15:28:20 +10:00
Peter Hutterer 13830e02c5 Add the python 3.6 check to all entry points
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:43 +10:00
Peter Hutterer 0e12369866 wacom: set the x/y min/max to the correct device units
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer 74ffe763b6 ble: downgrade three more debug messages
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer 1c893d14e8 wacom: make a debug message more informative
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer 960904d481 wacom: don't fetch the dimensions if we're stopping live mode
There's just no point to that and if the tablet is currently in live mode, it
refuses the GET_WIDTH request anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer 43c844ea1e dbusclient: make the live property mirror the dbus one
We have a dbus property for this so let's just use that as a backend for our
live property instead of emulating our own on top of it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer bffe41fbb6 protocol: handle 0xb3 automatically
0xb3 is the generic error code (or success, where applicable). Let's handle
those by default so that the rest of the messages only have to care about
replies with message-specific opcodes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-29 12:38:21 +10:00
Peter Hutterer 1dc1acaba3 gui: move most of the tuhi-gui startup script to application.py
Add a new main() there so we have a single entry point for the gui instead of
a complex script that needs to be called. That start up script should really
just be the minimum bits possible.

It's still not perfect because we won't work without the gresources and they
require that the pkgdatadir is set. But at least it moves all the logic out of
the startup script.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-29 10:42:44 +10:00
Peter Hutterer bb9f9b6c26 gui: reshuffle the includes until gi and flake8 are happy
We have implied inclusion orders here, specifically with gi. This works as
long as the files are included in the right order from other files but its not
generic enough - we really do need the gi.require_version() bit
everywhere to avoid issues.

Of course, once we do this flake8 complains about everything so let's
reshuffle things in an order it's happy with. This seems to be local modules
first, then ... whatever except when not?

application.py is excluded from this patch because it's about to get changed
in the next one and I'm too lazy to separate those out.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-29 10:42:44 +10:00
Peter Hutterer e37016dc7b Fix deprecated use of @GObject.property → @GObject.Property
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-29 10:42:44 +10:00
Peter Hutterer 97a4ab04d0 ble: downgrade a message from info to debug
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-29 10:42:10 +10:00
Peter Hutterer 07cefa3c26 dbusclient: add the start/stop live from kete to the bindings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:17:38 +02:00
Peter Hutterer 695b7c43be dbusclient: drop the duplicate device argument
The first argument in any signal is the object that emits it, so we don't have
to add it again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:17:38 +02:00
Peter Hutterer 71ca2ca569 gui: fix two signal disconnections
Both of the signals here are connect to the device, not Tuhi. The only reason
this worked was because the signal sent by the dbus bindings had the device
twice in the arguments and 'tuhi' was actually the device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:17:38 +02:00
Peter Hutterer 2d142b4be3 dbusclient: drop the word Kete from the generic dbus client bindings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:17:38 +02:00
Peter Hutterer 28f92882ec dbusclient: fix a few super() calls
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:17:38 +02:00
Peter Hutterer f477e86a96 gui: move the dbus client handler bits to the tuhi module
This is used by the GUI and by kete and it's just an abstraction of the
handling anyway with little actual logic. Let's make this sharable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:17:38 +02:00
Peter Hutterer ed29c0daae gui: stop listening on an authorization error
This conflicts with trying to register the device on authentication errors and
making re-registration unreliable. Tuhi would keep connecting to the device
while holding the button down, so we'd get another failed connection and a
disconnect from the device. The Register signal would come in and get lost
somehow.

Fixes #195

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 14:55:12 +02:00
Peter Hutterer 488512231c gui: reset the signal list after disconnecting them
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 14:55:12 +02:00
Peter Hutterer 6c0ddd96bc protocol: add missing space for NordicData's str()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:33:28 +10:00
Peter Hutterer 827ccbfa07 protcol: just print the class name during str()
<class '....'> doesn't make things easier to debug

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:33:28 +10:00
Peter Hutterer 1fb36ebc40 protocol: fix typo in printing a NordicData object
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:33:28 +10:00
Peter Hutterer db87390c48 protocol: use __str__, not __repr__ for the various messages
str() is the preferred one, though I can't find a good explanation when to use
what.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-28 15:33:28 +10:00
Peter Hutterer e6ea60d6c1 gui: hook up ctrl+q for app.quit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 13:18:28 +10:00
Peter Hutterer b0b076d52a config: don't purge drawings
We used to drop all but the last 10 drawings on startup and as the comment
says so that users don't rely on tuhi for storage. That's mostly fine when
Tuhi is a separate daemon but now the primary interface is the GUI. So we can
run into this situation:

- user starts Tuhi (which in turn starts tuhi-gui and tuhi-server)
- tuhi-server downloads 20 fresh drawings from the device
- tuhi-gui crashes before it can fetch them from the tuhi-server
- restart Tuhi, the server now purges 10 out of those 20 drawings that the
  user has never seen. They're gone for good.

Let's drop that code until we figure out a better solution to that (e.g. drop
drawings older than X months but that too is fraught with errors).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:18:10 +10:00
Peter Hutterer a0fb4cf0f9 wacom: use 'with' to group request/replies together
Previously, the YAML output was basically:

  - send: [0xb9, 0x01, 0x00]
  - recv: [0xba, 0x02, 0x44, 0x00]

using a context manager where replies are expeced we can now group the
replies in the yaml file:

        with logger as _:
           self.send_nordic_command(...)
           self.wait_nordic_data(...)

And that will prodice a grouped entry in the YAML file:

  - send: [0xb9, 0x01, 0x00]
    recv: [0xba, 0x02, 0x44, 0x00]

Which means processing those becomes a bit easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:05:17 +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 79480b867d protocol: store the interaction name in the NordicData where appropriate
This means the data logger can then access that name without needing a
separate lookup table.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:05:17 +10:00
Peter Hutterer e30787234c wacom: change the data logger to take a request msg instead of just raw data
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:05:17 +10:00
Peter Hutterer 9a21c2318a wacom: store the default point size for each tablet
It'll be overwritten by the messages anyway but for the converter tool this is
handy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 11:31:30 +02:00
Peter Hutterer 8eea6468b7 wacom: add a session id field to make it easier to find log files
The session id is a UUID, postfixed by an incrementing number. The UUID stays
the same for Tuhi's livetime, the number increments with every bluetooth
connect/disconnect. Result is e.g. 4e55c30035d043ce9f6f4914fb223820-2.

This session id is printed to the log file, added to the YAML raw logs and to
the JSON file, making it easier which log part resulted in which drawing, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:46:14 +02:00
Peter Hutterer 44d2018f1c protocol: assume the initial stroke point to be 0, 0, 0
Reproduced on the Spark, first bytes in a new file recording were
- file header: 0x62, 0x38, 0x62, 0x74
- stroke point: 0xbf, 0xff, 0xff, 0x4a, 0x14, 0x29, 0x31, 0x6a
- stroke delta: 0xa8, 0x02, 0x04, 0xc3,

The initial point thus has a delta pressure value 0x6a which must be added to
*something*. And zero is the most sensible *something* that I can think of.

Fixes #111

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:44:55 +02:00
Peter Hutterer c466c7d431 protocol: handle error code 0x7
Deprecated, but still exists on the Slate so let's wrap the connect attempt
so we throw the right error.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00