Commit graph

26 commits

Author SHA1 Message Date
Peter Hutterer
ae5ef9ce2f tools: pretty colors for the demos
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
355093cc1b libeis: replace the logger utility with a custom logger handling
The logger utilities are useful for quick prototyping, but we've reached the
point where we need the "proper" implementation of a log handler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
14ee9f6e31 libei: replace the logger utility with a custom logger handling
The logger utilities are useful for quick prototyping, but we've reached the
point where we need the "proper" implementation of a log handler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
c4601b7196 Implement device suspend/resume with starting state of "suspended"
This was already spelled out in the documentation but just not yet
implemented. New starting state for any device added by EIS is "suspended",
the server needs to explicitly resume it before events are accepted.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
629f3043ad libeis: rename get_x/get_y to get_dx/get_dy
These are deltas, let's name them as such

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
d4e274ee6f libeis: flatten the event hierarchy
Same as already done for libei. There's relatively little benefit here since
we won't have a lot of different events and any caller will do the switch
based on the event type anyway. So let's just export a single event type and
have everything contained in that.

Since this required rewriting all getters, let's move the lot to a new file
and streamline things a bit that way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-18 16:05:52 +10:00
Peter Hutterer
515b67c6da tools: use a cleanup function for unlinking the socket
This way we can't forget to remove the file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:17:51 +10:00
Peter Hutterer
39b5ba74a4 Switch the various coordinates to doubles
Original idea of 1/1000 of a pixel was to allow subpixels while sending fixed
width down the wire. Let's not care about that and use doubles instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:17:51 +10:00
Peter Hutterer
2e944450a0 tools: change the default socket to $XDG_RUNTIME_DIR/eis-0
This matches the future portal implementation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:17:51 +10:00
Peter Hutterer
69448e247c libeis: rename to eis_setup_backend_socket()
Now that the backend is more of an implementation detail, namespace for
eis_setup_backend_foo()

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:12:19 +10:00
Peter Hutterer
cb976a2f95 tools: fix a few memleaks on errors
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:12:19 +10:00
Peter Hutterer
d2ecf43abd libeis: switch to a single eis_new() function
The main reason for having different functions to create the initial context
was so we can nest the eis struct inside the context-specific struct. That
shouldn't leak into the API though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:12:19 +10:00
Peter Hutterer
48cbc48a38 tools: stop immediately on a disconnect event
We shouldn't get any events after this anyway, so the real-world impact here
is limited.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:12:19 +10:00
Peter Hutterer
311bc6b4fc libei: rename to ei_setup_backend_socket()
Now that the backend is more of an implementation detail, namespace for
ei_setup_backend_foo()

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 14:52:54 +10:00
Peter Hutterer
283cc87416 libei: switch to a single ei_new() function
The main reason for having different functions to create the initial context
was so we can nest the ei struct inside the context-specific struct. That
shouldn't leak into the API though and our use-case is probably one where we
create one context, then iterate through possible backends until one succeds -
having different contexts here doesn't help then.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 14:47:40 +10:00
Peter Hutterer
39fcf16ec8 tools: add key events to the example client
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-03 12:04:00 +10:00
Peter Hutterer
a9f07368a5 Implement pointer button and keyboard key events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-03 12:00:31 +10:00
Peter Hutterer
40682a0420 Use send() instead of write() to prevent SIGPIPE
We're in a library here, so expecting the caller to handle SIGPIPE just in
case we get it is a bit demanding. Let's use send() instead so we can just
prevent that altogether.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-31 14:27:18 +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
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
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
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
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
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