2020-07-29 11:53:03 +10:00
|
|
|
/*
|
|
|
|
|
* 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 "util-object.h"
|
|
|
|
|
|
|
|
|
|
#include "libei.h"
|
|
|
|
|
#include "util-list.h"
|
|
|
|
|
#include "util-sources.h"
|
|
|
|
|
|
2020-08-05 16:09:27 +10:00
|
|
|
struct ei_backend_interface {
|
|
|
|
|
void (*destroy)(struct ei *ei, void *backend);
|
2020-07-29 11:53:03 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ei_state {
|
|
|
|
|
EI_STATE_NEW, /* just connected, server sent hello */
|
|
|
|
|
EI_STATE_CONNECTING, /* client requested connect */
|
|
|
|
|
EI_STATE_CONNECTED, /* server has sent connect */
|
|
|
|
|
EI_STATE_DISCONNECTED,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ei {
|
|
|
|
|
struct object object;
|
|
|
|
|
void *user_data;
|
|
|
|
|
struct logger *logger;
|
|
|
|
|
struct sink *sink;
|
|
|
|
|
struct source *source;
|
2020-08-05 16:09:27 +10:00
|
|
|
struct ei_backend_interface backend_interface;
|
|
|
|
|
void *backend;
|
2020-07-29 11:53:03 +10:00
|
|
|
enum ei_state state;
|
|
|
|
|
struct list event_queue;
|
|
|
|
|
struct list devices;
|
2020-07-30 09:40:16 +10:00
|
|
|
char *name;
|
2020-07-29 11:53:03 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ei_device_state {
|
|
|
|
|
EI_DEVICE_STATE_NEW,
|
2020-08-04 11:08:50 +10:00
|
|
|
EI_DEVICE_STATE_CONNECTING,
|
2020-07-29 11:53:03 +10:00
|
|
|
EI_DEVICE_STATE_ACCEPTED,
|
|
|
|
|
EI_DEVICE_STATE_REMOVED,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ei_device {
|
|
|
|
|
struct object object;
|
|
|
|
|
struct list link;
|
|
|
|
|
uint32_t id;
|
|
|
|
|
enum ei_device_state state;
|
|
|
|
|
uint32_t capabilities;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ei_event {
|
|
|
|
|
struct object object;
|
|
|
|
|
enum ei_event_type type;
|
|
|
|
|
struct list link;
|
|
|
|
|
struct ei_client *client;
|
|
|
|
|
struct ei_device *device;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ei_event_client {
|
|
|
|
|
struct ei_event base;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ei_init_object(struct ei *ei, struct object *parent);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ei_init(struct ei *ei);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ei_set_connection(struct ei *ei, int fd);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ei_add_device(struct ei_device *device);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ei_remove_device(struct ei_device *device);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ei_pointer_rel(struct ei_device *device,
|
|
|
|
|
int32_t x, int32_t y);
|
|
|
|
|
|
2020-08-03 12:00:31 +10:00
|
|
|
int
|
|
|
|
|
ei_pointer_button(struct ei_device *device,
|
|
|
|
|
uint32_t button, bool is_press);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ei_keyboard_key(struct ei_device *device,
|
|
|
|
|
uint32_t key, bool is_press);
|
|
|
|
|
|
2020-07-29 11:53:03 +10:00
|
|
|
void
|
|
|
|
|
ei_device_accepted(struct ei_device *device);
|