Commit graph

956 commits

Author SHA1 Message Date
Peter Hutterer
2fbd22984f util: fix iobuf_append_fd OOB when we have too many fds
Cannot happen in deploymentts since we never have more than one anyway.

Fixes #43
2023-08-30 09:11:08 +10:00
Peter Hutterer
b7ab63c386 util: fix iobuf_take_fd invalid memmove for multiple fds
Wrong calculation resulted in memmoving only the first 32 bytes (i.e. 8
fds) instead of the first 32 fds, resulting in an infinite loop when
cleaning up an iobuf with more than 8 fds.
2023-08-30 09:11:08 +10:00
Peter Hutterer
7ddd70e9d8 Add ei_device_get_region_at() to obtain a region for a point
Helper function so clients don't need to loop through the regions to
find the matching one.
2023-08-29 11:39:20 +10:00
Peter Hutterer
36f1641125 meson.build: bump to use gnu11 over gnu99
static asserts require C11
2023-06-09 10:27:55 +10:00
Peter Hutterer
661f7665d7 libei 1.0.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-06-08 09:23:45 +10:00
Peter Hutterer
39e6c93c8b test: ensure all returned interface versions are 1
Even where our client pretends to have higher interface versions, we
always send back version 1 from the EIS implementation.

This test probably won't really trigger anything useful until we switch to
version 2 somewhere, so let's hope the code works...
2023-06-07 23:08:16 +00:00
Peter Hutterer
97a5538258 test: add test for correct ei_device_close behavior 2023-06-07 23:08:16 +00:00
Peter Hutterer
1f51c05897 test: don't over-ref the button/scroll devices
If we create a pointer and an absolute pointer in a test, we end up with
two devices that both have button and scroll capabilities.
Overwriting those results in a dangling ref to the device.
2023-06-07 23:08:16 +00:00
Peter Hutterer
b14405d3cd ei: fix a whitespace error 2023-06-07 23:08:16 +00:00
Peter Hutterer
22079d62dc test: add a unit test for ei_region_convert_point 2023-06-07 23:08:16 +00:00
Peter Hutterer
059d3e11b6 eis: send all our interface versions to the client
The protocol requires this only for interfaces that create client-side
objects but let's do it here anyway to ensure the code is tested.
2023-06-07 23:08:16 +00:00
Peter Hutterer
e0d60b062c ei: removed unused ei_callback_new_for_id
Leftover from an earlier version before callback and pingpong were split
into separate interfaces.
2023-06-07 23:08:16 +00:00
Peter Hutterer
befab06ea2 tests: add tests for button events
Those were missing, luckily the code works
2023-06-07 23:08:16 +00:00
Peter Hutterer
aa3c2eb763 ei: remove unused ei_pingpong_new()
Copy/paste from the callback interface I think, so let's remove it.
2023-06-07 23:08:16 +00:00
Peter Hutterer
6caf69a73c test: check that the width/height are set for physical devices 2023-06-07 23:08:16 +00:00
Peter Hutterer
a9edea65ca ci: add a check that our event values cannot diverge
See commit 168de89a "eis: sync event codes with libei", this script
should've prevented that issue.
2023-06-07 14:36:00 +10:00
Peter Hutterer
2d6b11833b CI: remove a copy/pasted MESON_ARGS from the abicheck job 2023-06-07 14:28:04 +10:00
Peter Hutterer
987997dc2c test: add tests for the eis region getters 2023-06-06 19:41:54 +10:00
Peter Hutterer
f0894aac67 test: drop ifdef'd out test
It's been ifdef'd out for long enough that clearly this test doesn't
matter anymore.
2023-06-06 10:56:53 +10:00
Peter Hutterer
4096d100ee ei: more docs that data is in pixels or mm
This depends on the device type and was-already documented in some
functions but not others.
2023-06-06 10:54:48 +10:00
Peter Hutterer
b5f0899352 eis: expose eis_region_contains
Same as the libei function, there's a use-case for this especially when
dealing with receiver contexts. libei filters those but we can't rely on
that in the server so using this is a workaround.
2023-06-06 00:50:05 +00:00
Peter Hutterer
fc79982682 eis: add eis_region_get_physical_scale
This can be set by the caller, so we should be able to get it later.
2023-06-06 00:50:05 +00:00
Peter Hutterer
1cf9412990 CI: fix the ABI check job, it was using the wrong HEAD
The ABI job git cloned from upstream and then compared HEAD with the
last ABI break. Problem though: the HEAD was origin/main, not the actual
HEAD from the merge request.

Fix this by adding upstream as a remote and fetching from it. And while
we're there update to the last ABI break commit sha and move the
abicheck bits into before_script.

Note that the remote has the CI job ID appended, this avoids conflicts
when the git repo is re-used betweenn jobs and the upstream remote
already exists.
2023-06-06 10:31:57 +10:00
Peter Hutterer
95366ea131 CI: use meson setup in the abi check job 2023-06-06 10:16:25 +10:00
Peter Hutterer
168de89a70 eis: sync event codes with libei
Commit da37da1308 "ei: change the API to match the protocol interfaces closer"
change the event type numbers for per-capability grouping but the
follow-up commit e6954b76d for eis didn't do the same. Right now the
event types are out sync.

This doesn't technically matter as this is a libeis implementation
detail (those types don't exist on the protocol) but it'd still be nice
to sync them before we ship 1.0.

This is an ABI break but not an API break.
2023-06-05 22:15:54 +00:00
Peter Hutterer
080864d82a Correct a meaningless comment 2023-06-05 12:19:19 +10:00
Peter Hutterer
7d0536f344 test: use the callback's version instead of hardcoding it a second time
Fixes f081e8e79f
2023-06-02 10:29:17 +10:00
Peter Hutterer
ed1acbbd7c eis: expose eis_device_get_context() and eis_seat_get_context()
For frame events on a device it's likely that we want to use eis_now()
which takes the context. So let's make this easy enough to access
without having to carry extra variables in the caller. And the same for
the seat as well.
2023-06-01 18:42:16 +10:00
Peter Hutterer
1175595acf tools: make the demo client send the correct discrete events
Multiples of 120 are needed
2023-06-01 15:12:07 +10:00
Peter Hutterer
cc053155a5 doc: change the doxygen oeffis group to liboeffis
This way the links are consistent with the libei/libeis groups.
2023-05-31 16:11:57 +10:00
Peter Hutterer
868a16df85 ei: ei_device_get_width/height need to be public APIs 2023-05-31 01:06:32 +00:00
Peter Hutterer
35ec414215 Remove unimplemented ei_device_get_keymap()
This is ei_device_keyboard_get_keymap() instead
2023-05-30 19:11:44 +10:00
Peter Hutterer
37e2bdebed CI: add a comment to the meson build helper
We now have an upstream for it so we can sync changes between projects.
2023-05-30 15:18:04 +10:00
Peter Hutterer
3ef22c8ed0 Log a bug if a client tries to send a discrete value 1
Discrete values are multiples of 120 and it's unlikely the device to be
emulated is *that* precise, so let's assume it's a bug and the client
wasn't aware of the 120-multiple requirement.
2023-05-30 11:14:57 +10:00
Peter Hutterer
3e908c03f4 log: remove trailing linebreaks from log messages
These are no longer needed or desired (see 37467881e6)
2023-05-29 17:54:20 +10:00
Peter Hutterer
1aedabe7c7 libeis: check incoming objects' version for correctness
If the server sends a protocol version higher than we support, fail.
2023-05-26 19:16:15 +10:00
Peter Hutterer
c99f4ffa2c libei: check incoming objects' version for correctness
If the server sends a protocol version higher than we support, fail.
2023-05-26 19:16:15 +10:00
Peter Hutterer
f081e8e79f proto: add a version argument to ei_connection.sync
This is the only request that creates a new object but doesn't specify
the version for that object, courtesy of copy/paste from the wayland
protocol. In libei/libeis this a bit was hidden away so it didn't get
noticed - but it was already buggy: libei would always hardcode to
version 1 but libeis would take whichever ei_callback version was agreed
upon during handshake. This version could be higher than 1.

This is a protocol break but we're still pre-1.0, there are very few
people that will be affected by this and it's better than having to
carry this bug around for years.

Fixes #35
2023-05-26 07:01:19 +00:00
Peter Hutterer
552f6dcbd0 ei-scanner: expose version_arg and version_arg_for
Points to the correspoding "version" argument, or points back to the
argument this version argument is for.
2023-05-26 16:56:13 +10:00
Ian Douglas Scott
1d8cd84c56 ei-scanner: Expose interface_arg, and also provide interface_arg_for
To make this practical to use in a template, we want relations in both
directions. And at least for consistency with other things, these fields
should contain the `Argument` instead of just its name string.

So we need to do this after are the arguments in the message have been
initially parsed. Adding these fields when parsing the request/event
close tag seems to work well enough.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-26 16:55:47 +10:00
Peter Hutterer
00226da59e scanner: add tests for the extra data arguments
Fixed in !218, let's test this so we don't break it again.
2023-05-25 10:09:28 +10:00
Peter Hutterer
3a9eb2d8b6 scanner: rework the main() function into something easier to test
Rename to scanner() and take an argument vector that can be passed to
ArgumentParser.parse_args(). This makes testing the scanner's CLI a lot
easier.
2023-05-25 09:51:42 +10:00
Ian Douglas Scott
091948e9ef ei-scanner: Fix --jinja-extra-data-file, and make mypy check pass 2023-05-24 11:33:12 -07:00
Peter Hutterer
016072507e CI: add a build test for our minimum meson version
Since meson is installed from pip, we'll use the latest stable version
when we build an image. Add an extra job with the fixed minimum version
so we ensure we actually build with that version.
2023-05-24 08:16:43 +10:00
Peter Hutterer
a75828aee0 meson.build: drop requirements back to 0.56
The bump to 0.60 was required for 2a2c4cdd but is no longer required
after 27ff400b.
2023-05-24 08:16:29 +10:00
Peter Hutterer
93fd69cdf3 libei 1.0.0rc2 2023-05-23 14:50:33 +10:00
Peter Hutterer
708aed6402 Export the event names through helper functions
Approximately every user of libei(s) will want something like this for
easier debugging, converting the numeric event type into something that
can be printed into the debug logs.

Let's provide this here so this doesn't need to be duplicated.
2023-05-22 02:39:08 +00:00
Peter Hutterer
ca06927371 test: add some tests for the ei-scanner itself
This is a bit convoluted because ei-scanner is named like that, so it
cannot be imported as python module. The solution for that is to
copy/rename it with meson to the builddir and run pytest in that. This
also allows us to set the path to the protocol XML file while we're at
it so we can use it as a fixture.

Actual tests are minimal for now, can be extended over time.
2023-05-22 10:54:28 +10:00
Peter Hutterer
f142f802f4 scanner: add the Interface.plainname property
Returns "connection" for the "ei_connection" interface, i.e. the
interface stripped of any component prefix.
2023-05-22 00:24:39 +00:00
Jan Beich
708d0f57e8 util: silence warnings when memfd_create is missing
src/util-memfile.c:55:1: warning: unused function 'memfile_create' [-Wunused-function]
OBJECT_IMPLEMENT_CREATE(memfile);
^
src/util-object.h:164:16: note: expanded from macro 'OBJECT_IMPLEMENT_CREATE'
struct type_ * type_##_create(struct object *parent) { \
               ^
<scratch space>:133:1: note: expanded from here
memfile_create
^

test/test-ei-device.c:37:1: warning: unused function 'memfile_unrefp' [-Wunused-function]
DEFINE_TRIVIAL_CLEANUP_FUNC(struct memfile *, memfile_unref);
^
src/util-mem.h:56:21: note: expanded from macro 'DEFINE_TRIVIAL_CLEANUP_FUNC'
        static inline void _func##p(_type *_p) {                \
                           ^
<scratch space>:159:1: note: expanded from here
memfile_unrefp
^
2023-05-21 09:04:16 +00:00