mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-18 02:50:38 +02:00
This is the minimum framework to support new clients, added devices and pointer relative motion events. It's missing a bunch of checks and verification, most of the server hooks aren't there yet, the only implementation is a UNIX socket and the protocol is plain text (but at least the last two makes it netcat-compatible). Protocol is plain text for now and interaction is like this (S is server, C is client): S: hello C: connect myclientname S: connected C: add 2 4 S: accept 2 C: rel 2 -1 1 C: rel 2 5 4 Where the last two lines are: add device with id 2 and capability mask 0x4, send a relative pointer motion event for device 2 with coordinates -1/1, then 5/4. The implementation relies heavily on some abstraction and macros galore, see the various util-* files. These are largely copied from libinput, with a few parts removed and a few other parts added. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
87 lines
2.5 KiB
C
87 lines
2.5 KiB
C
/*
|
|
* 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 "config.h"
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "util-macros.h"
|
|
|
|
struct logger;
|
|
|
|
enum logger_priority {
|
|
LOGGER_DEBUG = 20,
|
|
LOGGER_INFO = 30,
|
|
LOGGER_WARN = 40,
|
|
LOGGER_ERROR = 50,
|
|
};
|
|
|
|
typedef void (*logger_log_func_t)(struct logger *libinput,
|
|
enum logger_priority priority,
|
|
const char *format, va_list args);
|
|
|
|
void
|
|
log_msg(struct logger *logger,
|
|
enum logger_priority priority,
|
|
const char *format, ...);
|
|
|
|
void
|
|
log_msg_va(struct logger *logger,
|
|
enum logger_priority priority,
|
|
const char *format,
|
|
va_list args);
|
|
|
|
/* log helpers. The struct T_ needs to have a field called 'logger' */
|
|
#define log_debug(T_, ...) \
|
|
log_msg((T_)->logger, LOGGER_DEBUG, __VA_ARGS__)
|
|
#define log_info(T_, ...) \
|
|
log_msg((T_)->logger, LOGGER_INFO, __VA_ARGS__)
|
|
#define log_warn(T_, ...) \
|
|
log_msg((T_)->logger, LOGGER_WARN, __VA_ARGS__)
|
|
#define log_error(T_, ...) \
|
|
log_msg((T_)->logger, LOGGER_ERROR, __VA_ARGS__)
|
|
|
|
struct logger *
|
|
logger_new(void *user_data);
|
|
|
|
struct logger *
|
|
logger_unref(struct logger *logger);
|
|
|
|
void *
|
|
logger_get_user_data(struct logger *logger);
|
|
void
|
|
logger_set_user_data(struct logger *logger,
|
|
void *user_data);
|
|
|
|
enum logger_priority
|
|
logger_get_priority(struct logger *logger);
|
|
|
|
void
|
|
logger_set_priority(struct logger *logger,
|
|
enum logger_priority priority);
|
|
|
|
void
|
|
logger_set_handler(struct logger *logger,
|
|
logger_log_func_t handler);
|