Commit graph

1180 commits

Author SHA1 Message Date
Peter Hutterer
8ec0f4bf7c Send the trailing null byte for composed string messages
The iobuf treats this as binary data but then we're using it as strings in the
message parsing code. So make sure all messages have a trailing null byte.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30 21:01:09 +10:00
Peter Hutterer
1817071b5a tools: default to the LIBEI_SOCKET if present
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30 15:38:40 +10:00
Peter Hutterer
1bdca21772 libeis: remove the socket on exit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30 15:38:40 +10:00
Peter Hutterer
6062a0f676 libei: take the LIBEI_SOCKET variable if the socket path is NULL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30 15:38:40 +10:00
Peter Hutterer
b1231dfa1f libei: add a hook to configure the client name
Better than the current "myclient". Lacks safety and whatnot so long-term it
will have to get replaced with something else.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30 15:38:40 +10:00
Peter Hutterer
f228927b1f README: add some clarification for why libei
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 20:56:47 +10:00
Peter Hutterer
7e6afe2373 tools: make the socket server example take a socket path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 16:18:24 +10:00
Peter Hutterer
8078424c14 meson: fix header installation and pkgconfig libraries
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 16:18:24 +10:00
Peter Hutterer
31581eb110 tools: terminate the example server correctly on SIGINT
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 16:18:24 +10:00
Peter Hutterer
802dfd4ca6 Add the minimal implementation for a UNIX socket libei client
This is the minimum framework to support connecting to a libeis server, adding
a device and sending relative pointer motion events.It's missing a bunch of
checks and verifications, many of the hooks are still missing, etc.

See the tools/ directory for an example. The protocol is as outlined in
commit f7a24b2fbd.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 16:18:24 +10:00
Peter Hutterer
27670000e4 libeis: only log client state transitions if they changed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 11:52:23 +10:00
Peter Hutterer
247b6d0dcb libeis: fix wrong message field assignment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 10:59:07 +10:00
Peter Hutterer
b79f309a6c libeis: whitespace fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 09:59:11 +10:00
Peter Hutterer
90722a12ce tools: handle multiple events after a single dispatch()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 09:44:45 +10:00
Peter Hutterer
693b3767f2 tools: handle device removal
Well, print it, anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 09:43:06 +10:00
Peter Hutterer
23c34fc77d client: handle the case of zero data bytes
When terminating the connection, we might get a read of zero

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 09:42:42 +10:00
Peter Hutterer
fb115a1f43 libeis: avoid a cleanup double-free
Aparently the compiler is not smart enough to handle the case correctly where
a cleanup variable is introduced after a goto statement.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 09:41:56 +10:00
Peter Hutterer
b840c510bf libeis: remove existing devices before disconnecting the client
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 09:41:07 +10:00
Peter Hutterer
f7a24b2fbd Add the minimal implementation for a UNIX socket libeis server
This is the minimum framework to support new clients, added devices and
pointer relative motion events. It's missing a bunch of checks and
verification, most of the server hooks aren't there yet, the only
implementation is a UNIX socket and the protocol is plain text (but at least
the last two makes it netcat-compatible).

Protocol is plain text for now and interaction is like this (S is server, C is client):
S: hello
C: connect myclientname
S: connected
C: add 2 4
S: accept 2
C: rel 2 -1 1
C: rel 2 5 4

Where the last two lines are: add device with id 2 and capability mask 0x4,
send a relative pointer motion event for device 2 with coordinates -1/1, then
5/4.

The implementation relies heavily on some abstraction and macros galore, see
the various util-* files. These are largely copied from libinput, with a few
parts removed and a few other parts added.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-28 19:33:34 +10:00
Peter Hutterer
805ba96271 libeis: declare a few extra functions that will be useful
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-28 14:18:32 +10:00
Peter Hutterer
a09a99b6d9 libeis: add the init bits for a new libeis context for unix sockets
This is the easiest to implement, so let's start with that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-28 14:17:58 +10:00
Peter Hutterer
7f53c30157 libei: add a HELLO message on connect
This allows for some negotiation - server sends hello with some magic auth
data, client sends connect with the reply to the hello. Not sure yet how or
whether this makes sense, but at least it makes testing easy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-27 13:16:56 +10:00
Peter Hutterer
91781ad3e0 Drop the _ctx suffix to the main structs
No proper reason, it just goes easier with the macros I'm about to implement.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-25 16:18:33 +10:00
Peter Hutterer
5ba5f7d015 examples: update for the latest API changes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-16 13:32:27 +10:00
Peter Hutterer
1fea949114 Update keymap handling
keymap handling is difficult because a lot of it relies on specific server
implementation details. So let's provide the API for a client to assign a
specific keymap to the device and for the server to accept/refuse/override
that keymap.

Where the server refuses, it's up to the client to figure out the rest.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-16 13:32:27 +10:00
Peter Hutterer
68f9fa4b1c Simplify the suspend/resume behavior
The use-case of suspending individual capabilities is niche - where a client
needs to rely on this it should create multiple devices with different
capabilities so they can be suspended separately.

Also clarify that the server *must* process events even from a suspended
device. This works around a race condition where a client has sent several
events already before the suspend comes in - it has to assume that any event
sent before the server event is handled updates the state in the server.

Implementation-wise, libei will start filting events once ei_dispatch()
returned the suspend event to the client.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-16 11:01:05 +10:00
Peter Hutterer
61bdb2c891 libeis: caps shouldn't be a bitmask
Only allow changing or querying for a single capability at a time.
More verbose but less ambiguous and it removes any bugs resulting from bitmask
errors. There is no supported use-case where the server *adds* a
capability to a client-requested device, so has_capability and
disable_capability is enough.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-16 10:19:36 +10:00
Peter Hutterer
e6b280a98e libei: make the pointer/touch ranges constant and client-determined
We assume that any libei client has access to the windowing system through
other means (at least where it matters) so they can set up the pointer range
accordingly. This also allows the server to do heuristics on monitor mapping,
similar to what we have for Wacom tablets already.

And forcing the ranges to be constant means the race conditions are halved,
only the client is now affected by a potential race condition between the
screen size changing and the pointer ranges needing updates. Those can be
mitigated by the server though, e.g. an input device that maps to a
single-monitor *should* still be mapped to that same monitor after another
monitor is plugged in (and this should apply before the client is notified of
the screen mapping). So the client events in transit will still go to the
right position of the screen (though admittedly the target areas may have
migrated to the new screen so the click now goes wrong anyway).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-16 10:17:13 +10:00
Peter Hutterer
562e120da8 libei: change the device creation API a bit
Split into a _new() call and make the others setters, with a bit more
explanation of what the server does.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-16 10:17:12 +10:00
Peter Hutterer
5e649f682a Initial commit
This is the outline of the API intended with a minimal compiler just to verify
there are no immediate parsing issues.
2020-07-16 10:17:09 +10:00