Commit graph

16 commits

Author SHA1 Message Date
Peter Hutterer
2e4ce7008b libei: implement ei_peek_event()
At least for the test suite, I'll need something that allows me to look at an
event without removing it from the event queue. Just the event type isn't
enough, I need things like "what are the caps on the device". Simplest way to
allow this is a peek function that doesn't remove the event from the queue.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:19:03 +10:00
Peter Hutterer
bc5be06549 libei: add a backend to work off a single fd
For the case where someone else opens the sockets for us - like a test suite
or eventually the portal.

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
0ab1458241 test: add some internal unit-tests to libei
Similar in style to Rust where the unit tests are in the same file. Let's see
how far we can get with that in C. Auto-discovery of tests by forcing the
respective suites into a special test section so we can collect it later from
our unit runner.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 14:47:40 +10:00
Peter Hutterer
b4552374ca libei: documentation updates
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 14:47:40 +10:00
Peter Hutterer
cb192945d2 Make the button events carry event codes, not indices
Brings this more in line with libinput and, well, everything on linux, really.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-03 20:46:13 +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
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
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
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
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