mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 12:28:02 +02:00
Improve naming for the DeviceAdded message
DeviceAdded is more self-explanatory than just "Added" Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
325622ed7c
commit
b547fdc529
3 changed files with 44 additions and 44 deletions
|
|
@ -16,8 +16,8 @@ syntax = "proto3";
|
|||
* 2.a - server replies with "Connected" or
|
||||
* 2.b - server replies with "Disconnected" and closes its end of the socket
|
||||
* 3. - client sends "AddDevice"
|
||||
* 3.a - server replies with "Added" or
|
||||
* 3.b - server replies with "Removed"
|
||||
* 3.a - server replies with "DeviceAdded" or
|
||||
* 3.b - server replies with "DeviceRemoved"
|
||||
* 4. - client sends "PointerRelative" or any other event
|
||||
* 5. - client sends "RemoveDevice"
|
||||
* 6. - client sends "Disconnect" and closes its end of the socket
|
||||
|
|
@ -110,8 +110,8 @@ message ClientMessage {
|
|||
oneof msg {
|
||||
Connect connect = 1;
|
||||
Disconnect disconnect = 2;
|
||||
AddDevice add = 3;
|
||||
RemoveDevice remove = 4;
|
||||
AddDevice add_device = 3;
|
||||
RemoveDevice remove_device = 4;
|
||||
PointerRelative rel = 5;
|
||||
PointerButton button = 6;
|
||||
KeyboardKey key = 7;
|
||||
|
|
@ -126,12 +126,12 @@ message Connected {
|
|||
message Disconnected {
|
||||
}
|
||||
|
||||
message Added {
|
||||
message DeviceAdded {
|
||||
uint32 deviceid = 1;
|
||||
uint32 capabilities = 2;
|
||||
}
|
||||
|
||||
message Removed {
|
||||
message DeviceRemoved {
|
||||
uint32 deviceid = 1;
|
||||
}
|
||||
|
||||
|
|
@ -139,8 +139,8 @@ message ServerMessage {
|
|||
oneof msg {
|
||||
Connected connected = 2;
|
||||
Disconnected disconnected = 3;
|
||||
Added added = 4;
|
||||
Removed removed = 5;
|
||||
DeviceAdded device_added = 4;
|
||||
DeviceRemoved device_removed = 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
40
src/libei.c
40
src/libei.c
|
|
@ -44,8 +44,8 @@
|
|||
enum message_type {
|
||||
MESSAGE_CONNECTED = 1,
|
||||
MESSAGE_DISCONNECTED,
|
||||
MESSAGE_ADDED,
|
||||
MESSAGE_REMOVED,
|
||||
MESSAGE_DEVICE_ADDED,
|
||||
MESSAGE_DEVICE_REMOVED,
|
||||
};
|
||||
|
||||
struct message {
|
||||
|
|
@ -57,11 +57,11 @@ struct message {
|
|||
struct message_disconnected {
|
||||
uint8_t pad; /* no data */
|
||||
} disconnected;
|
||||
struct message_added {
|
||||
struct MESSAGE_DEVICE_ADDED {
|
||||
uint32_t deviceid;
|
||||
uint32_t capabilities;
|
||||
} added;
|
||||
struct message_removed {
|
||||
struct MESSAGE_DEVICE_REMOVED {
|
||||
uint32_t deviceid;
|
||||
} removed;
|
||||
};
|
||||
|
|
@ -290,8 +290,8 @@ connection_send_add(struct ei *ei, struct ei_device *device)
|
|||
add.deviceid = device->id;
|
||||
add.capabilities = device->capabilities;
|
||||
|
||||
msg.add = &add;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_ADD;
|
||||
msg.add_device = &add;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_ADD_DEVICE;
|
||||
|
||||
return connection_send_msg(ei, &msg);
|
||||
}
|
||||
|
|
@ -310,8 +310,8 @@ connection_send_remove(struct ei *ei, struct ei_device *device)
|
|||
|
||||
remove.deviceid = device->id;
|
||||
|
||||
msg.remove = &remove;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_REMOVE;
|
||||
msg.remove_device = &remove;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_REMOVE_DEVICE;
|
||||
|
||||
return connection_send_msg(ei, &msg);
|
||||
}
|
||||
|
|
@ -579,21 +579,21 @@ connection_parse_message(const char *data, size_t *len)
|
|||
.type = MESSAGE_DISCONNECTED,
|
||||
};
|
||||
break;
|
||||
case SERVER_MESSAGE__MSG_ADDED:
|
||||
case SERVER_MESSAGE__MSG_DEVICE_ADDED:
|
||||
{
|
||||
Added *a = proto->added;
|
||||
DeviceAdded *a = proto->device_added;
|
||||
*msg = (struct message) {
|
||||
.type = MESSAGE_ADDED,
|
||||
.type = MESSAGE_DEVICE_ADDED,
|
||||
.added.deviceid = a->deviceid,
|
||||
.added.capabilities = a->capabilities,
|
||||
};
|
||||
}
|
||||
break;
|
||||
case SERVER_MESSAGE__MSG_REMOVED:
|
||||
case SERVER_MESSAGE__MSG_DEVICE_REMOVED:
|
||||
{
|
||||
Removed *r = proto->removed;
|
||||
DeviceRemoved *r = proto->device_removed;
|
||||
*msg = (struct message) {
|
||||
.type = MESSAGE_REMOVED,
|
||||
.type = MESSAGE_DEVICE_REMOVED,
|
||||
.removed.deviceid = r->deviceid,
|
||||
};
|
||||
}
|
||||
|
|
@ -616,8 +616,8 @@ connection_new_handle_msg(struct ei *ei, struct message *msg)
|
|||
switch (msg->type) {
|
||||
case MESSAGE_CONNECTED:
|
||||
case MESSAGE_DISCONNECTED:
|
||||
case MESSAGE_ADDED:
|
||||
case MESSAGE_REMOVED:
|
||||
case MESSAGE_DEVICE_ADDED:
|
||||
case MESSAGE_DEVICE_REMOVED:
|
||||
rc = -EPROTO;
|
||||
break;
|
||||
}
|
||||
|
|
@ -638,8 +638,8 @@ connection_connecting_handle_msg(struct ei *ei, struct message *msg)
|
|||
case MESSAGE_DISCONNECTED:
|
||||
rc = -ECANCELED;
|
||||
break;
|
||||
case MESSAGE_ADDED:
|
||||
case MESSAGE_REMOVED:
|
||||
case MESSAGE_DEVICE_ADDED:
|
||||
case MESSAGE_DEVICE_REMOVED:
|
||||
rc = -EPROTO;
|
||||
break;
|
||||
}
|
||||
|
|
@ -659,10 +659,10 @@ connection_connected_handle_msg(struct ei *ei, struct message *msg)
|
|||
case MESSAGE_DISCONNECTED:
|
||||
rc = -ECANCELED;
|
||||
break;
|
||||
case MESSAGE_ADDED:
|
||||
case MESSAGE_DEVICE_ADDED:
|
||||
rc = ei_added(ei, msg->added.deviceid, msg->added.capabilities);
|
||||
break;
|
||||
case MESSAGE_REMOVED:
|
||||
case MESSAGE_DEVICE_REMOVED:
|
||||
rc = ei_removed(ei, msg->removed.deviceid);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,8 +156,8 @@ log_wire_message(struct eis *eis, const ServerMessage *msg)
|
|||
abort();
|
||||
MSG_STRING_CASE(CONNECTED);
|
||||
MSG_STRING_CASE(DISCONNECTED);
|
||||
MSG_STRING_CASE(ADDED);
|
||||
MSG_STRING_CASE(REMOVED);
|
||||
MSG_STRING_CASE(DEVICE_ADDED);
|
||||
MSG_STRING_CASE(DEVICE_REMOVED);
|
||||
break;
|
||||
default:
|
||||
assert(!"Unimplemented message type");
|
||||
|
|
@ -209,30 +209,30 @@ client_send_connect(struct eis_client *client)
|
|||
}
|
||||
|
||||
static int
|
||||
client_send_added(struct eis_client *client, struct eis_device *device)
|
||||
client_send_device_added(struct eis_client *client, struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Added added = ADDED__INIT;
|
||||
DeviceAdded added = DEVICE_ADDED__INIT;
|
||||
|
||||
added.deviceid = device->id;
|
||||
added.capabilities = device->capabilities;
|
||||
|
||||
msg.added = &added;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_ADDED;
|
||||
msg.device_added = &added;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_ADDED;
|
||||
|
||||
return client_send_msg(client, &msg);
|
||||
}
|
||||
|
||||
static int
|
||||
client_send_removed(struct eis_client *client, struct eis_device *device)
|
||||
client_send_device_removed(struct eis_client *client, struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Removed removed = REMOVED__INIT;
|
||||
DeviceRemoved removed = DEVICE_REMOVED__INIT;
|
||||
|
||||
removed.deviceid = device->id;
|
||||
|
||||
msg.removed = &removed;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_REMOVED;
|
||||
msg.device_removed = &removed;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_REMOVED;
|
||||
|
||||
return client_send_msg(client, &msg);
|
||||
}
|
||||
|
|
@ -551,9 +551,9 @@ client_parse_message(const char *data, size_t *len)
|
|||
.type = MESSAGE_DISCONNECT,
|
||||
};
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_ADD:
|
||||
case CLIENT_MESSAGE__MSG_ADD_DEVICE:
|
||||
{
|
||||
AddDevice *a = proto->add;
|
||||
AddDevice *a = proto->add_device;
|
||||
*msg = (struct message) {
|
||||
.type = MESSAGE_ADD_DEVICE,
|
||||
.add_device.deviceid = a->deviceid,
|
||||
|
|
@ -561,9 +561,9 @@ client_parse_message(const char *data, size_t *len)
|
|||
};
|
||||
}
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_REMOVE:
|
||||
case CLIENT_MESSAGE__MSG_REMOVE_DEVICE:
|
||||
{
|
||||
RemoveDevice *r = proto->remove;
|
||||
RemoveDevice *r = proto->remove_device;
|
||||
*msg = (struct message) {
|
||||
.type = MESSAGE_REMOVE_DEVICE,
|
||||
.remove_device.deviceid = r->deviceid,
|
||||
|
|
@ -742,13 +742,13 @@ eis_client_new(struct eis *eis, int fd)
|
|||
void
|
||||
eis_client_connect_device(struct eis_client *client, struct eis_device *device)
|
||||
{
|
||||
client_send_added(client, device);
|
||||
client_send_device_added(client, device);
|
||||
}
|
||||
|
||||
void
|
||||
eis_client_disconnect_device(struct eis_client *client, struct eis_device *device)
|
||||
{
|
||||
client_send_removed(client, device);
|
||||
client_send_device_removed(client, device);
|
||||
eis_queue_removed_event(device);
|
||||
list_remove(&device->link);
|
||||
eis_device_unref(device);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue