mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-19 15:00:40 +02:00
Use a helper macro for the protobuf message setup
All of this is always the same steps, let's use a macro so we can limit our code to the bits we actually need to do. This requires renaming some of the protocol itself to match up with the expectations - not the worst thing since it makes the protocol more consistent. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
09929534bf
commit
1f9539540e
3 changed files with 136 additions and 221 deletions
|
|
@ -98,13 +98,13 @@ message PointerAbsolute {
|
|||
double y = 3;
|
||||
}
|
||||
|
||||
message Scroll {
|
||||
message PointerScroll {
|
||||
uint32 deviceid = 1;
|
||||
double x = 2;
|
||||
double y = 3;
|
||||
}
|
||||
|
||||
message ScrollDiscrete {
|
||||
message PointerScrollDiscrete {
|
||||
uint32 deviceid = 1;
|
||||
double x = 2;
|
||||
double y = 3;
|
||||
|
|
@ -148,12 +148,12 @@ message ClientMessage {
|
|||
BindSeat bind_seat = 3;
|
||||
UnbindSeat unbind_seat = 4;
|
||||
CloseDevice close_device = 5;
|
||||
PointerRelative rel = 6;
|
||||
PointerAbsolute abs = 7;
|
||||
Scroll scroll = 8;
|
||||
ScrollDiscrete disc = 9;
|
||||
PointerButton button = 10;
|
||||
KeyboardKey key = 11;
|
||||
PointerRelative pointer_relative = 6;
|
||||
PointerAbsolute pointer_absolute = 7;
|
||||
PointerScroll pointer_scroll = 8;
|
||||
PointerScrollDiscrete pointer_scroll_discrete = 9;
|
||||
PointerButton pointer_button = 10;
|
||||
KeyboardKey keyboard_key = 11;
|
||||
TouchDown touch_down = 12;
|
||||
TouchMotion touch_motion = 13;
|
||||
TouchUp touch_up = 14;
|
||||
|
|
@ -201,7 +201,7 @@ message DeviceRegion {
|
|||
double scale = 6;
|
||||
}
|
||||
|
||||
message DeviceAddedDone {
|
||||
message DeviceDone {
|
||||
uint32 deviceid = 1;
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ message ServerMessage {
|
|||
DeviceAdded device_added = 6;
|
||||
DeviceRegion device_region = 7;
|
||||
DeviceKeymap device_keymap = 8;
|
||||
DeviceAddedDone device_added_done = 9;
|
||||
DeviceDone device_done = 9;
|
||||
DeviceRemoved device_removed = 10;
|
||||
DeviceResumed device_resumed = 11;
|
||||
DeviceSuspended device_suspended = 12;
|
||||
|
|
|
|||
|
|
@ -81,9 +81,9 @@ ei_proto_handle_message(struct ei *ei,
|
|||
proto->device_added->name,
|
||||
proto->device_added->capabilities);
|
||||
break;
|
||||
case SERVER_MESSAGE__MSG_DEVICE_ADDED_DONE:
|
||||
case SERVER_MESSAGE__MSG_DEVICE_DONE:
|
||||
rc = call(device_done, ei,
|
||||
proto->device_added_done->deviceid);
|
||||
proto->device_done->deviceid);
|
||||
break;
|
||||
case SERVER_MESSAGE__MSG_DEVICE_KEYMAP:
|
||||
{
|
||||
|
|
@ -141,12 +141,12 @@ 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(REL);
|
||||
MSG_STRING_CASE(ABS);
|
||||
MSG_STRING_CASE(BUTTON);
|
||||
MSG_STRING_CASE(SCROLL);
|
||||
MSG_STRING_CASE(DISC);
|
||||
MSG_STRING_CASE(KEY);
|
||||
MSG_STRING_CASE(POINTER_RELATIVE);
|
||||
MSG_STRING_CASE(POINTER_ABSOLUTE);
|
||||
MSG_STRING_CASE(POINTER_BUTTON);
|
||||
MSG_STRING_CASE(POINTER_SCROLL);
|
||||
MSG_STRING_CASE(POINTER_SCROLL_DISCRETE);
|
||||
MSG_STRING_CASE(KEYBOARD_KEY);
|
||||
MSG_STRING_CASE(TOUCH_DOWN);
|
||||
MSG_STRING_CASE(TOUCH_MOTION);
|
||||
MSG_STRING_CASE(TOUCH_UP);
|
||||
|
|
@ -199,15 +199,18 @@ ei_proto_send_msg_with_fds(struct ei *ei, const ClientMessage *msg, int *fds)
|
|||
return rc;
|
||||
}
|
||||
|
||||
#define prepare_msg(_type, _struct, _field) \
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT; \
|
||||
_struct _field = _type##__INIT; \
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_##_type; \
|
||||
msg._field = &_field
|
||||
|
||||
static int
|
||||
ei_proto_send_connect(struct ei *ei)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
Connect connect = CONNECT__INIT;
|
||||
connect.name = ei->name;
|
||||
prepare_msg(CONNECT, Connect, connect);
|
||||
|
||||
msg.connect = &connect;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_CONNECT;
|
||||
connect.name = ei->name;
|
||||
|
||||
return ei_proto_send_msg(ei, &msg);
|
||||
}
|
||||
|
|
@ -215,11 +218,7 @@ ei_proto_send_connect(struct ei *ei)
|
|||
static int
|
||||
ei_proto_send_disconnect(struct ei *ei)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
Disconnect disconnect = DISCONNECT__INIT;
|
||||
|
||||
msg.disconnect = &disconnect;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_DISCONNECT;
|
||||
prepare_msg(DISCONNECT, Disconnect, disconnect);
|
||||
|
||||
return ei_proto_send_msg(ei, &msg);
|
||||
}
|
||||
|
|
@ -227,14 +226,10 @@ ei_proto_send_disconnect(struct ei *ei)
|
|||
static int
|
||||
ei_proto_send_bind_seat(struct ei_seat *seat, uint32_t capabilities)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
BindSeat bind = BIND_SEAT__INIT;
|
||||
prepare_msg(BIND_SEAT, BindSeat, bind_seat);
|
||||
|
||||
bind.seatid = seat->id;
|
||||
bind.capabilities = capabilities;
|
||||
|
||||
msg.bind_seat = &bind;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_BIND_SEAT;
|
||||
bind_seat.seatid = seat->id;
|
||||
bind_seat.capabilities = capabilities;
|
||||
|
||||
return ei_proto_send_msg(ei_seat_get_context(seat), &msg);
|
||||
}
|
||||
|
|
@ -242,13 +237,9 @@ ei_proto_send_bind_seat(struct ei_seat *seat, uint32_t capabilities)
|
|||
static int
|
||||
ei_proto_send_unbind_seat(struct ei_seat *seat)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
UnbindSeat unbind = UNBIND_SEAT__INIT;
|
||||
prepare_msg(UNBIND_SEAT, UnbindSeat, unbind_seat);
|
||||
|
||||
unbind.seatid = seat->id;
|
||||
|
||||
msg.unbind_seat = &unbind;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_UNBIND_SEAT;
|
||||
unbind_seat.seatid = seat->id;
|
||||
|
||||
return ei_proto_send_msg(ei_seat_get_context(seat), &msg);
|
||||
}
|
||||
|
|
@ -256,13 +247,9 @@ ei_proto_send_unbind_seat(struct ei_seat *seat)
|
|||
static int
|
||||
ei_proto_send_close_device(struct ei_device *device)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
CloseDevice close = CLOSE_DEVICE__INIT;
|
||||
prepare_msg(CLOSE_DEVICE, CloseDevice, close_device);
|
||||
|
||||
close.deviceid = device->id;
|
||||
|
||||
msg.close_device = &close;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_CLOSE_DEVICE;
|
||||
close_device.deviceid = device->id;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -270,15 +257,11 @@ ei_proto_send_close_device(struct ei_device *device)
|
|||
static int
|
||||
ei_proto_send_rel(struct ei_device *device, double x, double y)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
PointerRelative rel = POINTER_RELATIVE__INIT;
|
||||
prepare_msg(POINTER_RELATIVE, PointerRelative, pointer_relative);
|
||||
|
||||
rel.deviceid = device->id;
|
||||
rel.x = x;
|
||||
rel.y = y;
|
||||
|
||||
msg.rel = &rel;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_REL;
|
||||
pointer_relative.deviceid = device->id;
|
||||
pointer_relative.x = x;
|
||||
pointer_relative.y = y;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -286,15 +269,11 @@ ei_proto_send_rel(struct ei_device *device, double x, double y)
|
|||
static int
|
||||
ei_proto_send_abs(struct ei_device *device, double x, double y)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
PointerAbsolute abs = POINTER_ABSOLUTE__INIT;
|
||||
prepare_msg(POINTER_ABSOLUTE, PointerAbsolute, pointer_absolute);
|
||||
|
||||
abs.deviceid = device->id;
|
||||
abs.x = x;
|
||||
abs.y = y;
|
||||
|
||||
msg.abs = &abs;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_ABS;
|
||||
pointer_absolute.deviceid = device->id;
|
||||
pointer_absolute.x = x;
|
||||
pointer_absolute.y = y;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -302,15 +281,11 @@ ei_proto_send_abs(struct ei_device *device, double x, double y)
|
|||
static int
|
||||
ei_proto_send_button(struct ei_device *device, uint32_t b, bool is_press)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
PointerButton button = POINTER_BUTTON__INIT;
|
||||
prepare_msg(POINTER_BUTTON, PointerButton, pointer_button);
|
||||
|
||||
button.deviceid = device->id;
|
||||
button.button = b;
|
||||
button.state = is_press;
|
||||
|
||||
msg.button = &button;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_BUTTON;
|
||||
pointer_button.deviceid = device->id;
|
||||
pointer_button.button = b;
|
||||
pointer_button.state = is_press;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -318,15 +293,11 @@ ei_proto_send_button(struct ei_device *device, uint32_t b, bool is_press)
|
|||
static int
|
||||
ei_proto_send_scroll(struct ei_device *device, double x, double y)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
Scroll scroll = SCROLL__INIT;
|
||||
prepare_msg(POINTER_SCROLL, PointerScroll, pointer_scroll);
|
||||
|
||||
scroll.deviceid = device->id;
|
||||
scroll.x = x;
|
||||
scroll.y = y;
|
||||
|
||||
msg.scroll = &scroll;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_SCROLL;
|
||||
pointer_scroll.deviceid = device->id;
|
||||
pointer_scroll.x = x;
|
||||
pointer_scroll.y = y;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -334,15 +305,11 @@ ei_proto_send_scroll(struct ei_device *device, double x, double y)
|
|||
static int
|
||||
ei_proto_send_scroll_discrete(struct ei_device *device, int32_t x, int32_t y)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
ScrollDiscrete disc = SCROLL_DISCRETE__INIT;
|
||||
prepare_msg(POINTER_SCROLL_DISCRETE, PointerScrollDiscrete, pointer_scroll_discrete);
|
||||
|
||||
disc.deviceid = device->id;
|
||||
disc.x = x;
|
||||
disc.y = y;
|
||||
|
||||
msg.disc = &disc;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_DISC;
|
||||
pointer_scroll_discrete.deviceid = device->id;
|
||||
pointer_scroll_discrete.x = x;
|
||||
pointer_scroll_discrete.y = y;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -350,15 +317,11 @@ ei_proto_send_scroll_discrete(struct ei_device *device, int32_t x, int32_t y)
|
|||
static int
|
||||
ei_proto_send_key(struct ei_device *device, uint32_t k, bool is_press)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
KeyboardKey key = KEYBOARD_KEY__INIT;
|
||||
prepare_msg(KEYBOARD_KEY, KeyboardKey, keyboard_key);
|
||||
|
||||
key.deviceid = device->id;
|
||||
key.key = k;
|
||||
key.state = is_press;
|
||||
|
||||
msg.key = &key;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_KEY;
|
||||
keyboard_key.deviceid = device->id;
|
||||
keyboard_key.key = k;
|
||||
keyboard_key.state = is_press;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -367,16 +330,12 @@ ei_proto_send_key(struct ei_device *device, uint32_t k, bool is_press)
|
|||
static int
|
||||
ei_proto_send_touch_down(struct ei_device *device, uint32_t tid, double x, double y)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
TouchDown touch = TOUCH_DOWN__INIT;
|
||||
prepare_msg(TOUCH_DOWN, TouchDown, touch_down);
|
||||
|
||||
touch.deviceid = device->id;
|
||||
touch.touchid = tid;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
|
||||
msg.touch_down = &touch;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_TOUCH_DOWN;
|
||||
touch_down.deviceid = device->id;
|
||||
touch_down.touchid = tid;
|
||||
touch_down.x = x;
|
||||
touch_down.y = y;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -384,16 +343,12 @@ ei_proto_send_touch_down(struct ei_device *device, uint32_t tid, double x, doubl
|
|||
static int
|
||||
ei_proto_send_touch_motion(struct ei_device *device, uint32_t tid, double x, double y)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
TouchMotion touch = TOUCH_MOTION__INIT;
|
||||
prepare_msg(TOUCH_MOTION, TouchMotion, touch_motion);
|
||||
|
||||
touch.deviceid = device->id;
|
||||
touch.touchid = tid;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
|
||||
msg.touch_motion = &touch;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_TOUCH_MOTION;
|
||||
touch_motion.deviceid = device->id;
|
||||
touch_motion.touchid = tid;
|
||||
touch_motion.x = x;
|
||||
touch_motion.y = y;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
@ -401,14 +356,10 @@ ei_proto_send_touch_motion(struct ei_device *device, uint32_t tid, double x, dou
|
|||
static int
|
||||
ei_proto_send_touch_up(struct ei_device *device, uint32_t tid)
|
||||
{
|
||||
ClientMessage msg = CLIENT_MESSAGE__INIT;
|
||||
TouchUp touch = TOUCH_UP__INIT;
|
||||
prepare_msg(TOUCH_UP, TouchUp, touch_up);
|
||||
|
||||
touch.deviceid = device->id;
|
||||
touch.touchid = tid;
|
||||
|
||||
msg.touch_up = &touch;
|
||||
msg.msg_case = CLIENT_MESSAGE__MSG_TOUCH_UP;
|
||||
touch_up.deviceid = device->id;
|
||||
touch_up.touchid = tid;
|
||||
|
||||
return ei_proto_send_msg(ei_device_get_context(device), &msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ log_wire_message(struct eis *eis, const ServerMessage *msg)
|
|||
MSG_STRING_CASE(SEAT_ADDED);
|
||||
MSG_STRING_CASE(SEAT_REMOVED);
|
||||
MSG_STRING_CASE(DEVICE_ADDED);
|
||||
MSG_STRING_CASE(DEVICE_ADDED_DONE);
|
||||
MSG_STRING_CASE(DEVICE_DONE);
|
||||
MSG_STRING_CASE(DEVICE_KEYMAP);
|
||||
MSG_STRING_CASE(DEVICE_REGION);
|
||||
MSG_STRING_CASE(DEVICE_REMOVED);
|
||||
|
|
@ -99,14 +99,16 @@ eis_proto_send_msg_with_fds(struct eis_client *client, const ServerMessage *msg,
|
|||
return min(0, xsend_with_fd(source_get_fd(client->source), buf, sizeof(buf), fds));
|
||||
}
|
||||
|
||||
#define prepare_msg(_type, _struct, _field) \
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT; \
|
||||
_struct _field = _type##__INIT; \
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_##_type; \
|
||||
msg._field = &_field
|
||||
|
||||
static int
|
||||
eis_proto_send_disconnected(struct eis_client *client)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Disconnected disconnected = DISCONNECTED__INIT;
|
||||
|
||||
msg.disconnected = &disconnected;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DISCONNECTED;
|
||||
prepare_msg(DISCONNECTED, Disconnected, disconnected);
|
||||
|
||||
return eis_proto_send_msg(client, &msg);
|
||||
}
|
||||
|
|
@ -114,11 +116,7 @@ eis_proto_send_disconnected(struct eis_client *client)
|
|||
static int
|
||||
eis_proto_send_connected(struct eis_client *client)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Connected connected = CONNECTED__INIT;
|
||||
|
||||
msg.connected = &connected;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_CONNECTED;
|
||||
prepare_msg(CONNECTED, Connected, connected);
|
||||
|
||||
return eis_proto_send_msg(client, &msg);
|
||||
}
|
||||
|
|
@ -126,15 +124,11 @@ eis_proto_send_connected(struct eis_client *client)
|
|||
static int
|
||||
eis_proto_send_seat_added(struct eis_seat *seat)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
SeatAdded added = SEAT_ADDED__INIT;
|
||||
prepare_msg(SEAT_ADDED, SeatAdded, seat_added);
|
||||
|
||||
added.seatid = seat->id;
|
||||
added.name = seat->name;
|
||||
added.capabilities = seat->capabilities_mask;
|
||||
|
||||
msg.seat_added = &added;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_SEAT_ADDED;
|
||||
seat_added.seatid = seat->id;
|
||||
seat_added.name = seat->name;
|
||||
seat_added.capabilities = seat->capabilities_mask;
|
||||
|
||||
return eis_proto_send_msg(eis_seat_get_client(seat), &msg);
|
||||
}
|
||||
|
|
@ -142,13 +136,9 @@ eis_proto_send_seat_added(struct eis_seat *seat)
|
|||
static int
|
||||
eis_proto_send_seat_removed(struct eis_seat *seat)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
SeatRemoved removed = SEAT_REMOVED__INIT;
|
||||
prepare_msg(SEAT_REMOVED, SeatRemoved, seat_removed);
|
||||
|
||||
removed.seatid = seat->id;
|
||||
|
||||
msg.seat_removed = &removed;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_SEAT_REMOVED;
|
||||
seat_removed.seatid = seat->id;
|
||||
|
||||
return eis_proto_send_msg(eis_seat_get_client(seat), &msg);
|
||||
}
|
||||
|
|
@ -156,17 +146,13 @@ eis_proto_send_seat_removed(struct eis_seat *seat)
|
|||
static int
|
||||
eis_proto_send_device_added(struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
DeviceAdded added = DEVICE_ADDED__INIT;
|
||||
prepare_msg(DEVICE_ADDED, DeviceAdded, device_added);
|
||||
|
||||
struct eis_seat *seat = eis_device_get_seat(device);
|
||||
|
||||
added.deviceid = device->id;
|
||||
added.seatid = seat->id;
|
||||
added.name = device->name;
|
||||
added.capabilities = device->capabilities;
|
||||
|
||||
msg.device_added = &added;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_ADDED;
|
||||
device_added.deviceid = device->id;
|
||||
device_added.seatid = seat->id;
|
||||
device_added.name = device->name;
|
||||
device_added.capabilities = device->capabilities;
|
||||
|
||||
return eis_proto_send_msg(eis_device_get_client(device), &msg);
|
||||
}
|
||||
|
|
@ -174,21 +160,19 @@ eis_proto_send_device_added(struct eis_device *device)
|
|||
static int
|
||||
eis_proto_send_device_keymap(struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
DeviceKeymap keymap = DEVICE_KEYMAP__INIT;
|
||||
prepare_msg(DEVICE_KEYMAP, DeviceKeymap, device_keymap);
|
||||
|
||||
int fds[2] = {-1, -1};
|
||||
|
||||
if (!device->keymap)
|
||||
return 0;
|
||||
|
||||
struct eis_keymap *k = device->keymap;
|
||||
keymap.deviceid = device->id;
|
||||
keymap.keymap_type = k->type;
|
||||
keymap.keymap_size = k->size;
|
||||
device_keymap.deviceid = device->id;
|
||||
device_keymap.keymap_type = k->type;
|
||||
device_keymap.keymap_size = k->size;
|
||||
fds[0] = k->fd;
|
||||
|
||||
msg.device_keymap = &keymap;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_KEYMAP;
|
||||
|
||||
return eis_proto_send_msg_with_fds(eis_device_get_client(device), &msg, fds);
|
||||
}
|
||||
|
|
@ -196,13 +180,9 @@ eis_proto_send_device_keymap(struct eis_device *device)
|
|||
static int
|
||||
eis_proto_send_device_done(struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
DeviceAddedDone done = DEVICE_ADDED_DONE__INIT;
|
||||
prepare_msg(DEVICE_DONE, DeviceDone, device_done);
|
||||
|
||||
done.deviceid = device->id;
|
||||
|
||||
msg.device_added_done = &done;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_ADDED_DONE;
|
||||
device_done.deviceid = device->id;
|
||||
|
||||
return eis_proto_send_msg(eis_device_get_client(device), &msg);
|
||||
}
|
||||
|
|
@ -210,18 +190,14 @@ eis_proto_send_device_done(struct eis_device *device)
|
|||
static int
|
||||
eis_proto_send_device_region(struct eis_device *device, const struct eis_region *r)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
DeviceRegion region = DEVICE_REGION__INIT;
|
||||
prepare_msg(DEVICE_REGION, DeviceRegion, device_region);
|
||||
|
||||
region.deviceid = device->id;
|
||||
region.offset_x = r->x;
|
||||
region.offset_y = r->y;
|
||||
region.width = r->width;
|
||||
region.height = r->height;
|
||||
region.scale = r->physical_scale;
|
||||
|
||||
msg.device_region = ®ion;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_REGION;
|
||||
device_region.deviceid = device->id;
|
||||
device_region.offset_x = r->x;
|
||||
device_region.offset_y = r->y;
|
||||
device_region.width = r->width;
|
||||
device_region.height = r->height;
|
||||
device_region.scale = r->physical_scale;
|
||||
|
||||
return eis_proto_send_msg(eis_device_get_client(device), &msg);
|
||||
}
|
||||
|
|
@ -229,13 +205,9 @@ eis_proto_send_device_region(struct eis_device *device, const struct eis_region
|
|||
static int
|
||||
eis_proto_send_device_removed(struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
DeviceRemoved removed = DEVICE_REMOVED__INIT;
|
||||
prepare_msg(DEVICE_REMOVED, DeviceRemoved, device_removed);
|
||||
|
||||
removed.deviceid = device->id;
|
||||
|
||||
msg.device_removed = &removed;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_REMOVED;
|
||||
device_removed.deviceid = device->id;
|
||||
|
||||
return eis_proto_send_msg(eis_device_get_client(device), &msg);
|
||||
}
|
||||
|
|
@ -243,13 +215,9 @@ eis_proto_send_device_removed(struct eis_device *device)
|
|||
static int
|
||||
eis_proto_send_device_suspended(struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
DeviceSuspended suspended = DEVICE_SUSPENDED__INIT;
|
||||
prepare_msg(DEVICE_SUSPENDED, DeviceSuspended, device_suspended);
|
||||
|
||||
suspended.deviceid = device->id;
|
||||
|
||||
msg.device_suspended = &suspended;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_SUSPENDED;
|
||||
device_suspended.deviceid = device->id;
|
||||
|
||||
return eis_proto_send_msg(eis_device_get_client(device), &msg);
|
||||
}
|
||||
|
|
@ -257,13 +225,9 @@ eis_proto_send_device_suspended(struct eis_device *device)
|
|||
static int
|
||||
eis_proto_send_device_resumed(struct eis_device *device)
|
||||
{
|
||||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
DeviceResumed resumed = DEVICE_RESUMED__INIT;
|
||||
prepare_msg(DEVICE_RESUMED, DeviceResumed, device_resumed);
|
||||
|
||||
resumed.deviceid = device->id;
|
||||
|
||||
msg.device_resumed = &resumed;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DEVICE_RESUMED;
|
||||
device_resumed.deviceid = device->id;
|
||||
|
||||
return eis_proto_send_msg(eis_device_get_client(device), &msg);
|
||||
}
|
||||
|
|
@ -331,41 +295,41 @@ eis_proto_handle_message(struct eis_client *client,
|
|||
rc = call(close_device, client,
|
||||
proto->close_device->deviceid);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_REL:
|
||||
case CLIENT_MESSAGE__MSG_POINTER_RELATIVE:
|
||||
rc = call(rel, client,
|
||||
proto->rel->deviceid,
|
||||
proto->rel->x,
|
||||
proto->rel->y);
|
||||
proto->pointer_relative->deviceid,
|
||||
proto->pointer_relative->x,
|
||||
proto->pointer_relative->y);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_ABS:
|
||||
case CLIENT_MESSAGE__MSG_POINTER_ABSOLUTE:
|
||||
rc = call(abs, client,
|
||||
proto->abs->deviceid,
|
||||
proto->abs->x,
|
||||
proto->abs->y);
|
||||
proto->pointer_absolute->deviceid,
|
||||
proto->pointer_absolute->x,
|
||||
proto->pointer_absolute->y);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_BUTTON:
|
||||
case CLIENT_MESSAGE__MSG_POINTER_BUTTON:
|
||||
rc = call(button, client,
|
||||
proto->button->deviceid,
|
||||
proto->button->button,
|
||||
proto->button->state);
|
||||
proto->pointer_button->deviceid,
|
||||
proto->pointer_button->button,
|
||||
proto->pointer_button->state);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_SCROLL:
|
||||
case CLIENT_MESSAGE__MSG_POINTER_SCROLL:
|
||||
rc = call(scroll, client,
|
||||
proto->scroll->deviceid,
|
||||
proto->scroll->x,
|
||||
proto->scroll->y);
|
||||
proto->pointer_scroll->deviceid,
|
||||
proto->pointer_scroll->x,
|
||||
proto->pointer_scroll->y);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_DISC:
|
||||
case CLIENT_MESSAGE__MSG_POINTER_SCROLL_DISCRETE:
|
||||
rc = call(scroll_discrete, client,
|
||||
proto->disc->deviceid,
|
||||
proto->disc->x,
|
||||
proto->disc->y);
|
||||
proto->pointer_scroll_discrete->deviceid,
|
||||
proto->pointer_scroll_discrete->x,
|
||||
proto->pointer_scroll_discrete->y);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_KEY:
|
||||
case CLIENT_MESSAGE__MSG_KEYBOARD_KEY:
|
||||
rc = call(key, client,
|
||||
proto->key->deviceid,
|
||||
proto->key->key,
|
||||
proto->key->state);
|
||||
proto->keyboard_key->deviceid,
|
||||
proto->keyboard_key->key,
|
||||
proto->keyboard_key->state);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_TOUCH_DOWN:
|
||||
rc = call(touch_down, client,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue