Commit Graph

512 Commits

Author SHA1 Message Date
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 a817d10cc7 protocol: start a new attempt at handling the protocol
This is only the framework for a new protocol handler that should simplify
adding, extending and debugging the actual protocol messages.

The summary is:
- each protocol interaction is a subclass of Msg() that handles the data sent
  and received from the device.
- the list of messages for each device is stored in a dictionary the caller
  initializes by providing the protocol version
- those messages are addressable via the Interactions enum through the
  Protocol class
- the messages can be run via execute(), taking and setting the obvious
  properties on the object
- actual communication is done via a single callback that takes/returns a
  NordicData object for the request/reply.

So after the basic setup, the caller can do this:
   p = Protocol(ProtocolVersion.INTUOS_PRO)
   name = p.execute(Interactions.GET_NAME).name
   p.execute(Interactions.SET_TIME, time.time())

This completely separates the protocol from the implementation where we want
the result of that exchange, ideally paving the way for better testing and
easier debugging of what's happening on the wire. Well, ether.

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 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 a323ba9aeb meson.build: drop the unused gtk package versions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-13 13:59:03 +10:00
Peter Hutterer 5b5fcd6e71 Circle CI: install the packages for the other tests too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-13 13:58:43 +10:00
Peter Hutterer 24825aa6ed circleci: checkout out the repo before we run meson
Having the files around helps tremendously.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-13 13:40:44 +10:00
Peter Hutterer fc16085597 Hook up CircleCI for basic tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-13 13:34:16 +10:00
Peter Hutterer 442dd5e53e meson.build: add tuhi to the flake8 tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-13 13:34:16 +10:00
Peter Hutterer fe757ee116 Drop setup.py - we're on meson now
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-13 13:34:16 +10:00
Peter Hutterer a27fbe96dd flake8 fixes 2019-08-13 13:34:16 +10:00
Peter Hutterer 3e44e28707
Merge pull request #145 from whot/wip/tuhigui
Merge the TuhiGui into this repo
2019-08-09 15:28:29 +10:00
Peter Hutterer 3641afc8bf gui: print a warning when we can't connect to the screen
Because the exception thrown is less than obvious.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-09 15:26:43 +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 28fbddce78 gui: remove two more TuhiGUI leftovers from the About dialog
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 14:44:18 +10:00
Peter Hutterer 0c333aa64b gui: fix flake8 warnings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 14:44:18 +10:00
Peter Hutterer 0840f353d5 gui: render the drawings as oblongs in the right ratio
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 14:44:18 +10:00
Peter Hutterer ee68ec4bcc gui: drop the Credits page from the About dialog
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 14:44:18 +10:00
Peter Hutterer 35ab7ad621 gui: reverse-sort the drawings by timestamp before adding them
We want the most-recent drawings up the top. And since we always add to the
flowbox, we need to reverse-sort everything.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 14:44:18 +10:00
Peter Hutterer 89559364cf gui: fix categorization of drawings
Using the year/month as key only works if both are expanded properly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 14:44:18 +10:00
Peter Hutterer 37d22dfaad gui: drop the relative_time() helper, no longer used
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 14:44:18 +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 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 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 a63355a03e gui: we don't really do selection in the flowbox, so let's make it white 2019-07-23 12:58:08 +10:00
Peter Hutterer 4e886fca2b gui: only show the toolbox on enter
This is using opacity of 0% to hide them - this way the space stays allocated
and showing it doesn't rearrange things. Using visiblity here causes
everything to shift around on reveal.
2019-07-19 18:09:13 +10:00
Peter Hutterer 0b9d4c2602 gui: round off the borders for the paper itself
Because we don't want to hurt ourselves on those sharp edges, do we?
2019-07-19 16:43:54 +10:00
Peter Hutterer d06b92e9af gui: hook up a zoom slider
The default size of the drawings is a bit small now, good for an overview but
not for identifying which drawing to use now. Add a zoom slider for that.
2019-07-19 16:41:17 +10:00
Peter Hutterer 097f66f33c gui: add a GTK separator under the month/year label 2019-07-19 14:37:51 +10:00
Peter Hutterer 357f25deb4 gui: pack the toolbox at the start so it doesn't expand
If one drawing in the line gets rotated, the buttons all scaled to filll the
space - which is ugly.
2019-07-19 14:37:51 +10:00
Peter Hutterer 6b623132e5 gui: handle the now-normalized pressure range
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-19 14:37:51 +10:00