Commit graph

65 commits

Author SHA1 Message Date
Peter Hutterer
5adf87cdda tools: hook up absolute pointer motion in the demo client
Prints the regions and sets the pointer to somewhere around 150/150

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-12 15:39:26 +10:00
Peter Hutterer
5747cbf8b8 eis: fix the object creation API again
It's now consistently parent_new_child().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 16:34:10 +10:00
Peter Hutterer
2ec3328447 tools: use the linux event codes now that we're including the header
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:29:56 +10:00
Peter Hutterer
3abf13742a Restructure keymap handling to server-side only
This keeps most of the current structure but gets rid of client-side
keymaps (which have been broken since the server-side devices anyway).
The new approach: clients get a keymap (or NULL) from the server, if
they don't like it they will have to do transformation on their side.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:29:55 +10:00
Peter Hutterer
3aa75890e9 eis: change the regions API to use eis_region_add()
This is slightly inconsistent with the configure API but more consistent
with the device API (which also has a new() + add()). It reduces
potential bugs though because the region cannot be added to two devices
anymore, and this way we also get a context in the region from the start
(which means we can log).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
712e37eb3b tools: fix a typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
a522808253 tools: fix keyboard cap in the EIS demo server
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
ecd75fcf40 tools: add an abs device and regions to the demo server
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-09 15:45:06 +10:00
Peter Hutterer
2bb846696f Change to use server-created devices
This changes the protocol so that it is the EIS implementation that
creates devices within a seat.

A client now "binds" to a seat and the EIS implementation creates
devices matching the requested capabilities. A client can close a device
if it no longer wants those but otherwise everything (including pointer
ranges) is handled by the server.

This is one giant patch because changes at the protocol level cannot
easily be broken out into smaller patches. Some FIXMEs are left which
will be handled in follow-up patches, e.g. the keymap handling is
basically broken right now.

Fixes #7

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:02:54 +10:00
David Redondo
27e7823029 Implement support for scroll events
The interfaces were declared on both client and server  side but not
implemented.

Signed-off-by: David Redondo <kde@david-redondo.de>
2021-07-16 08:40:07 +02:00
David Edmundson
ce755e4334 tools/demo-server: create a seat in uinput mode
The uinput path ended up diverged from the printf codepath and does not
create any seats and we can't process events.

Signed-off-by: David Edmundson <davidedmundson@kde.org>
2021-07-07 22:30:23 +01:00
Peter Hutterer
23696006f1 tools/demo-server: handle abs motion events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-11-04 12:48:24 +10:00
Peter Hutterer
51bec40aa5 tools/demo-server: split the keymap handling into two functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:36:44 +10:00
Peter Hutterer
08650b0268 tools/demo-server: set the server keymap in our local struct
Where the demo server is run with a --layout, set that in our local struct so
the printed messages use the correct keysyms.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:36:37 +10:00
Peter Hutterer
ab386f3cdb util: add an _unref_ cleanup + declaration function
To cut down on the boilerplate, an unref-able struct variable can now be
declared as
   _unref_(type) *name = NULL;
which is the equivalent of
   _cleanup_(type_unrefp) struct type *name = NULL;

Let's see how that style ends up reading.

This means we can get rid of the custom _cleanup_foo_ functions everywhere, no
need for all the extra #defines etc. A somewhat special case is systemd which
defines the various unrefp functions for us in the headers, so we can use them
directly.

OBJECT_IMPLEMENT_UNREF now also creates the unrefp function for this object -
this of course conflicts where DECLARE_UNREF_CLEANUP_FUNC is in scope. Not a
problem so far, let's see how we go.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:17:16 +10:00
Peter Hutterer
2076057ba2 util: add a macro to create unref cleanup functions
Slightly less boilerplate than before.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:47:47 +10:00
Peter Hutterer
5e24b35ecb tools: use a cleanup func for the event in the demo client
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:47:47 +10:00
Peter Hutterer
93b96e42ad Add an EIS-controlled seat to the hierarchy
After CONNECT, the EIS implementation needs to add one or more seats. The
libei client can only create devices within those seats. This mirrors the
wayland hierarchy as well as the X.Org one.

The seat has a set of allowed capabilities, so the client knows ahead of time
when it may not be possible to create a specific device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:47:47 +10:00
Peter Hutterer
faff1ed597 tools/demo-server: add --force to remove a leftover socket path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:10:16 +10:00
Peter Hutterer
7318512a89 libeis: switch the keymap to be a separate object
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-01 15:28:46 +10:00
Peter Hutterer
76d59c11c9 libei: switch the keymap to be a separate object
This fits better with the rest of the API and also fits much nicer into the
most common use-case of "device doesn't have a keymap".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-01 15:28:46 +10:00
Peter Hutterer
c72f27b4c2 eis: switch to eis_device_allow_capability()
The previous approach would implicitly allow any capability not known to the
server. Switch instead to requiring an explicit 'ok' for any capability the
server wants to support.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-17 05:29:01 +00:00
Peter Hutterer
4a918d17d8 libeis: namespace the capability-specific getters and setters
Naming scheme is now: ei_device_<capability>_get/set_<what>. So far the
range is the only one where we had to deal with the same thing for two
different capabilities and it's unlikely we'll have to have different keymaps
for different capabilities. But still, let's do this now while it's still
easy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-28 14:13:56 +10:00
Peter Hutterer
e4840d4523 libei: namespace the capability-specific configure calls
Naming scheme is now: ei_device_<capability>_configure_<what>. So far the
range is the only one where we had to deal with the same thing for two
different capabilities and it's unlikely we'll have to have different keymaps
for different capabilities. But still, let's do this now while it's still
easy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-28 14:13:53 +10:00
Peter Hutterer
3b90296237 tools/demo-server: add a uinput example handler
This is a basic example on how an EIS server can map to uinput, just to
illustrate that there's nothing in libeis that requires a display server
protocol (X or Wayland). All that's done here is we set up a keyboard and
pointer device and route the input events through that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-27 12:52:50 +10:00
Peter Hutterer
f45a23e466 tools/demo-server: abstract the event handler
Move this to handle_event function so we can swap out what actually deals with
the events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-27 11:49:20 +10:00
Peter Hutterer
5d85ea4c8f tools/demo-server: use _cleanup_foo_ functions for eis and eis_event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-27 11:49:20 +10:00
Peter Hutterer
22930d0d2b tools/demo-client, demo-server: use the new color print functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-27 11:49:20 +10:00
Peter Hutterer
6b3d9255cf libei: implement org.freedesktop.portal.EmulatedInput support
The current implementation of that portal has two methods: EmulateInput to
authenticate and Connect to get the fd to the EIS implementation. The portal
implementation is in charge of finding EIS and restricting it if need be.

This uses libsystemd because we can integrate that with epoll and our
libei_dispatch() method. GDBus requires a glib mainloop, so it's not really
suitable here. Given how simple this is anyway, it's easy to just do the DBus
bits in the caller and then hand the fd to ei_setup_backend_fd().

A eis-fake-portal is provided for testing, this "portal" can use the custom
portal bus name and connect the eis-demo-client to the eis-demo-server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 13:35:18 +10:00
Peter Hutterer
31988e056d tools/demo-client: print a server-side keymap if there was one
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
ee1935b8c5 tools/demo-server: add support for keymap overrides
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
04dab83115 tools/demo-client: make the XKB layout a commandline argument
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
901235af5c tools/demo-server: add option parsing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
55d92c8f61 tools/demo-client: hook up --verbose
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
c4f1a9107e tools: rename the socket server tool to eis-demo-server
Conveys more of it's meaning

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
c063ec023c tools/ei-demo: add hooks for choosing a backend
None exist other than the socket one but hey, the infrastructure is there.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 20:45:37 +10:00
Peter Hutterer
8cf7b3573e tools: rename the ei-socket-client to ei-demo-client
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 20:00:49 +10:00
Peter Hutterer
a01476f4af tools: don't re-add devices on removed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 19:58:39 +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
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
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
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
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
515b67c6da tools: use a cleanup function for unlinking the socket
This way we can't forget to remove the file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:17:51 +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
2e944450a0 tools: change the default socket to $XDG_RUNTIME_DIR/eis-0
This matches the future portal implementation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:17:51 +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
cb976a2f95 tools: fix a few memleaks on errors
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:12:19 +10:00