Commit graph

858 commits

Author SHA1 Message Date
Peter Hutterer
08efdee83d eis: remove a misleading paragraph from the docs
The 99% use-case for receiver clients is probably going to be capturing
logical input, not physical input.
2023-05-08 13:03:15 +10:00
Peter Hutterer
b3c202af23 ei: tighten the event type checks
Require exact event types, not just approximate ones. It's always a bug
to call any of these functions for an event type that's something else.
2023-05-08 12:49:40 +10:00
Peter Hutterer
c076c48336 doc: split the libei doxygen API into multiple submodules
The API is quite long now, so let's split it up into multiple logical
groups. The main page is now roughly graspable, with seats, devices,
regions and keymaps in submodules.

The sender and receiver APIs are also grouped into two separate APIs -
anyone implementing either doesn't need the other, it just messes things
up.
2023-05-05 14:05:30 +10:00
Peter Hutterer
5bb6e80ded doc: some minor doxygen updates 2023-05-05 14:05:30 +10:00
Peter Hutterer
aa866c5a92 Add a few more doxygen comments 2023-05-05 14:05:30 +10:00
Peter Hutterer
60d94aecda doc: rename the mainpage sections to get @ref ei to work
Otherwise doxygen tries to link to these sections instead to the struct
ei/eis it's supposed to link to.
2023-05-05 14:05:30 +10:00
Peter Hutterer
e6954b76d3 eis: change the API to match the protocol interfaces closer
Same as the corresponding ei change a few commits ago, this one does all
the EIS renaming in the same manner.

As with the libei changes, an EIS implementation must now handle the
EIS_DEVICE_CAP_BUTTON and EI_DEVICE_CAP_SCROLL capabilities. In
virtually all cases, clients will likely expect that a device with the
pointer or absolute pointer capabilities will also have button and
scroll capabilities.
2023-05-05 14:04:17 +10:00
Peter Hutterer
da37da1308 ei: change the API to match the protocol interfaces closer
Now that the protocol interfaces are more fine-grained, let's match this
with the C API too.

This is just a rename of things so that in general
ei_pointer_*foo now becomes ei_foo*.

A few notable renames for better readability here:
- ei_device_scroll_delta (because scroll_scroll is awkward)
- ei_event_scroll_get_dx/dy and
  ei_event_scroll_get_discrete_dx/dy to indicate the delta-ness

Beyond that, clients must ensure to check/bind to the new
EI_DEVICE_CAP_BUTTON and EI_DEVICE_CAP_SCROLL capabilities to be able
to send button or scroll events.

Note that this API now allows for an EIS implementation to send a device
that only has a button or a scroll cap. Or a pointer cap without
buttons, etc. It's up to the clients how to handle such devices
(probably: ignore them).
2023-05-05 14:02:33 +10:00
Peter Hutterer
6ee202569f doc: point to the main branch, not the master branch 2023-05-04 14:11:34 +10:00
Peter Hutterer
e1b2db8c10 Purge the pseudo-code examples
They haven't been kept up-to-date with API changes, so let's point to
the actual working demo tools instead.
2023-05-04 14:11:34 +10:00
Peter Hutterer
a902d5dbd8 protocol: replace the capabilities enum with an interface list
Previously we had ei_seat.capabilities and ei_device.capabilities,
both referring to the same enum. The seat caps were used to bind,
the device caps were used to announce capabilities.

The device caps were already mostly superfluous as the information
they carried was implicitly available by the set of interfaces
the device announced - if the device has a keyboard interface
it must also have the keyboard capability.

So let's drop the separate enum and make the capabilities
the set of supported interfaces. In the device we can drop the
event directly and just send the interface list. In the seat
we have a capability event that sends each *possible* interface
with a custom-assigned mask. The client can then use that mask
to bind to the capability as before.

For example:
   <- ei_seat.capability(0x1, "ei_pointer")
   <- ei_seat.capability(0x4, "ei_keyboard")
   <- ei_seat.capability(0x8, "ei_touchscreen")
   <- ei_seat.done()
   -> ei_seat.bind(0x4 | 0x8)  # bind to keyboard and touchscreen
   <- ei_seat.device()
   -> ei_device.interface("ei_keyboard")
   -> ei_device.interface("ei_touchscreen")
   <- ei_device.done()

In the generated bindings we simply use the interface index
to generate the masks, but the protocol at least states that
the mask may not be constant.

Because the button/scroll interfaces are not exposed by the C API, some
of the handling is a bit awkward since we need to use both depending
whether we have pointer/pointer_absolute selected.

Fixes #28

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-02 05:53:25 +00:00
Peter Hutterer
bf88b34918 Split the ei_pointer interface up into its components
Split the ei_pointer protocol interface into ei_pointer,
ei_pointer_absolute, ei_scroll and ei_button.

This gets rid of the slightly awkward pointer vs pointer absolute
handling. Those were two different capabilities but tied to the same
interface.

Plus it paves the way for devices that are keyboards with scroll
buttons, etc.
2023-05-02 05:53:25 +00:00
Peter Hutterer
a157cbfa42 Rename an internal struct to scroll_state
To avoid future name clashes.
2023-05-02 05:53:25 +00:00
Peter Hutterer
6215eecfbd test: fix a debug log typo 2023-04-27 15:22:07 +10:00
Peter Hutterer
d21726965b doc: move the sentinel attribute to unconfuse doxygen
The compiler doesn't care, doxygen apprently does.
2023-04-27 14:42:25 +10:00
Peter Hutterer
97a7a3e360 doc: fix two obsolete API comments 2023-04-27 14:42:22 +10:00
Peter Hutterer
53f4564019 meson: require the python modules that the scanner requires
The scanner uses attr and jinja2, so let's make sure we have them.
2023-04-26 14:25:21 +10:00
Peter Hutterer
f6cd949472 test: cast the varargs to the right data size
Fixes the test suite issues on 32 bit. Only needed for the 64 bit
arguments, but let's do the 32 bit as well for solidarity and
readability.

Fixes #30
2023-04-26 12:18:58 +10:00
Peter Hutterer
9c5c3c890f ei: de-duplicate ei_seat_unbind_capability
ei_seat_unbind_capabilities does the same, so let's use that.
2023-04-14 10:52:39 +10:00
Peter Hutterer
cf74cfeb1e ei: fix ei_seat_unbind_capabilities
Simplify the code a little but more importantly: if we get down to zero
capabilities close the devices - just like we do in
ei_seat_unbind_capability.
2023-04-14 10:51:40 +10:00
Peter Hutterer
1a4764d99b libei 0.5 2023-04-06 14:19:22 +10:00
Peter Hutterer
f15736e809 scanner: add a validator for Interface.mode
Not really needed since we currently have an assert in create but this
makes the code more obvious.
2023-04-06 14:01:07 +10:00
Peter Hutterer
3546a443a9 scanner: auto-mangle the interface name when accessed
Now that we only have one place where we need to mangle the name, let's
make this a property of the Interface instead.
2023-04-06 14:00:44 +10:00
Peter Hutterer
cfd2980ae4 scanner: look up interfaces by protocol name
Now that we have it, let's use it instead having to mangle names.
2023-04-06 13:57:20 +10:00
Peter Hutterer
24680aef2e test: use an enum iterator to loop through the interface names 2023-04-06 13:57:20 +10:00
Peter Hutterer
5aad9fd777 scanner: add the protocol name so we can compile some #defines
The protocol name on an interface is a fixed string that is part of
the ABI since it's used in a few messages (e.g.
ei_handshake.interface_version). To avoid typos, let's expose that
string in the scanner and #define it in the generated sources.
2023-04-06 13:57:20 +10:00
Peter Hutterer
fa07430683 scanner: use mangle_name for the interface name 2023-04-06 13:57:20 +10:00
Peter Hutterer
99b36ba652 test: add a test for pointer vs abs pointer receiving 2023-04-06 13:57:20 +10:00
Peter Hutterer
7f7880d953 test: add test for receiving the device interfaces 2023-04-06 13:57:20 +10:00
Peter Hutterer
5b1b5aec1a proto: replace pointer/keyboard/touchscreen with a generic "interface" event
Since these events are merely notifications of a single object, we can make
this more generic. This allows us to introduce future capabilities without
having to bump the seat.
2023-04-06 13:57:18 +10:00
Peter Hutterer
4b77664dc1 test: if we fail to load liboeffis.so, skip the rest of the pytests
This gives us a nicer behavior when (semi-intentionally) running pytest
in the source directory.
2023-04-06 12:04:51 +10:00
Peter Hutterer
6179c91580 test: fix the exception check for the missing eiproto module
When running pytest from the source directory we get a
ModuleNotFoundError, not an ImportError.
2023-04-06 12:04:35 +10:00
Peter Hutterer
0aa8bab9c0 test: drop the default timeouts to 2
There's no need to wait any longer.
2023-04-05 14:22:31 +10:00
Salman Malik
a438e46e18 config: Make memfd_create optional
`memfd_create` doesn't seem to be supported on
all platforms (e.g. ubuntu 18 has trouble with it).
Even though, I was able to substitute `memfd_create`
with a direct system call, I was not able to get
the `MFD_CLOXEC` flag (from fcntl.h) working cleanly
(there were redefinitions/conflicts for other
structures when trying to use <linux/*> headers).
Making it optional for time being till we have
figured out how to make it work broadly.
2023-03-28 11:24:06 +00:00
Salman Malik
8b7fb73bfd ei-scanner: Adjust annotation for list
Otherwise Python complains about:

TypeError: 'type' object is not subscriptable
2023-03-25 23:00:41 +00:00
Peter Hutterer
5332124abf CI: add a debian bullseye job 2023-03-19 07:56:09 +00:00
Peter Hutterer
74ed569fe0 test: skip the oeffis tests if we don't have dbusmock 0.28.5 2023-03-19 07:56:09 +00:00
Peter Hutterer
bba921329d proto: skip the bitmask check if on old python versions
int.bit_count() requires Python 3.10, so let's skip it where not
available.
2023-03-19 07:56:09 +00:00
Peter Hutterer
a95c9e1799 meson: drop version requirement to 0.56 so we can build on Bullseye
Looks like the only more recent meson feature we use is for
'exclude_suites' in the valgrind test setup. We can just skip that.
2023-03-19 07:56:09 +00:00
Peter Hutterer
c5aa2c0b60 doc/proto: address a few documentation issues
A few clarifications as suggested by Benjamin Tissoires.
2023-03-17 14:03:32 +10:00
Salman Malik
150ac5b4ac src/meson.build: Switch shared_library => library
This is the recommendation from meson documentation. The default
option is still to create a shared library but doing it this
way gives users an opportunity to create either a shared, static
or both type of libraries by setting up the meson build appropriately.

Here is the result with the default setup:

$ meson setup . _build
$ meson compile -C _build
$ find _build | egrep "(\.so|\.a)$"

_build/subprojects/munit/libmunit.so
_build/test/libunittest.a
_build/test/libeierpecken.a
_build/src/libei.so
_build/src/liboeffis.so
_build/src/libutil.a
_build/src/libeis.so

And here it is with the overridden flag:

_build/subprojects/munit/libmunit.a
_build/test/libunittest.a
_build/test/libeierpecken.a
_build/src/libei.a
_build/src/libeis.a
_build/src/liboeffis.a
_build/src/libutil.a

$ meson setup . _build  --default-library=static
$ meson compile -C _build
$ find _build | egrep "(\.so|\.a)$"
2023-03-15 00:47:15 +00:00
Peter Hutterer
1bc04bffa8 CI: add new workflow rules
Required for pipelines to run after some infrastructure changes, see
See https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/438
2023-03-15 09:47:14 +10:00
Peter Hutterer
e6cb6b1998 Add a pre-commit hook
Moving my local hooks into a pre-commit hook set that others can find
useful too:
- remove trailing whitespaces and newlines
- don't allow commits to the "main" branch
- python black and python ruff (same args as in the CI)
2023-03-13 08:52:08 +10:00
Peter Hutterer
8954d96227 Remove empty trailing newlines from all files 2023-03-13 08:52:08 +10:00
Peter Hutterer
940f2778a9 CI: bump to the latest ci templates
This version includes a fix for ci-fairy to handle the trailing newlines
in a more predictable manner.
2023-03-13 08:51:52 +10:00
Peter Hutterer
37f4351a67 doc/proto: add a page for the ei-scanner
In case someone is actually planning to use that one
2023-03-10 14:25:59 +10:00
Peter Hutterer
d44de4e73e doc/proto: add a link to the git repo and issues page 2023-03-09 14:49:03 +10:00
Peter Hutterer
e8765f3042 doc/proto: add a page describing the libraries
Now that the API doc is behind a link, let's make it a bit more
prominent to find.
2023-03-09 14:28:30 +10:00
Peter Hutterer
2665224461 doc/proto: mirror the required directory structure
Might as well make this easier for us locally.
2023-03-09 14:28:30 +10:00
Peter Hutterer
3bcece1923 doc/proto: remove now unused files
Obsolete since 5258a559eb:
    doc/proto: remove the embedded docs from the proto, use static pages instead
2023-03-09 13:43:43 +10:00