Commit Graph

277 Commits (83d669c0595755ed22761e4c1049d7c0f0c42639)

Author SHA1 Message Date
Benjamin Tissoires 83d669c059 kete-sandboxed: fix tuhi-kete import path
fixes e4e0a3b ("kete: rename the script from tuhi-kete.py to kete.py")

When renaming tuhi-kete into kete, we forgot to also update
tuhi-kete-sandboxed.py.
2018-03-06 10:02:23 +01:00
Benjamin Tissoires d86d3ce4a7 setup.py: fix pyxdg requirement
xdg is declaring itself as pyxdg.

Detected when installing through flatpak. It tries installing 'xdg'
through pip while we already manually installed it:

Processing dependencies for tuhi==0.1
Searching for xdg
Reading https://pypi.python.org/simple/xdg/
Download error on https://pypi.python.org/simple/xdg/: [Errno -3] Temporary failure in name resolution -- Some packages may not be found!
Couldn't find index page for 'xdg' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [Errno -3] Temporary failure in name resolution -- Some packages may not be found!
No local packages or working download links found for xdg
error: Could not find suitable distribution for Requirement.parse('xdg')
Error: module tuhi: Child process exited with code 1
2018-03-06 09:55:11 +01:00
Peter Hutterer e6f5baf02f setup.py: add pygobject
This appears to be the right dependency and should work with pip
https://mathieu.daitauha.fr/blog/2016/07/06/pip-install-pygobject/
2018-03-06 09:33:17 +01:00
Peter Hutterer b749cad77e setup.py: don't require 'gi'
Turns out this is not the gi.repository but a different package:
    'Command line to private gist.  Example: gi.py myFile'

It's incompatible with python3 and fails on import and seems to conflict with
gi.repository (also, the upstream seems dead).

Fixes #103
2018-03-06 09:33:17 +01:00
Peter Hutterer 7e751d45c8 base: if gi.repository fails to import, warn
We need python 3.6 but old Ubuntus only have 3.5. 3.6 can be installed (and
thus we get past the 3.6 sys.version check), but the gi.repository backports
are in various states of disarray (see #103 and #104).

And Python (and in particular gi) makes it hard for users to distinguish
between "the dependencies are a mess" and "this is a bug in tuhi".

So let's catch any error during gi.repository import and print a warning to
the user, in the hope of getting less bugs caused by Ubuntu frankenpythons.
Still won't fix issues like #104, but I'm not sure how to test for those
errors.

Related to #103
2018-03-06 09:33:17 +01:00
Peter Hutterer 0ee18353ef README: the Intuos Pro Paper works now 2018-03-06 09:54:39 +10:00
Peter Hutterer 108f1720b8 setup.py: add requires for external packages
Fixes #100
2018-02-20 11:05:31 +10:00
Peter Hutterer caf1264952 dbus: add file format version negotiation for the JSON data
Export the supported versions in a Manager property and require the client to
request a specific version in GetJSONData. Without that, the server could
never update the format and clients would have to support every single
historical version to make sure they can run against any version server.

Fixes #98
2018-02-19 11:17:18 +10:00
Peter Hutterer d4ea6e3938 dbus: change the JSON timestamp argument to 64 bit
Because we're totally going to ship tuhi in embedded devices that are going to
be in use until after 2038 when time resets to zero, the world goes big bang
and the only survivers will be 64-bit species. Or something like that. Either
way, the API documentation already said so anyway and the DrawingsAvailable
property is already 64 bit too.

Semi-confusingly: the dbus 64 bit unsigned type is 't', it doesn't stand for
'timestamp'.
2018-02-19 11:16:27 +10:00
Peter Hutterer e0949a2a5e kete: rename indices/index to timestamp
That's what it is, it hasn't been an index for a while now.
2018-02-19 10:50:41 +10:00
Peter Hutterer 81d20a5193 README: fix outdated doc for GetJSONData 2018-02-19 10:46:57 +10:00
Benjamin Tissoires 789c098e82 wacom: do not timeout on long drawing retrievals
It can easily take more than 5 seconds when reading the data. The current
timeout just cuts the connection while it is still reading.

We *could* just remove the timeout here as the device will gracefully
send us a 0xc8 opcode with a blank CRC if we shut the device down while
retrieving the data.

However, better being on the safe side and keep a timeout, but restart it
if we are still getting pen data during the timeout.

Fixes #91
2018-02-16 10:52:49 +01:00
Benjamin Tissoires a5cb084a31 wacom: use semaphore instead of polling
Using polling is bad, true, but it worked. However, using a Semaphore
is better and we can directly benefit from the internal timeout
implementation.
2018-02-16 10:51:09 +01:00
Benjamin Tissoires be2ac9fed3 wacom/live: take into account 'physical' borders of the bloc of paper
When using the live mode on the Slate, the bloc note actually hampers
the pen and prevents it to address all of the pixels on the screen.

Add some artificial boundaries that roughly match the primary design
of the device.

The Intuos Pro has a clip where you put a regular sheet of paper, so there
is no point restraining the active surface.

Fixes #88
2018-02-16 10:47:19 +01:00
Benjamin Tissoires 013de2a6e4 wacom/live: do not fetch the width and height, rely on stored values
It's not like we are handling hundreds of devices. And this allows us to
be more flexible in which fields are replaced in the report descriptor.
2018-02-16 10:47:19 +01:00
Benjamin Tissoires cf4d5b184e wacom/live: make the pressure dependent of the class
The Intuos Pro has 4096 levels of pressure, while the Slate and the Spark
only has 2048. We should do something about it.
2018-02-16 10:47:19 +01:00
Benjamin Tissoires 18221dfd58 wacom/live: fix physical maximums
This way, udevadm shows on the Slate:
E: ID_INPUT_HEIGHT_MM=148
E: ID_INPUT_TABLET=1
E: ID_INPUT_WIDTH_MM=216

Fixes #84
2018-02-16 10:47:19 +01:00
Benjamin Tissoires ee15b474fd wacom/live: make sure the kernel assigns INPUT_PROP_POINTER
The wacom kernel driver assigns INPUT_PROP_DIRECT if we use the
application Pen. Using the Digitizer one fixes that.
2018-02-16 10:47:19 +01:00
Peter Hutterer 7b246e0892 wacom: add packet handling of the two initial packets the IntuosPro sends
One is a fixed header, one  is the stroke timestamp
2018-02-16 15:43:28 +10:00
Peter Hutterer 31ab5f37d3 wacom: move stroke prefix handling into a packet handler 2018-02-16 15:43:28 +10:00
Peter Hutterer 5692a1f3b2 wacom: add PacketHandlers for handling special commands
For data packets other than basic motion/pressure strokes, add a PacketHandler
that can deal with that particular packet. Those handlers are part of the
class declaration, when we instantiate a protocol we pull them all into a
packet_handlers list and go through them. The first one to return True is
considered the right handler and we expect something has been done with the
packet.

This patch includes the handlers for the end-of-stroke and end-of-sequence
packets, the rest to be added later.
2018-02-16 15:43:28 +10:00
Peter Hutterer 43064b58fc wacom: add a WacomPacket class
Instad of carrying around a lot of parameters, move this into a class with
properties. Eventually we can subclass that one for the special opcodes (or
something...)
2018-02-16 15:43:28 +10:00
Peter Hutterer 23e18cea67 drawing: add a stroke.seal() functionality
Makes end-of-stroke handling easier, we can call seal() on the current stroke
and it'll make drawing.current_stroke() None, which is something we can deal
with.
2018-02-16 15:43:28 +10:00
Peter Hutterer 155a11104c wacom: print an error if our device is more than 5 mins out 2018-02-16 15:43:28 +10:00
Peter Hutterer 09bfe44dd7 drawing: rename the stroke from 'l' to 's'
Leftover copy/paste error from when this class had a Layer subclass
2018-02-16 15:43:28 +10:00
Peter Hutterer 9fbfe17e13 ble: disable a debug message
Now that we got the basics running and reliable, this debug message is mostly
just noise, especially when in an office with lots of bluetooth devices
around. Comment it out, to be enabled when necessary.
2018-02-16 15:43:28 +10:00
Benjamin Tissoires 17dc80bea3 wacom: fix report descriptor logical min/max
Changing the python representation is not enough. We also need to change
the HID marker with the correct size.

Fixes 67b4d2b8fe
2018-02-14 13:11:37 +01:00
Peter Hutterer d0001e18ed tools: chmod +x on tuhi-live 2018-02-14 16:25:56 +10:00
Peter Hutterer a5c9d12a18 README: document live mode
Fixes #89
2018-02-14 16:13:29 +10:00
Peter Hutterer 67b4d2b8fe wacom: allow 4 bytes for width/height
Intuos Paper needs more than 16 bits

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-14 15:52:34 +10:00
Peter Hutterer 138497a73b wacom: add support for the Intuos Pro 2 paper 2018-02-14 15:03:02 +10:00
Peter Hutterer 7796d3c110 wacom: don't add points to the log until we have an absolute value
On the Intuos Pro at least we sometimes get events that are all relative at
first and it can take several events for us to have all three values as
absolute. This is likely a parsing error on our side, but meanwhile don't
write the data until we have at least one known value for all three axes.

And because the SVG writer isn't happy with empty strokes, add a seal()
function to the drawing to purge empty strokes.

Fixed #92 or at least works around it
2018-02-14 14:54:17 +10:00
Peter Hutterer 6c156efc01 wacom: make relative/abs events more obvious in the log
Mark the deltas with a * if they're the ones that changed.
2018-02-14 14:50:49 +10:00
Peter Hutterer 80d0066cef wacom: we only have one drawing per exchange
skip putting a single drawing in a list
2018-02-14 14:50:49 +10:00
Peter Hutterer c39b735e1e wacom: factor out the 'next stroke data' parsing 2018-02-14 14:50:49 +10:00
Peter Hutterer 8ecc397303 wacom: skip over the prefix when handling pen data
The prefix (4 bytes on the spark/slate) is some data that we don't know yet.
It *could* be the size of a tablet/drawing in LE byte order: 14434x29794
although that doesn't quite match the Intuos Pro data where the prefix is
different.

Either way, having this be an opcode of 0x3800 was probably just coincidence.
Let's skip over the header normally and assume that once we have a prefix, we
have a drawing. This opcode never occurs a second time within the same
drawing.
2018-02-14 14:50:49 +10:00
Peter Hutterer 876f35f806 wacom: factor out the prefix handling
The Intuos Pro has a different prefix, we'll need to override this. Dropping
the comment about the 8bt, on the intuos pro the prefix is nonsensical so
let's not leave a false lead there.
2018-02-14 14:50:45 +10:00
Peter Hutterer 726362107b wacom: append multiple nordic answers to each other
On the Spark, the 0xc9 CRC comes almost immediately after the 0xc8
end-of-sequence. This causes a race condition where sometimes we process the
0xc8 before the 0xc9 arrives, other times the 0xc9 overwrites the current
nordic_answer value before we get to it - triggering an unexpected opcode
exception.

Fix this by appending the nordic answer and only ever pulling off enough to
satisfy the current request.

Fixes #90
2018-02-14 11:25:13 +10:00
Peter Hutterer 240b982070 wacom: fix Spark CRC check
All it needs is less reversing
2018-02-14 11:25:13 +10:00
Peter Hutterer 45d4d6fb9b wacom: merge two debug strings 2018-02-14 09:45:49 +10:00
Benjamin Tissoires 422045e2fd wacom: insert proper ranges for X and Y in the uhid device
Also fix the pressure range to be 2047
2018-02-14 06:23:25 +10:00
Benjamin Tissoires 99a2f7bdc5 kete: parse incoming uhid data 2018-02-14 06:23:25 +10:00
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 d4dd672b2f live-mode: properly pack the fds over DBus
Keeping this one as a separate commit, so we can use it as a future
reference.
2018-02-14 06:23:25 +10:00
Benjamin Tissoires fec265cb68 live: add a script to run as root that enable live mode
we want to be able to open uhid, so we need root access.
Root access is bad, so we fork the process, and then immediately drop
the privileges to talk to the dbus dameon (or to create one).
2018-02-14 06:23:25 +10:00
Benjamin Tissoires 3eca8da251 kete: add live debugging mode
Just start/stop live mode, the debug happens in the tuhi process.

That's enough until we figure out the DBus API if we need one
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
Benjamin Tissoires 41a3c85b59 kete: export the connected state of the bluez device to the tuhiketedevice
We need this in the live mode as the connection will be longer than
the usual retrieval of the data.
2018-02-14 06:23:25 +10:00
Benjamin Tissoires e4e0a3b8aa kete: rename the script from tuhi-kete.py to kete.py
Python doesn't really like minus signs in file names, especially
when you start importing the modules. Rename kete from tuhi-kete.py
to kete.py so it makes it easier to have other scripts in the tools
folder to borrow code from kete.
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