Commit graph

469 commits

Author SHA1 Message Date
Peter Hutterer
403e40597d Replace remaining errno-based errors to proper brei_results 2023-03-03 11:27:01 +10:00
Peter Hutterer
a6565fd86b brei: change the various errors to PROTOCOL 2023-03-03 11:27:01 +10:00
Peter Hutterer
cc7a8cb95e ei: make more ei_queue* functions semi-public for consistency
And drop the ei_add_seat() indirection.
2023-03-03 11:27:01 +10:00
Peter Hutterer
03d7f96ddd eis: remove some indirection from the device event handling
Now that we only have one nice hook as entry point for those events,
let's move (and harden) the code there.
2023-03-03 11:26:51 +10:00
Peter Hutterer
876e4044ab eis: error out if we're in the wrong state to start/stop emulating 2023-03-03 11:22:09 +10:00
Peter Hutterer
83b4902d9f ei: error out if we're in the wrong device state for emulating 2023-03-03 11:22:09 +10:00
Peter Hutterer
d698ed2f75 ei: remove some indirection from device events
Now that we only have one nice hook as entry point for those events,
let's move (and harden) the code there.
2023-03-03 11:22:09 +10:00
Peter Hutterer
1846223991 eis: add eis_client_disconnect_with_reason
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-03-03 11:22:09 +10:00
Peter Hutterer
8a2dd03a3f ei: reject a device with capabilities unknown to us
Untested because we cannot really trigger this code path with libeis.
2023-03-03 11:22:09 +10:00
Peter Hutterer
1a21c4854b ei: better protocol checking for invalid messages 2023-03-03 11:22:09 +10:00
Peter Hutterer
dd5bc6b6e7 proto: add a bunch of error reasons for debugging 2023-03-03 11:22:09 +10:00
Peter Hutterer
55a12f5cae Remove unused macro 2023-03-03 11:22:09 +10:00
Peter Hutterer
e67a0a7777 brei: add the brei_result object and bubble it up as error case
Add a new simple object "brei_result" that maps to the protocol-type
reason + explanation. That object is now returned instead of the errno,
giving us better debugging options.

This changes the dispatcher functions from returning an int to returning
a brei_result instead (default NULL for success). A helper function for
converting a neg errno to a result is provided for convenience for now,
eventually all these paths should deal with things correctly.
2023-03-03 11:22:08 +10:00
Peter Hutterer
579f0d07d2 Add a brei-proto.h generated header file
This will be needed to have access to the various disconnect reasons in
brei-shared.c.
2023-03-03 11:21:26 +10:00
Peter Hutterer
5631b54b96 eis: pass the disconnect reason around when disconnecting a client
No real functional changes right now, but allows for future multiple errors
2023-03-03 11:21:26 +10:00
Peter Hutterer
e07d4638d5 scanner: drop the Argument.argtype in favour of DBus-type bindings
This was a brei-specifc implementation detail that is not really needed,
we can use the single-character dbus-style bindings.
2023-03-03 11:21:26 +10:00
Peter Hutterer
1bc7e2ad05 eis: send out the ei_callback interface version after setup.Done
This is currently the only interface that requires client-created
objects, so the client needs to know which version it can use. Let's
send it to them before the connection object.
2023-03-03 11:21:26 +10:00
Peter Hutterer
03bc5a1d6d ei: handle server-sent interface versions correctly
When we receive a ei_connection_setup.interface_version event, update
the supported version number for that interface to the correct minimum.
2023-03-03 11:21:26 +10:00
Peter Hutterer
027f85e195 proto: switch connection_setup.version to mirror interface_version requests
For most interfaces, the client announcing its supported version is
sufficient - the objects are all created server-side. For some
interfaces (ei_connection_setup and ei_callback right now) the client
needs to know the server-supported version.

So let's switch the current ei_connection_setup.version event (used to
negotiate ei_connection_setup's version) to a generic
`interface_version` event. This way our EIS implementation can
eventually send a version for ei_callback as well.
2023-03-03 11:21:26 +10:00
Peter Hutterer
0dba8769d4 ei: remove unused server_version and client_version fields 2023-03-03 11:21:26 +10:00
Peter Hutterer
273eda39ca Move the C proto templates to the src directory
These are very specific to libei/libeis, so let's not leave them
somewhere where they look like official bindings or something.
2023-03-03 11:21:26 +10:00
Peter Hutterer
e0d0c1af61 eis: require ei_seat and ei_devices
A client that skips on announcing those will get connected and
immediately disconnected again. There's no point to libei if you support
neither of those (at least for now).
2023-03-03 11:21:26 +10:00
Peter Hutterer
86dced2c40 eis: make ei_connection/callback/pingpong required interfaces
v1 of ei_connection requires callback and pingpong, so let's make all
three required and disconnect a client that doesn't support those.
2023-03-03 11:21:26 +10:00
Peter Hutterer
a80b19bb2c eis: immediately disconnect a client without the ei_connection interface
No point going through the setup here, just disconnect immediately.
2023-03-03 11:21:26 +10:00
Peter Hutterer
619b83220d eis: drop the device->id now that it's all protocol-wrapped 2023-03-03 11:21:26 +10:00
Peter Hutterer
6ed610e30e Split the ping/pong request into its own interface
Leave the ei_callback as-is and instead add ei_pingpong for the same
thing initiated by the server. The interface is otherwise identical but
for the direction it is supposed to flow.

This reduces the possibility of a client accidentally sending a
request when it is supposed to handle an event or vice versa.
2023-03-03 11:21:26 +10:00
Peter Hutterer
f41cc91599 proto: add a ping/pong request
This is effectively the same as connection.sync, but goes the other way.
This adds the ei_callback.done request.

In libeis this is (currently) enforced immediately after sending the
connection object. Not required there and makes the code a bit messier
but this way we can ensure that any client library handles that part of
the code.
2023-03-03 11:21:26 +10:00
Peter Hutterer
e84ddd1471 eis: drop the seat when the client requests it 2023-03-03 11:21:26 +10:00
Peter Hutterer
b481eff34c eis: only allow the available caps to bind to a seat
A client binding with caps >= the seat's current version will get
disconnected now.
2023-03-03 11:21:26 +10:00
Peter Hutterer
8c85b8fc1f protocol: add ei_connection.invalid_object
This event is to notify the client that an object used in a request was
unknown. This allows the client to work around race conditions like
binding to a seat that was removed.

This is currently the server-side only which is probably enough for now.
The only client-side created objects we have are the callbacks.
2023-03-03 11:21:26 +10:00
Peter Hutterer
cfbb906358 protocol: rename type to context_type
type is a reserved keyword in many languages, let's not make this harder
to use than necessary
2023-03-03 11:21:26 +10:00
Peter Hutterer
bf77479c6a protocol: rename the interface request to interface_version
More descriptive this way
2023-03-03 11:21:26 +10:00
Peter Hutterer
2e4d984819 eis: don't send seat events unless the client supports ei_seat 2023-03-03 11:21:26 +10:00
Peter Hutterer
58b430039a eis: destroy the eis_connection immediately after sending disconnect
Requests the client sent on the connection after disconnect
will thus be ignored.
2023-03-03 11:21:26 +10:00
Peter Hutterer
bde838fd1d protocol: rename the touch capability to touchscreen
This matches the interface name now, even though the public API right
now still uses TOUCH
2023-03-03 11:21:26 +10:00
Peter Hutterer
da51bc095f brei: add a brei context object
Having debugging in the brei code is useful, the only way we can do this
is by passing the log handler down.
2023-03-03 11:21:26 +10:00
Peter Hutterer
8d2da0d857 brei: remove some obsolete functions 2023-03-03 11:21:26 +10:00
Peter Hutterer
df673b140d ei: remove now-unused function 2023-03-03 11:21:26 +10:00
Peter Hutterer
0a347f433f protocol: make the connection setup the zero object with a proper handover
This changes the initial connection negotiation to have the
ei_connection_setup as the pre-existing object id 0. Once the client has
sent all the data to set up the connection, the EIS implementation
replies with a new object ID that is the ei_connection protocol object,
i.e. the main object.

This allows for version negotiation of our main protocol object.
2023-03-03 11:21:26 +10:00
Peter Hutterer
23433d3aff protocol: move the keymap into the keyboard interface 2023-03-03 11:21:26 +10:00
Peter Hutterer
4d9ca1796d protocol: move pointer/keyboard/touch into separate interfaces
This allows us to have a device support multiple interfaces and evolve
those interfaces individually, e.g. add things to the keyboard interface
without having to bump the touchscreen interface.

Note that due to a name clash with the existing struct ei_touch public
API the protocol interface is named touchscreen.
2023-03-03 11:21:26 +10:00
Peter Hutterer
e2a45dad38 eis: switch to a goto out approach
Makes the code a bit easier to follow
2023-03-03 11:21:26 +10:00
Peter Hutterer
964bb76c60 protocol: move the frame event into the device interface 2023-03-03 11:21:26 +10:00
Peter Hutterer
3fc1bdf07a protocol: move start/stop emulating into the device 2023-03-03 11:21:26 +10:00
Peter Hutterer
fadc1853c9 protocol: add the ei_device interface
Sitting nested below the ei_seat, the client gets a notification for a
device through the ei_seat.device event.
2023-03-03 11:21:26 +10:00
Peter Hutterer
01a2ff2d72 brei: pass the proto object through to send_message
Makes for easier debugging since we can print names instead of just
ids/opcodes.
2023-03-03 11:21:26 +10:00
Peter Hutterer
2a8661f7ad protocol: move the seat bind to the seat object
Needs documentation but we can do this when we're done with everything.
2023-03-03 11:21:26 +10:00
Peter Hutterer
c98a9fc7d7 eis: update libeis-client to use the declare macros 2023-03-03 11:21:24 +10:00
Peter Hutterer
bcece3d3c1 eis: make sure our connection setup has the right version too 2023-03-03 11:20:42 +10:00
Peter Hutterer
aaf72f9263 protocol: add a seat interface
Incomplete, only supports the initial seat setup but binding to a seat
is still outside this interface.
2023-03-03 11:20:42 +10:00