Commit graph

18 commits

Author SHA1 Message Date
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
537fdfde85 Drop ei_next_event_type() and eis_next_event_type()
Replaced by ei_peek_event() and eis_next_event_type()

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-18 14:42:23 +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
ba9b0bb903 eis: implement an fd backend
Caller opens the socket, passes it to eis, done.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:19:03 +10:00
Peter Hutterer
9ee00ada3a eis: implement eis_peek_event() and eis_next_event_type()
Motivation for peek is the same as for libei - the upcoming test suite needs
to check a few things before actually dequeuing the event.

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