mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 06:38:02 +02:00
proto: group the client messages vs events
This is just for easier readability and extensibility. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
56187e1543
commit
e3ed2c4ee6
5 changed files with 76 additions and 66 deletions
|
|
@ -163,28 +163,31 @@ message Property {
|
|||
|
||||
message ClientMessage {
|
||||
oneof msg {
|
||||
/* Client setup and configuration */
|
||||
Connect connect = 1;
|
||||
ConnectDone connect_done = 2;
|
||||
Disconnect disconnect = 3;
|
||||
BindSeat bind_seat = 4;
|
||||
UnbindSeat unbind_seat = 5;
|
||||
CloseDevice close_device = 6;
|
||||
PointerRelative pointer_relative = 7;
|
||||
PointerAbsolute pointer_absolute = 8;
|
||||
PointerScroll pointer_scroll = 9;
|
||||
PointerScrollDiscrete pointer_scroll_discrete = 10;
|
||||
PointerScrollStop pointer_scroll_stop = 11;
|
||||
PointerButton pointer_button = 12;
|
||||
KeyboardKey keyboard_key = 13;
|
||||
TouchDown touch_down = 14;
|
||||
TouchMotion touch_motion = 15;
|
||||
TouchUp touch_up = 16;
|
||||
ConfigureName configure_name = 17;
|
||||
ConfigureCapabilities configure_capabilities = 18;
|
||||
Frame frame = 19;
|
||||
ConfigureName configure_name = 7;
|
||||
ConfigureCapabilities configure_capabilities = 8;
|
||||
Property property = 9;
|
||||
|
||||
/* Events */
|
||||
StartEmulating start_emulating = 20;
|
||||
StopEmulating stop_emulating = 21;
|
||||
Property property = 22;
|
||||
PointerRelative pointer_relative = 22;
|
||||
PointerAbsolute pointer_absolute = 23;
|
||||
PointerScroll pointer_scroll = 24;
|
||||
PointerScrollDiscrete pointer_scroll_discrete = 25;
|
||||
PointerScrollStop pointer_scroll_stop = 26;
|
||||
PointerButton pointer_button = 27;
|
||||
KeyboardKey keyboard_key = 28;
|
||||
TouchDown touch_down = 29;
|
||||
TouchMotion touch_motion = 30;
|
||||
TouchUp touch_up = 31;
|
||||
Frame frame = 32;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,6 +163,10 @@ log_wire_message(struct ei *ei, const ClientMessage *msg, int error)
|
|||
MSG_STRING_CASE(BIND_SEAT);
|
||||
MSG_STRING_CASE(UNBIND_SEAT);
|
||||
MSG_STRING_CASE(CLOSE_DEVICE);
|
||||
MSG_STRING_CASE(CONFIGURE_NAME);
|
||||
MSG_STRING_CASE(CONFIGURE_CAPABILITIES);
|
||||
MSG_STRING_CASE(PROPERTY);
|
||||
/* events */
|
||||
MSG_STRING_CASE(START_EMULATING);
|
||||
MSG_STRING_CASE(STOP_EMULATING);
|
||||
MSG_STRING_CASE(POINTER_RELATIVE);
|
||||
|
|
@ -175,10 +179,7 @@ log_wire_message(struct ei *ei, const ClientMessage *msg, int error)
|
|||
MSG_STRING_CASE(TOUCH_DOWN);
|
||||
MSG_STRING_CASE(TOUCH_MOTION);
|
||||
MSG_STRING_CASE(TOUCH_UP);
|
||||
MSG_STRING_CASE(CONFIGURE_NAME);
|
||||
MSG_STRING_CASE(CONFIGURE_CAPABILITIES);
|
||||
MSG_STRING_CASE(FRAME);
|
||||
MSG_STRING_CASE(PROPERTY);
|
||||
}
|
||||
if (message == NULL)
|
||||
assert(!"Unimplemented message type");
|
||||
|
|
@ -473,7 +474,10 @@ static const struct ei_proto_requests requests = {
|
|||
.disconnect = ei_proto_send_disconnect,
|
||||
.bind_seat = ei_proto_send_bind_seat,
|
||||
.unbind_seat = ei_proto_send_unbind_seat,
|
||||
.property = ei_proto_send_property,
|
||||
.close_device = ei_proto_send_close_device,
|
||||
|
||||
/* events */
|
||||
.start_emulating = ei_proto_send_start_emulating,
|
||||
.stop_emulating = ei_proto_send_stop_emulating,
|
||||
.rel = ei_proto_send_rel,
|
||||
|
|
@ -488,7 +492,6 @@ static const struct ei_proto_requests requests = {
|
|||
.touch_motion = ei_proto_send_touch_motion,
|
||||
.touch_up = ei_proto_send_touch_up,
|
||||
.frame = ei_proto_send_frame,
|
||||
.property = ei_proto_send_property,
|
||||
};
|
||||
|
||||
const struct ei_proto_requests *
|
||||
|
|
|
|||
|
|
@ -223,6 +223,36 @@ client_msg_close_device(struct eis_client *client, uint32_t deviceid)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_bind_seat(struct eis_client *client, uint32_t seatid, uint32_t caps)
|
||||
{
|
||||
struct eis_seat *seat;
|
||||
|
||||
list_for_each(seat, &client->seats, link) {
|
||||
if (seat->id == seatid) {
|
||||
eis_seat_bind(seat, caps);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_unbind_seat(struct eis_client *client, uint32_t seatid)
|
||||
{
|
||||
struct eis_seat *seat;
|
||||
|
||||
list_for_each(seat, &client->seats, link) {
|
||||
if (seat->id == seatid) {
|
||||
eis_seat_unbind(seat);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_start_emulating(struct eis_client *client, uint32_t deviceid)
|
||||
{
|
||||
|
|
@ -259,35 +289,6 @@ client_msg_stop_emulating(struct eis_client *client, uint32_t deviceid)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_bind_seat(struct eis_client *client, uint32_t seatid, uint32_t caps)
|
||||
{
|
||||
struct eis_seat *seat;
|
||||
|
||||
list_for_each(seat, &client->seats, link) {
|
||||
if (seat->id == seatid) {
|
||||
eis_seat_bind(seat, caps);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_unbind_seat(struct eis_client *client, uint32_t seatid)
|
||||
{
|
||||
struct eis_seat *seat;
|
||||
|
||||
list_for_each(seat, &client->seats, link) {
|
||||
if (seat->id == seatid) {
|
||||
eis_seat_unbind(seat);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
client_msg_frame(struct eis_client *client, uint32_t deviceid)
|
||||
|
|
@ -582,6 +583,9 @@ static const struct eis_proto_interface intf_state_connected = {
|
|||
.bind_seat = client_msg_bind_seat,
|
||||
.unbind_seat = client_msg_unbind_seat,
|
||||
.close_device = client_msg_close_device,
|
||||
.configure_name = client_msg_configure_name,
|
||||
.configure_capabilities = client_msg_configure_capabilities,
|
||||
/* events */
|
||||
.start_emulating = client_msg_start_emulating,
|
||||
.stop_emulating = client_msg_stop_emulating,
|
||||
.rel = client_msg_pointer_rel,
|
||||
|
|
@ -594,8 +598,6 @@ static const struct eis_proto_interface intf_state_connected = {
|
|||
.touch_down = client_msg_touch_down,
|
||||
.touch_motion = client_msg_touch_motion,
|
||||
.touch_up = client_msg_touch_up,
|
||||
.configure_name = client_msg_configure_name,
|
||||
.configure_capabilities = client_msg_configure_capabilities,
|
||||
.frame = client_msg_frame,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -338,6 +338,20 @@ eis_proto_handle_message(struct eis_client *client,
|
|||
rc = call(close_device, client,
|
||||
proto->close_device->deviceid);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_CONFIGURE_NAME:
|
||||
rc = call(configure_name, client,
|
||||
proto->configure_name->name);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_CONFIGURE_CAPABILITIES:
|
||||
rc = call(configure_capabilities, client,
|
||||
proto->configure_capabilities->allowed_capabilities);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_PROPERTY:
|
||||
rc = call(property, client, proto->property->name,
|
||||
proto->property->value[0] ? proto->property->value : NULL,
|
||||
proto->property->permissions);
|
||||
break;
|
||||
/* Events */
|
||||
case CLIENT_MESSAGE__MSG_START_EMULATING:
|
||||
rc = call(start_emulating, client,
|
||||
proto->start_emulating->deviceid);
|
||||
|
|
@ -408,22 +422,9 @@ eis_proto_handle_message(struct eis_client *client,
|
|||
proto->touch_up->deviceid,
|
||||
proto->touch_up->touchid);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_CONFIGURE_NAME:
|
||||
rc = call(configure_name, client,
|
||||
proto->configure_name->name);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_CONFIGURE_CAPABILITIES:
|
||||
rc = call(configure_capabilities, client,
|
||||
proto->configure_capabilities->allowed_capabilities);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_FRAME:
|
||||
rc = call(frame, client, proto->frame->deviceid);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_PROPERTY:
|
||||
rc = call(property, client, proto->property->name,
|
||||
proto->property->value[0] ? proto->property->value : NULL,
|
||||
proto->property->permissions);
|
||||
break;
|
||||
default:
|
||||
rc = -EBADMSG;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@ struct eis_proto_interface {
|
|||
int (*bind_seat)(struct eis_client *client, uint32_t seatid, uint32_t capabilities);
|
||||
int (*unbind_seat)(struct eis_client *client, uint32_t seatid);
|
||||
int (*close_device)(struct eis_client *client, uint32_t deviceid);
|
||||
int (*configure_name)(struct eis_client *client, const char *name);
|
||||
int (*configure_capabilities)(struct eis_client *client, uint32_t allow);
|
||||
int (*property)(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions);
|
||||
/* events */
|
||||
int (*start_emulating)(struct eis_client *client, uint32_t deviceid);
|
||||
int (*stop_emulating)(struct eis_client *client, uint32_t deviceid);
|
||||
int (*rel)(struct eis_client *client, uint32_t deviceid, double x, double y);
|
||||
|
|
@ -55,11 +60,7 @@ struct eis_proto_interface {
|
|||
int (*touch_motion)(struct eis_client *client, uint32_t deviceid,
|
||||
uint32_t tid, double x, double y);
|
||||
int (*touch_up)(struct eis_client *client, uint32_t deviceid, uint32_t tid);
|
||||
int (*configure_name)(struct eis_client *client, const char *name);
|
||||
int (*configure_capabilities)(struct eis_client *client, uint32_t allow);
|
||||
int (*frame) (struct eis_client *client, uint32_t deviceid);
|
||||
int (*property)(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions);
|
||||
};
|
||||
|
||||
struct eis_proto_requests {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue