Commit graph

199 commits

Author SHA1 Message Date
Peter Hutterer
bde5b37acf Include stddef.h for size_t
And add the minimal build tests to make sure we build and link

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 13:01:37 +10:00
Peter Hutterer
b913e7e609 brei: fix a compiler warning in release mode
Re-ordering commands in buildtype=release means recvfd may not be set by the
time _cleanup_ is called (due to the goto outs). Replace those with return
statements, it's more logical here anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 12:30:25 +10:00
Peter Hutterer
e238a5d049 util: fix receiving of multiple fds
Initial implementation only handled this correctly if the fds were over
multiple message headers, not multiple fds in the same message header.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 11:01:01 +10:00
Peter Hutterer
65c069e6a0 util: fix a valgrind warning in xsend_with_fd
valgrind complains about uninitialized bytes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 08:53:49 +10:00
Peter Hutterer
17d396aaf1 Add size handling for the keymap
Just sending the fd isn't good enough, to mmap those we need the size argument
too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 18:57:25 +10:00
Peter Hutterer
4af29d930a tools: add keymap handling to the socket demos
Client sets layout fr, server accepts it and prints azerty for the keys
pressed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 18:57:25 +10:00
Peter Hutterer
2a619fd4b4 utils: basic helper for creating a file in memory
Needed by the tools for keymap handling.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 16:03:34 +10:00
Peter Hutterer
575943e744 test: add another dispatch for the suspend test
In case the RESUMED isn't written on the wire yet (or it's written with
sendmsg and thus a separate message on its own) we don't have the RESUMED
ready for us yet. Let's call another dispatch to make sure it's processed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
d160f6c7af test: enable debug logging again
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
819b1e86b1 libei: integration of keymap fd parsing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
fef9580319 libeis: push the new brei_message one level up into eisproto
This is the proto parser and it'll know when we need an fd on the message, so
let's make sure we have everything in place to fetch the fd.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
397bb3f19d brei: hook up the brei message so we can retrieve an fd
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
38c50d0d3d libei: push the new brei_message one level up into eiproto
This is the proto parser and it'll know when we need an fd on the message, so
let's make sure we have everything in place to fetch the fd.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 14:51:53 +10:00
Peter Hutterer
d4fedc1a4b brei: abstract the message type away
Once we start passing fds within messages, we need something more abstract.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 14:51:53 +10:00
Peter Hutterer
dabd48c028 util: add fd passing to the iobufs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 14:51:53 +10:00
Peter Hutterer
56ca4b4ac7 util: add sending and receiving fds to the io utilities
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 11:49:53 +10:00
Peter Hutterer
9e42b579d9 util: typo fix in comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 10:04:43 +10:00
Peter Hutterer
ab453cd1f4 libei: hook up the API for keymap assignments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 09:08:45 +10:00
Peter Hutterer
5749f3ec27 brei: fix use of uninitialized data
This was intentional here but valgrind doesn't like it, so let's just set it
to something that should look odd.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 08:45:05 +10:00
Peter Hutterer
eb8e204f27 util: fix use of uninitialized variable
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 16:07:54 +10:00
Peter Hutterer
f3a60ca6b3 Fix maybe-uninitialized warnings
Building with a releaes build reshuffles things so this ends causing potential
issues. Initialize to NULL to avoid around this.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 16:07:54 +10:00
Peter Hutterer
a835093321 Add gitlab CI
Mostly copied from libinput and simplified so we only test on Fedora for now.
Good enough that it should catch accidental breakages.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 16:07:54 +10:00
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
7d7e7fc5e0 libeis: set the user data we passed to libeis_new()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
5b1d74cf19 libeis: use get/set user_data, not userdata
For consistency with libei.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
3b5316a7b7 meson: hook up unit tests for eis as well
None defined for now, this is the build system setup only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
741425b803 util: add a wrapper macro for running code only once
Macro around the usual static bool stuff, let's see if this is more readable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
b00fe9ed99 util: move the ansi color escape sequences into a separate header
Make the default set an enum with an array to access the codes. Additionally
provide a true RBG escape sequence, all modern terminals support that anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
91c4bc2a93 libei: handle a late device connect correctly
Where the server connects a device after the client has already removed it, we
need to ignore that message silently.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
689e5c4ed9 util: remove a libinput leftover
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
f8fa944262 test: add helper functions for checking for no events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
b7ddbf0a53 libeis: make the device ref/unref public
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
2b29b6e1b9 libei: add ei_device_get/set_user_data
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
d7831fe81a libei: some more documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
5811ee7306 libei: drop two unimplemented example init functions
These were added originally to illustrate how the diffent backends could work
but they're not going to be implemented this way anyway. So let's just drop
them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
8bddc3008f test: expand the ei tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
76e5b30451 libei: change the behavior of the REMOVED message
If a client calls ei_device_remove(), it should consider that as the last
interaction with this device (short of unref). There is no need for the server
to confirm this, no further events must reach the client for this device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
451875e287 libei: if we get disconnected after ei_device_add(), queue a removed event
If we get disconnected after calling ei_device_add() but before EIS saw and
processed the event, we need to emulate a removed event ourselves.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
a41a025b65 test: add some documentation for the test helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
8a8c72b24e test: rename a helper function
This function dispatches until a stable state is reached - that could be no
event waiting or some event waiting to be processed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
1fdbba2ec9 test: rename two tests to reflect current nomenclature
"reject" isn't a thing, "disconnect" is

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
1fe93ae8be Factor out munit test handling into a set of helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
451f863894 brei: add a dispatch helper function for protocol messages
This de-duplicates a bunch of things that we don't need to duplicate,
specifically the protocol part that splits the data up into parseable chunks.
That we have Frames in between messages is an implementation detail, this way
neither libei nor libeis have to care about it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
d26ab60b1f test: fix the naming of some unit tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
a20d09c049 libeis: use the shared next_message helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
4daab4de92 Move the next message helper into a shared function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00