mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-05 03:00:35 +01:00
This protocol is wayland-like though it uses a slightly different message format. The XML file uses the same structure, except for the "fixed" type which is "float" here. The scanner uses a jinja template to generate source and header files for ei and eis which are now used instead of the protobuf-generated objects. Note that the scanner is a minimal working version, some features like enum value checks are not yet implemented. Unlike wayland we do not need to generate the libwayland-like library, we only need the wire protocol parser - some shortcuts can thus be taken. To keep the changes simple, the protocol currently is a flat protocol with only one interface and all messages copied over from the previous ei.proto file. In future commits, this will be moved to the respective interfaces instead.
230 lines
6.3 KiB
C
230 lines
6.3 KiB
C
/* SPDX-License-Identifier: MIT */
|
|
/*
|
|
* Copyright © 2020 Red Hat, Inc.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "util-macros.h"
|
|
#include "util-object.h"
|
|
|
|
#include "libei.h"
|
|
#include "brei-shared.h"
|
|
#include "util-list.h"
|
|
#include "util-sources.h"
|
|
#include "util-structs.h"
|
|
|
|
#include "libei-seat.h"
|
|
#include "libei-device.h"
|
|
#include "libei-event.h"
|
|
#include "libei-region.h"
|
|
|
|
struct ei_backend_interface {
|
|
void (*destroy)(struct ei *ei, void *backend);
|
|
};
|
|
|
|
enum ei_state {
|
|
EI_STATE_NEW, /* No backend yet */
|
|
EI_STATE_BACKEND, /* We have a backend */
|
|
EI_STATE_VERSION_QUERY, /* Waiting for server version */
|
|
EI_STATE_CONNECTING, /* client requested connect */
|
|
EI_STATE_CONNECTED, /* server has sent connect */
|
|
EI_STATE_DISCONNECTING, /* in the process of cleaning up */
|
|
EI_STATE_DISCONNECTED,
|
|
};
|
|
|
|
struct ei {
|
|
struct object object;
|
|
struct brei_object proto_object;
|
|
|
|
void *user_data;
|
|
struct sink *sink;
|
|
struct source *source;
|
|
struct ei_backend_interface backend_interface;
|
|
void *backend;
|
|
enum ei_state state;
|
|
struct list event_queue;
|
|
struct list seats;
|
|
char *name;
|
|
|
|
struct {
|
|
ei_log_handler handler;
|
|
enum ei_log_priority priority;
|
|
} log;
|
|
|
|
bool is_sender;
|
|
uint32_t server_version;
|
|
uint32_t client_version;
|
|
};
|
|
|
|
const struct ei_interface *
|
|
ei_get_interface(struct ei *ei);
|
|
|
|
int
|
|
ei_set_socket(struct ei *ei, int fd);
|
|
|
|
void
|
|
ei_disconnect(struct ei *ei);
|
|
|
|
const struct brei_object *
|
|
ei_get_proto_object(struct ei *ei);
|
|
|
|
struct ei *
|
|
ei_get_context(struct ei *ei);
|
|
|
|
int
|
|
ei_send_message(struct ei *ei, uint32_t object_id,
|
|
uint32_t opcode, const char *signature, size_t nargs, ...);
|
|
|
|
int
|
|
ei_send_seat_bind(struct ei_seat *seat, uint32_t capabilities);
|
|
|
|
int
|
|
ei_send_close_device(struct ei_device *device);
|
|
|
|
int
|
|
ei_send_start_emulating(struct ei_device *device, uint32_t sequence);
|
|
|
|
int
|
|
ei_send_stop_emulating(struct ei_device *device);
|
|
|
|
int
|
|
ei_send_frame(struct ei_device *device, uint64_t time);
|
|
|
|
void
|
|
ei_queue_device_removed_event(struct ei_device *device);
|
|
|
|
void
|
|
ei_insert_device_removed_event(struct ei_device *device);
|
|
|
|
void
|
|
ei_queue_seat_removed_event(struct ei_seat *seat);
|
|
|
|
void
|
|
ei_queue_device_start_emulating_event(struct ei_device *device, uint32_t sequence);
|
|
|
|
void
|
|
ei_queue_device_stop_emulating_event(struct ei_device *device);
|
|
|
|
void
|
|
ei_queue_frame_event(struct ei_device *device, uint64_t time);
|
|
|
|
void
|
|
ei_queue_pointer_rel_event(struct ei_device *device, double x, double y);
|
|
|
|
void
|
|
ei_queue_pointer_abs_event(struct ei_device *device, double x, double y);
|
|
|
|
void
|
|
ei_queue_pointer_button_event(struct ei_device *device, uint32_t button, bool is_press);
|
|
|
|
void
|
|
ei_queue_keyboard_key_event(struct ei_device *device, uint32_t key, bool is_press);
|
|
|
|
void
|
|
ei_queue_pointer_scroll_event(struct ei_device *device, double x, double y);
|
|
|
|
void
|
|
ei_queue_pointer_scroll_discrete_event(struct ei_device *device, int32_t x, int32_t y);
|
|
|
|
void
|
|
ei_queue_pointer_scroll_stop_event(struct ei_device *device, bool x, bool y);
|
|
|
|
void
|
|
ei_queue_pointer_scroll_cancel_event(struct ei_device *device, bool x, bool y);
|
|
|
|
void
|
|
ei_queue_touch_down_event(struct ei_device *device, uint32_t touchid,
|
|
double x, double y);
|
|
|
|
void
|
|
ei_queue_touch_motion_event(struct ei_device *device, uint32_t touchid,
|
|
double x, double y);
|
|
|
|
void
|
|
ei_queue_touch_up_event(struct ei_device *device, uint32_t touchid);
|
|
|
|
int
|
|
ei_send_pointer_rel(struct ei_device *device,
|
|
double x, double y);
|
|
|
|
int
|
|
ei_send_pointer_abs(struct ei_device *device,
|
|
double x, double y);
|
|
|
|
int
|
|
ei_send_pointer_button(struct ei_device *device,
|
|
uint32_t button, bool is_press);
|
|
|
|
int
|
|
ei_send_pointer_scroll(struct ei_device *device,
|
|
double x, double y);
|
|
int
|
|
ei_send_pointer_scroll_stop(struct ei_device *device, double x, double y);
|
|
|
|
int
|
|
ei_send_pointer_scroll_cancel(struct ei_device *device, double x, double y);
|
|
|
|
int
|
|
ei_send_pointer_scroll_discrete(struct ei_device *device,
|
|
int32_t x, int32_t y);
|
|
|
|
int
|
|
ei_send_keyboard_key(struct ei_device *device,
|
|
uint32_t key, bool is_press);
|
|
|
|
int
|
|
ei_send_touch_down(struct ei_device *device, uint32_t tid,
|
|
double x, double y);
|
|
int
|
|
ei_send_touch_motion(struct ei_device *device, uint32_t tid,
|
|
double x, double y);
|
|
int
|
|
ei_send_touch_up(struct ei_device *device, uint32_t tid);
|
|
|
|
_printf_(6, 7) void
|
|
ei_log_msg(struct ei *ei,
|
|
enum ei_log_priority priority,
|
|
const char *file, int lineno, const char *func,
|
|
const char *format, ...);
|
|
|
|
_printf_(6, 0) void
|
|
ei_log_msg_va(struct ei *ei,
|
|
enum ei_log_priority priority,
|
|
const char *file, int lineno, const char *func,
|
|
const char *format,
|
|
va_list args);
|
|
|
|
#define log_debug(T_, ...) \
|
|
ei_log_msg((T_), EI_LOG_PRIORITY_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
#define log_info(T_, ...) \
|
|
ei_log_msg((T_), EI_LOG_PRIORITY_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
#define log_warn(T_, ...) \
|
|
ei_log_msg((T_), EI_LOG_PRIORITY_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
#define log_error(T_, ...) \
|
|
ei_log_msg((T_), EI_LOG_PRIORITY_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
#define log_bug(T_, ...) \
|
|
ei_log_msg((T_), EI_LOG_PRIORITY_ERROR, __FILE__, __LINE__, __func__, "🪳 libei bug: " __VA_ARGS__)
|
|
#define log_bug_client(T_, ...) \
|
|
ei_log_msg((T_), EI_LOG_PRIORITY_ERROR, __FILE__, __LINE__, __func__, "🪲 Bug: " __VA_ARGS__)
|