mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-09 09:50:16 +01:00
protocol: move the frame event into the device interface
This commit is contained in:
parent
3fc1bdf07a
commit
964bb76c60
7 changed files with 47 additions and 87 deletions
|
|
@ -148,12 +148,6 @@
|
|||
<arg name="touchid" type="uint"/>
|
||||
</request>
|
||||
|
||||
<request name="frame">
|
||||
<arg name="device_id" type="uint"/>
|
||||
<arg name="timestamp" type="uint"/>
|
||||
<arg name="micros" type="uint"/>
|
||||
</request>
|
||||
|
||||
<event name="connection_setup">
|
||||
<description summary="initial connection setup">
|
||||
Provides the client with an object to initialize and setup the connection.
|
||||
|
|
@ -285,11 +279,6 @@
|
|||
<arg name="touchid" type="uint"/>
|
||||
</event>
|
||||
|
||||
<event name="frame">
|
||||
<arg name="device_id" type="uint"/>
|
||||
<arg name="timestamp" type="uint"/>
|
||||
<arg name="micros" type="uint"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="ei_callback" version="1">
|
||||
|
|
@ -450,6 +439,11 @@
|
|||
<request name="stop_emulating">
|
||||
</request>
|
||||
|
||||
<request name="frame">
|
||||
<arg name="timestamp" type="uint"/>
|
||||
<arg name="micros" type="uint"/>
|
||||
</request>
|
||||
|
||||
<event name="destroyed" since="1">
|
||||
<description summary="Device removal notification">
|
||||
This device has been removed and a client should release all
|
||||
|
|
@ -532,6 +526,11 @@
|
|||
|
||||
<event name="stop_emulating">
|
||||
</event>
|
||||
|
||||
<event name="frame" since="1">
|
||||
<arg name="timestamp" type="uint"/>
|
||||
<arg name="micros" type="uint"/>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "util-macros.h"
|
||||
#include "util-mem.h"
|
||||
#include "util-io.h"
|
||||
#include "util-time.h"
|
||||
#include "util-strings.h"
|
||||
|
||||
#include "libei-private.h"
|
||||
|
|
@ -271,6 +272,16 @@ handle_msg_stop_emulating(struct ei_device *device)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
handle_msg_frame(struct ei_device *device, uint32_t time, uint32_t micros)
|
||||
{
|
||||
DISCONNECT_IF_SENDER_CONTEXT(device);
|
||||
|
||||
ei_queue_frame_event(device, ms2us(time) + micros);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct ei_device_interface interface = {
|
||||
.destroyed = handle_msg_destroy,
|
||||
.name = handle_msg_name,
|
||||
|
|
@ -284,6 +295,7 @@ static const struct ei_device_interface interface = {
|
|||
.paused = handle_msg_paused,
|
||||
.start_emulating = handle_msg_start_emulating,
|
||||
.stop_emulating = handle_msg_stop_emulating,
|
||||
.frame = handle_msg_frame,
|
||||
};
|
||||
|
||||
const struct ei_device_interface *
|
||||
|
|
@ -954,7 +966,15 @@ ei_device_frame(struct ei_device *device, uint64_t time)
|
|||
if (device->state != EI_DEVICE_STATE_EMULATING)
|
||||
return;
|
||||
|
||||
ei_send_frame(device, time);
|
||||
if (!device->send_frame_event)
|
||||
return;
|
||||
|
||||
device->send_frame_event = false;
|
||||
|
||||
int rc = ei_device_request_frame(device, us2ms(time), time % 1000);
|
||||
if (rc)
|
||||
ei_disconnect(ei_device_get_context(device));
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -114,9 +114,6 @@ ei_send_message(struct ei *ei, const struct brei_object *object,
|
|||
void
|
||||
ei_add_seat(struct ei_seat *seat);
|
||||
|
||||
int
|
||||
ei_send_frame(struct ei_device *device, uint64_t time);
|
||||
|
||||
void
|
||||
ei_queue_device_removed_event(struct ei_device *device);
|
||||
|
||||
|
|
|
|||
35
src/libei.c
35
src/libei.c
|
|
@ -650,25 +650,6 @@ handle_msg_keyboard_modifiers(struct ei_connection *connection, uint32_t devicei
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ei_send_frame(struct ei_device *device, uint64_t time)
|
||||
{
|
||||
struct ei *ei = ei_device_get_context(device);
|
||||
|
||||
if (ei->state == EI_STATE_NEW || ei->state == EI_STATE_DISCONNECTED)
|
||||
return 0;
|
||||
|
||||
if (!device->send_frame_event)
|
||||
return 0;
|
||||
|
||||
device->send_frame_event = false;
|
||||
|
||||
int rc = ei_connection_request_frame(ei->connection, device->id, us2ms(time), time % 1000);
|
||||
if (rc)
|
||||
ei_disconnect(ei);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
ei_send_pointer_rel(struct ei_device *device, double x, double y)
|
||||
{
|
||||
|
|
@ -885,21 +866,6 @@ static int handle_msg_disconnected(struct ei_connection *connection, uint32_t re
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
handle_msg_frame(struct ei_connection *connection, uint32_t deviceid, uint32_t time, uint32_t micros)
|
||||
{
|
||||
struct ei *ei = ei_connection_get_context(connection);
|
||||
|
||||
DISCONNECT_IF_SENDER_CONTEXT(ei);
|
||||
|
||||
struct ei_device *device = ei_find_device(ei, deviceid);
|
||||
|
||||
if (device)
|
||||
return ei_device_event_frame(device, ms2us(time) + micros);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
handle_msg_pointer_rel(struct ei_connection *connection, uint32_t deviceid, float x, float y)
|
||||
{
|
||||
|
|
@ -1127,7 +1093,6 @@ static const struct ei_connection_interface intf_state_connected = {
|
|||
.touch_down = handle_msg_touch_down,
|
||||
.touch_motion = handle_msg_touch_motion,
|
||||
.touch_up = handle_msg_touch_up,
|
||||
.frame = handle_msg_frame,
|
||||
};
|
||||
|
||||
static const struct ei_connection_interface *interfaces[] = {
|
||||
|
|
|
|||
|
|
@ -282,21 +282,6 @@ eis_client_setup_done(struct eis_client *client, const char *name, bool is_sende
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
client_msg_frame(struct eis_connection *connection, uint32_t deviceid, uint32_t time, uint32_t micros)
|
||||
{
|
||||
struct eis_client *client = eis_connection_get_client(connection);
|
||||
|
||||
DISCONNECT_IF_RECEIVER_CONTEXT(client);
|
||||
|
||||
struct eis_device *device = eis_client_find_device(client, deviceid);
|
||||
|
||||
if (device)
|
||||
return eis_device_event_frame(device, ms2us(time) + micros);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_pointer_rel(struct eis_connection *connection, uint32_t deviceid,
|
||||
float x, float y)
|
||||
|
|
@ -508,7 +493,6 @@ static const struct eis_connection_interface intf_state_connected = {
|
|||
.touch_down = client_msg_touch_down,
|
||||
.touch_motion = client_msg_touch_motion,
|
||||
.touch_up = client_msg_touch_up,
|
||||
.frame = client_msg_frame,
|
||||
};
|
||||
|
||||
static const struct eis_connection_interface *interfaces[] = {
|
||||
|
|
|
|||
|
|
@ -254,10 +254,25 @@ client_msg_stop_emulating(struct eis_device *device)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_frame(struct eis_device *device, uint32_t time, uint32_t micros)
|
||||
{
|
||||
DISCONNECT_IF_RECEIVER_CONTEXT(device);
|
||||
|
||||
if (device->state != EIS_DEVICE_STATE_EMULATING)
|
||||
return -EINVAL;
|
||||
|
||||
eis_queue_frame_event(device, ms2us(time) + micros);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const struct eis_device_interface interface = {
|
||||
.release = client_msg_release,
|
||||
.start_emulating = client_msg_start_emulating,
|
||||
.stop_emulating = client_msg_stop_emulating,
|
||||
.frame = client_msg_frame,
|
||||
};
|
||||
|
||||
const struct eis_device_interface *
|
||||
|
|
@ -799,19 +814,7 @@ eis_device_frame(struct eis_device *device, uint64_t time)
|
|||
|
||||
device->send_frame_event = false;
|
||||
|
||||
|
||||
handle_request(device, frame, us2ms(time), time % 1000);
|
||||
}
|
||||
|
||||
int
|
||||
eis_device_event_frame(struct eis_device *device, uint64_t time)
|
||||
{
|
||||
if (device->state != EIS_DEVICE_STATE_EMULATING)
|
||||
return -EINVAL;
|
||||
|
||||
eis_queue_frame_event(device, time);
|
||||
|
||||
return 0;
|
||||
eis_device_event_frame(device, us2ms(time), time % 1000);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -110,8 +110,6 @@ void
|
|||
eis_device_set_client_keymap(struct eis_device *device,
|
||||
enum eis_keymap_type type,
|
||||
int keymap_fd, size_t size);
|
||||
int
|
||||
eis_device_event_frame(struct eis_device *device, uint64_t time);
|
||||
|
||||
int
|
||||
eis_device_event_pointer_rel(struct eis_device *device,
|
||||
|
|
@ -152,12 +150,6 @@ eis_device_event_touch_motion(struct eis_device *device, uint32_t touchid,
|
|||
int
|
||||
eis_device_event_touch_up(struct eis_device *device, uint32_t touchid);
|
||||
|
||||
void
|
||||
eis_device_handle_event_start_emulating(struct eis_device *device, uint32_t sequence);
|
||||
|
||||
void
|
||||
eis_device_handle_event_stop_emulating(struct eis_device *device);
|
||||
|
||||
void
|
||||
eis_device_closed_by_client(struct eis_device *device);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue