diff --git a/src/libeis-client.c b/src/libeis-client.c index c7dc9b0..700f615 100644 --- a/src/libeis-client.c +++ b/src/libeis-client.c @@ -160,6 +160,8 @@ eis_client_has_capability(struct eis_client *client, case EIS_DEVICE_CAP_POINTER_ABSOLUTE: case EIS_DEVICE_CAP_KEYBOARD: case EIS_DEVICE_CAP_TOUCH: + case EIS_DEVICE_CAP_BUTTON: + case EIS_DEVICE_CAP_SCROLL: return mask_all(client->restrictions.cap_allow_mask, cap); } diff --git a/src/libeis-device.c b/src/libeis-device.c index a5d6b48..c0215a1 100644 --- a/src/libeis-device.c +++ b/src/libeis-device.c @@ -392,10 +392,9 @@ client_msg_button(struct eis_button *button, uint32_t btn, uint32_t state) DISCONNECT_IF_RECEIVER_CONTEXT(device); - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_BUTTON)) { return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL, - "Pointer button event for non-pointer device"); + "Button event for non-button device"); } if (device->state == EIS_DEVICE_STATE_EMULATING) { @@ -413,10 +412,9 @@ client_msg_scroll(struct eis_scroll *scroll, float x, float y) DISCONNECT_IF_RECEIVER_CONTEXT(device); - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL, - "Pointer scroll event for non-pointer device"); + "Scroll event for non-scroll device"); } if (device->state == EIS_DEVICE_STATE_EMULATING) { @@ -434,10 +432,9 @@ client_msg_scroll_discrete(struct eis_scroll *scroll, int32_t x, int32_t y) DISCONNECT_IF_RECEIVER_CONTEXT(device); - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL, - "Pointer scroll discrete event for non-pointer device"); + "Scroll discrete event for non-scroll device"); } if (device->state == EIS_DEVICE_STATE_EMULATING) { @@ -456,10 +453,9 @@ client_msg_scroll_stop(struct eis_scroll *scroll, DISCONNECT_IF_RECEIVER_CONTEXT(device); - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL, - "Pointer scroll stop event for non-pointer device"); + "Scroll stop event for non-scroll device"); } if (device->state == EIS_DEVICE_STATE_EMULATING) { @@ -753,6 +749,8 @@ eis_device_configure_capability(struct eis_device *device, enum eis_device_capab case EIS_DEVICE_CAP_POINTER_ABSOLUTE: case EIS_DEVICE_CAP_KEYBOARD: case EIS_DEVICE_CAP_TOUCH: + case EIS_DEVICE_CAP_BUTTON: + case EIS_DEVICE_CAP_SCROLL: mask_add(device->capabilities, cap); break; } @@ -822,7 +820,6 @@ eis_device_add(struct eis_device *device) if (rc < 0) goto out; } - if (eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE)) { device->pointer_absolute = eis_pointer_absolute_new(device); rc = eis_device_event_interface(device, eis_pointer_absolute_get_id(device->pointer_absolute), @@ -831,16 +828,15 @@ eis_device_add(struct eis_device *device) if (rc < 0) goto out; } - - if (eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER) || - eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE)) { + if (eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { device->scroll = eis_scroll_new(device); rc = eis_device_event_interface(device, eis_scroll_get_id(device->scroll), EIS_SCROLL_INTERFACE_NAME, eis_scroll_get_version(device->scroll)); if (rc < 0) goto out; - + } + if (eis_device_has_capability(device, EIS_DEVICE_CAP_BUTTON)) { device->button = eis_button_new(device); rc = eis_device_event_interface(device, eis_button_get_id(device->button), EIS_BUTTON_INTERFACE_NAME, @@ -935,6 +931,8 @@ eis_device_has_capability(struct eis_device *device, case EIS_DEVICE_CAP_POINTER_ABSOLUTE: case EIS_DEVICE_CAP_KEYBOARD: case EIS_DEVICE_CAP_TOUCH: + case EIS_DEVICE_CAP_BUTTON: + case EIS_DEVICE_CAP_SCROLL: return mask_all(device->capabilities, cap); } return false; @@ -1033,12 +1031,12 @@ eis_device_pointer_motion_absolute(struct eis_device *device, } _public_ void -eis_device_pointer_button(struct eis_device *device, +eis_device_button_button(struct eis_device *device, uint32_t button, bool is_press) { - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_BUTTON)) { log_bug_client(eis_device_get_context(device), - "%s: device is not a pointer", __func__); + "%s: device is not a button device", __func__); return; } @@ -1072,13 +1070,11 @@ eis_device_resume_scrolling(struct eis_device *device, double x, double y) } _public_ void -eis_device_pointer_scroll(struct eis_device *device, - double x, double y) +eis_device_scroll_delta(struct eis_device *device, double x, double y) { - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { log_bug_client(eis_device_get_context(device), - "%s: device is not a (absolute) pointer", __func__); + "%s: device is not a scroll device", __func__); } if (device->state != EIS_DEVICE_STATE_EMULATING) @@ -1092,13 +1088,13 @@ eis_device_pointer_scroll(struct eis_device *device, } _public_ void -eis_device_pointer_scroll_stop(struct eis_device *device, bool x, bool y) +eis_device_scroll_stop(struct eis_device *device, bool x, bool y) { - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { log_bug_client(eis_device_get_context(device), - "%s: device is not a (absolute) pointer", __func__); + "%s: device is not a scroll device", __func__); } + if (device->state != EIS_DEVICE_STATE_EMULATING) return; @@ -1120,13 +1116,13 @@ eis_device_pointer_scroll_stop(struct eis_device *device, bool x, bool y) } _public_ void -eis_device_pointer_scroll_cancel(struct eis_device *device, bool x, bool y) +eis_device_scroll_cancel(struct eis_device *device, bool x, bool y) { - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { log_bug_client(eis_device_get_context(device), - "%s: device is not a (absolute) pointer", __func__); + "%s: device is not a scroll device", __func__); } + if (device->state != EIS_DEVICE_STATE_EMULATING) return; @@ -1152,13 +1148,11 @@ eis_device_pointer_scroll_cancel(struct eis_device *device, bool x, bool y) } _public_ void -eis_device_pointer_scroll_discrete(struct eis_device *device, - int32_t x, int32_t y) +eis_device_scroll_discrete(struct eis_device *device, int32_t x, int32_t y) { - if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER) && - !eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE)) { + if (!eis_device_has_capability(device, EIS_DEVICE_CAP_SCROLL)) { log_bug_client(eis_device_get_context(device), - "%s: device is not a (absolute) pointer", __func__); + "%s: device is not a scroll device", __func__); } if (device->state != EIS_DEVICE_STATE_EMULATING) diff --git a/src/libeis-event.c b/src/libeis-event.c index 1c4c11d..a1cfdc4 100644 --- a/src/libeis-event.c +++ b/src/libeis-event.c @@ -44,13 +44,13 @@ eis_event_destroy(struct eis_event *event) case EIS_EVENT_DEVICE_CLOSED: case EIS_EVENT_DEVICE_START_EMULATING: case EIS_EVENT_DEVICE_STOP_EMULATING: - case EIS_EVENT_POINTER_BUTTON: + case EIS_EVENT_BUTTON_BUTTON: case EIS_EVENT_POINTER_MOTION: case EIS_EVENT_POINTER_MOTION_ABSOLUTE: - case EIS_EVENT_POINTER_SCROLL_DELTA: - case EIS_EVENT_POINTER_SCROLL_STOP: - case EIS_EVENT_POINTER_SCROLL_CANCEL: - case EIS_EVENT_POINTER_SCROLL_DISCRETE: + case EIS_EVENT_SCROLL_DELTA: + case EIS_EVENT_SCROLL_STOP: + case EIS_EVENT_SCROLL_CANCEL: + case EIS_EVENT_SCROLL_DISCRETE: case EIS_EVENT_KEYBOARD_KEY: case EIS_EVENT_TOUCH_DOWN: case EIS_EVENT_TOUCH_MOTION: @@ -173,11 +173,11 @@ eis_event_get_time(struct eis_event *event) require_event_type(event, 0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_STOP, - EIS_EVENT_POINTER_SCROLL_CANCEL, - EIS_EVENT_POINTER_SCROLL_DISCRETE, + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_STOP, + EIS_EVENT_SCROLL_CANCEL, + EIS_EVENT_SCROLL_DISCRETE, EIS_EVENT_KEYBOARD_KEY, EIS_EVENT_TOUCH_DOWN, EIS_EVENT_TOUCH_UP, @@ -197,6 +197,8 @@ eis_event_seat_has_capability(struct eis_event *event, enum eis_device_capabilit case EIS_DEVICE_CAP_POINTER_ABSOLUTE: case EIS_DEVICE_CAP_KEYBOARD: case EIS_DEVICE_CAP_TOUCH: + case EIS_DEVICE_CAP_BUTTON: + case EIS_DEVICE_CAP_SCROLL: return mask_all(event->bind.capabilities, cap); } return false; @@ -216,9 +218,9 @@ eis_event_pointer_get_dx(struct eis_event *event) require_event_type(event, 0.0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.dx; } @@ -229,9 +231,9 @@ eis_event_pointer_get_dy(struct eis_event *event) require_event_type(event, 0.0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.dy; } @@ -242,9 +244,9 @@ eis_event_pointer_get_absolute_x(struct eis_event *event) require_event_type(event, 0.0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.absx; } @@ -255,102 +257,102 @@ eis_event_pointer_get_absolute_y(struct eis_event *event) require_event_type(event, 0.0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.absy; } _public_ uint32_t -eis_event_pointer_get_button(struct eis_event *event) +eis_event_button_get_button(struct eis_event *event) { require_event_type(event, 0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.button; } _public_ bool -eis_event_pointer_get_button_is_press(struct eis_event *event) +eis_event_button_get_is_press(struct eis_event *event) { require_event_type(event, false, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.button_is_press; } _public_ double -eis_event_pointer_get_scroll_x(struct eis_event *event) +eis_event_scroll_get_dx(struct eis_event *event) { require_event_type(event, 0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.sx; } _public_ double -eis_event_pointer_get_scroll_y(struct eis_event *event) +eis_event_scroll_get_dy(struct eis_event *event) { require_event_type(event, 0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.sy; } _public_ int32_t -eis_event_pointer_get_scroll_discrete_x(struct eis_event *event) +eis_event_scroll_get_discrete_dx(struct eis_event *event) { require_event_type(event, 0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.sdx; } _public_ int32_t -eis_event_pointer_get_scroll_discrete_y(struct eis_event *event) +eis_event_scroll_get_discrete_dy(struct eis_event *event) { require_event_type(event, 0, EIS_EVENT_POINTER_MOTION, EIS_EVENT_POINTER_MOTION_ABSOLUTE, - EIS_EVENT_POINTER_BUTTON, - EIS_EVENT_POINTER_SCROLL_DELTA, - EIS_EVENT_POINTER_SCROLL_DISCRETE); + EIS_EVENT_BUTTON_BUTTON, + EIS_EVENT_SCROLL_DELTA, + EIS_EVENT_SCROLL_DISCRETE); return event->pointer.sdy; } _public_ bool -eis_event_pointer_get_scroll_stop_x(struct eis_event *event) +eis_event_scroll_get_stop_x(struct eis_event *event) { require_event_type(event, 0, - EIS_EVENT_POINTER_SCROLL_STOP, - EIS_EVENT_POINTER_SCROLL_CANCEL); + EIS_EVENT_SCROLL_STOP, + EIS_EVENT_SCROLL_CANCEL); return event->pointer.stop_x; } _public_ bool -eis_event_pointer_get_scroll_stop_y(struct eis_event *event) +eis_event_scroll_get_stop_y(struct eis_event *event) { require_event_type(event, 0, - EIS_EVENT_POINTER_SCROLL_STOP, - EIS_EVENT_POINTER_SCROLL_CANCEL); + EIS_EVENT_SCROLL_STOP, + EIS_EVENT_SCROLL_CANCEL); return event->pointer.stop_y; } diff --git a/src/libeis-seat.c b/src/libeis-seat.c index df10093..c3bf7fe 100644 --- a/src/libeis-seat.c +++ b/src/libeis-seat.c @@ -104,9 +104,10 @@ client_msg_bind(struct eis_seat *seat, uint64_t caps) capabilities |= EIS_DEVICE_CAP_KEYBOARD; if (caps & bit(EIS_TOUCHSCREEN_INTERFACE_INDEX)) capabilities |= EIS_DEVICE_CAP_TOUCH; - - /* Note: a client binding to button/scroll only - ends up with libeis capabilities 0. */ + if (caps & bit(EIS_BUTTON_INTERFACE_INDEX)) + capabilities |= EIS_DEVICE_CAP_BUTTON; + if (caps & bit(EIS_SCROLL_INTERFACE_INDEX)) + capabilities |= EIS_DEVICE_CAP_SCROLL; eis_seat_bind(seat, capabilities); @@ -299,6 +300,8 @@ eis_seat_configure_capability(struct eis_seat *seat, case EIS_DEVICE_CAP_POINTER_ABSOLUTE: case EIS_DEVICE_CAP_KEYBOARD: case EIS_DEVICE_CAP_TOUCH: + case EIS_DEVICE_CAP_BUTTON: + case EIS_DEVICE_CAP_SCROLL: mask_add(seat->capabilities.c_mask, cap); break; } @@ -313,6 +316,8 @@ eis_seat_has_capability(struct eis_seat *seat, case EIS_DEVICE_CAP_POINTER_ABSOLUTE: case EIS_DEVICE_CAP_KEYBOARD: case EIS_DEVICE_CAP_TOUCH: + case EIS_DEVICE_CAP_BUTTON: + case EIS_DEVICE_CAP_SCROLL: return mask_all(seat->capabilities.c_mask, cap); } return false; diff --git a/src/libeis.c b/src/libeis.c index 7469bf9..be8bdc2 100644 --- a/src/libeis.c +++ b/src/libeis.c @@ -122,11 +122,11 @@ eis_event_type_to_string(enum eis_event_type type) CASE_RETURN_STRING(EIS_EVENT_DEVICE_STOP_EMULATING); CASE_RETURN_STRING(EIS_EVENT_POINTER_MOTION); CASE_RETURN_STRING(EIS_EVENT_POINTER_MOTION_ABSOLUTE); - CASE_RETURN_STRING(EIS_EVENT_POINTER_BUTTON); - CASE_RETURN_STRING(EIS_EVENT_POINTER_SCROLL_DELTA); - CASE_RETURN_STRING(EIS_EVENT_POINTER_SCROLL_STOP); - CASE_RETURN_STRING(EIS_EVENT_POINTER_SCROLL_CANCEL); - CASE_RETURN_STRING(EIS_EVENT_POINTER_SCROLL_DISCRETE); + CASE_RETURN_STRING(EIS_EVENT_BUTTON_BUTTON); + CASE_RETURN_STRING(EIS_EVENT_SCROLL_DELTA); + CASE_RETURN_STRING(EIS_EVENT_SCROLL_STOP); + CASE_RETURN_STRING(EIS_EVENT_SCROLL_CANCEL); + CASE_RETURN_STRING(EIS_EVENT_SCROLL_DISCRETE); CASE_RETURN_STRING(EIS_EVENT_KEYBOARD_KEY); CASE_RETURN_STRING(EIS_EVENT_TOUCH_DOWN); CASE_RETURN_STRING(EIS_EVENT_TOUCH_UP); @@ -143,11 +143,11 @@ update_event_timestamp(struct eis_event *event, uint64_t time) switch (event->type) { case EIS_EVENT_POINTER_MOTION: case EIS_EVENT_POINTER_MOTION_ABSOLUTE: - case EIS_EVENT_POINTER_BUTTON: - case EIS_EVENT_POINTER_SCROLL_DELTA: - case EIS_EVENT_POINTER_SCROLL_STOP: - case EIS_EVENT_POINTER_SCROLL_CANCEL: - case EIS_EVENT_POINTER_SCROLL_DISCRETE: + case EIS_EVENT_BUTTON_BUTTON: + case EIS_EVENT_SCROLL_DELTA: + case EIS_EVENT_SCROLL_STOP: + case EIS_EVENT_SCROLL_CANCEL: + case EIS_EVENT_SCROLL_DISCRETE: case EIS_EVENT_KEYBOARD_KEY: case EIS_EVENT_TOUCH_DOWN: case EIS_EVENT_TOUCH_UP: @@ -179,11 +179,11 @@ eis_queue_event(struct eis_event *event) switch (event->type) { case EIS_EVENT_POINTER_MOTION: case EIS_EVENT_POINTER_MOTION_ABSOLUTE: - case EIS_EVENT_POINTER_BUTTON: - case EIS_EVENT_POINTER_SCROLL_DELTA: - case EIS_EVENT_POINTER_SCROLL_STOP: - case EIS_EVENT_POINTER_SCROLL_CANCEL: - case EIS_EVENT_POINTER_SCROLL_DISCRETE: + case EIS_EVENT_BUTTON_BUTTON: + case EIS_EVENT_SCROLL_DELTA: + case EIS_EVENT_SCROLL_STOP: + case EIS_EVENT_SCROLL_CANCEL: + case EIS_EVENT_SCROLL_DISCRETE: case EIS_EVENT_KEYBOARD_KEY: case EIS_EVENT_TOUCH_DOWN: case EIS_EVENT_TOUCH_UP: @@ -303,7 +303,7 @@ eis_queue_pointer_button_event(struct eis_device *device, uint32_t button, bool is_press) { struct eis_event *e = eis_event_new_for_device(device); - e->type = EIS_EVENT_POINTER_BUTTON; + e->type = EIS_EVENT_BUTTON_BUTTON; e->pointer.button = button; e->pointer.button_is_press = is_press; @@ -315,7 +315,7 @@ eis_queue_pointer_scroll_event(struct eis_device *device, double x, double y) { struct eis_event *e = eis_event_new_for_device(device); - e->type = EIS_EVENT_POINTER_SCROLL_DELTA; + e->type = EIS_EVENT_SCROLL_DELTA; e->pointer.sx = x; e->pointer.sy = y; eis_queue_event(e); @@ -326,7 +326,7 @@ eis_queue_pointer_scroll_discrete_event(struct eis_device *device, int32_t x, int32_t y) { struct eis_event *e = eis_event_new_for_device(device); - e->type = EIS_EVENT_POINTER_SCROLL_DISCRETE; + e->type = EIS_EVENT_SCROLL_DISCRETE; e->pointer.sdx = x; e->pointer.sdy = y; eis_queue_event(e); @@ -336,7 +336,7 @@ void eis_queue_pointer_scroll_stop_event(struct eis_device *device, bool x, bool y) { struct eis_event *e = eis_event_new_for_device(device); - e->type = EIS_EVENT_POINTER_SCROLL_STOP; + e->type = EIS_EVENT_SCROLL_STOP; e->pointer.stop_x = x; e->pointer.stop_y = y; eis_queue_event(e); @@ -346,7 +346,7 @@ void eis_queue_pointer_scroll_cancel_event(struct eis_device *device, bool x, bool y) { struct eis_event *e = eis_event_new_for_device(device); - e->type = EIS_EVENT_POINTER_SCROLL_CANCEL; + e->type = EIS_EVENT_SCROLL_CANCEL; e->pointer.stop_x = x; e->pointer.stop_y = y; eis_queue_event(e); diff --git a/src/libeis.h b/src/libeis.h index 7ef1a13..8a35a1f 100644 --- a/src/libeis.h +++ b/src/libeis.h @@ -119,10 +119,12 @@ enum eis_device_type { }; enum eis_device_capability { - EIS_DEVICE_CAP_POINTER = 1, - EIS_DEVICE_CAP_POINTER_ABSOLUTE = 2, - EIS_DEVICE_CAP_KEYBOARD = 4, - EIS_DEVICE_CAP_TOUCH = 8, + EIS_DEVICE_CAP_POINTER = (1 << 0), + EIS_DEVICE_CAP_POINTER_ABSOLUTE = (1 << 1), + EIS_DEVICE_CAP_KEYBOARD = (1 << 2), + EIS_DEVICE_CAP_TOUCH = (1 << 3), + EIS_DEVICE_CAP_SCROLL = (1 << 4), + EIS_DEVICE_CAP_BUTTON = (1 << 5), }; enum eis_keymap_type { @@ -205,25 +207,25 @@ enum eis_event_type { /** * A button press or release event */ - EIS_EVENT_POINTER_BUTTON, + EIS_EVENT_BUTTON_BUTTON, /** * A vertical and/or horizontal scroll event with logical-pixels * or mm precision, depending on the device type. */ - EIS_EVENT_POINTER_SCROLL_DELTA, + EIS_EVENT_SCROLL_DELTA, /** * An ongoing scroll sequence stopped. */ - EIS_EVENT_POINTER_SCROLL_STOP, + EIS_EVENT_SCROLL_STOP, /** * An ongoing scroll sequence was cancelled. */ - EIS_EVENT_POINTER_SCROLL_CANCEL, + EIS_EVENT_SCROLL_CANCEL, /** * A vertical and/or horizontal scroll event with a discrete range in * logical scroll steps, like a scroll wheel. */ - EIS_EVENT_POINTER_SCROLL_DISCRETE, + EIS_EVENT_SCROLL_DISCRETE, /** * A key press or release event @@ -897,24 +899,24 @@ eis_device_pointer_motion_absolute(struct eis_device *device, /** see @ref ei_device_button_button */ void -eis_device_pointer_button(struct eis_device *device, - uint32_t button, bool is_press); +eis_device_button_button(struct eis_device *device, + uint32_t button, bool is_press); /** see @ref ei_device_scroll_delta */ void -eis_device_pointer_scroll(struct eis_device *device, double x, double y); +eis_device_scroll_delta(struct eis_device *device, double x, double y); /** see @ref ei_device_scroll_discrete */ void -eis_device_pointer_scroll_discrete(struct eis_device *device, int32_t x, int32_t y); +eis_device_scroll_discrete(struct eis_device *device, int32_t x, int32_t y); /** see @ref ei_device_scroll_stop */ void -eis_device_pointer_scroll_stop(struct eis_device *device, bool stop_x, bool stop_y); +eis_device_scroll_stop(struct eis_device *device, bool stop_x, bool stop_y); /** see @ref ei_device_scroll_cancel */ void -eis_device_pointer_scroll_cancel(struct eis_device *device, bool cancel_x, bool cancel_y); +eis_device_scroll_cancel(struct eis_device *device, bool cancel_x, bool cancel_y); /** see @ref ei_device_keyboard_key */ void @@ -1025,66 +1027,66 @@ double eis_event_pointer_get_absolute_y(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_BUTTON return the button + * For an event of type @ref EIS_EVENT_BUTTON_BUTTON return the button * code as defined in linux/input-event-codes.h */ uint32_t -eis_event_pointer_get_button(struct eis_event *event); +eis_event_button_get_button(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_BUTTON return true if the + * For an event of type @ref EIS_EVENT_BUTTON_BUTTON return true if the * event is a button press, false for a release. */ bool -eis_event_pointer_get_button_is_press(struct eis_event *event); +eis_event_button_get_is_press(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_DELTA return the x scroll + * For an event of type @ref EIS_EVENT_SCROLL_DELTA return the x scroll * distance in logical pixels or mm, depending on the device type. */ double -eis_event_pointer_get_scroll_x(struct eis_event *event); +eis_event_scroll_get_dx(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_DELTA return the y scroll + * For an event of type @ref EIS_EVENT_SCROLL_DELTA return the y scroll * distance in logical pixels or mm, depending on the device type. */ double -eis_event_pointer_get_scroll_y(struct eis_event *event); +eis_event_scroll_get_dy(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_STOP return whether the + * For an event of type @ref EIS_EVENT_SCROLL_STOP return whether the * x axis has stopped scrolling. * - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_CANCEL return whether the + * For an event of type @ref EIS_EVENT_SCROLL_CANCEL return whether the * x axis has cancelled scrolling. */ bool -eis_event_pointer_get_scroll_stop_x(struct eis_event *event); +eis_event_scroll_get_stop_x(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_STOP return whether the + * For an event of type @ref EIS_EVENT_SCROLL_STOP return whether the * y axis has stopped scrolling. * - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_CANCEL return whether the + * For an event of type @ref EIS_EVENT_SCROLL_CANCEL return whether the * y axis has cancelled scrolling. */ bool -eis_event_pointer_get_scroll_stop_y(struct eis_event *event); +eis_event_scroll_get_stop_y(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_DISCRETE return the x + * For an event of type @ref EIS_EVENT_SCROLL_DISCRETE return the x * scroll distance in fractions or multiples of 120. */ int32_t -eis_event_pointer_get_scroll_discrete_x(struct eis_event *event); +eis_event_scroll_get_discrete_dx(struct eis_event *event); /** - * For an event of type @ref EIS_EVENT_POINTER_SCROLL_DISCRETE return the y + * For an event of type @ref EIS_EVENT_SCROLL_DISCRETE return the y * scroll distance in fractions or multiples of 120. */ int32_t -eis_event_pointer_get_scroll_discrete_y(struct eis_event *event); +eis_event_scroll_get_discrete_dy(struct eis_event *event); /** * For an event of type @ref EIS_EVENT_KEYBOARD_KEY return the key code (as diff --git a/test/eierpecken.c b/test/eierpecken.c index 4801f54..4fbb59c 100644 --- a/test/eierpecken.c +++ b/test/eierpecken.c @@ -58,6 +58,8 @@ struct peck { struct eis_device *eis_pointer; struct eis_device *eis_keyboard; struct eis_device *eis_abs; + struct eis_device *eis_button; + struct eis_device *eis_scroll; struct eis_device *eis_touch; struct ei_seat *ei_seat; @@ -111,6 +113,8 @@ peck_destroy(struct peck *peck) eis_device_unref(peck->eis_abs); eis_device_unref(peck->eis_keyboard); eis_device_unref(peck->eis_touch); + eis_device_unref(peck->eis_button); + eis_device_unref(peck->eis_scroll); eis_seat_unref(peck->eis_seat); ei_device_unref(peck->ei_pointer); @@ -171,6 +175,20 @@ peck_eis_get_default_pointer_absolute(struct peck *peck) return peck->eis_abs; }; +struct eis_device * +peck_eis_get_default_button(struct peck *peck) +{ + munit_assert_ptr_not_null(peck->eis_button); + return peck->eis_button; +}; + +struct eis_device * +peck_eis_get_default_scroll(struct peck *peck) +{ + munit_assert_ptr_not_null(peck->eis_scroll); + return peck->eis_scroll; +}; + struct eis_device * peck_eis_get_default_keyboard(struct peck *peck) { @@ -523,6 +541,8 @@ peck_create_eis_seat(struct peck *peck, struct eis_client *client) eis_seat_configure_capability(seat, EIS_DEVICE_CAP_POINTER_ABSOLUTE); eis_seat_configure_capability(seat, EIS_DEVICE_CAP_KEYBOARD); eis_seat_configure_capability(seat, EIS_DEVICE_CAP_TOUCH); + eis_seat_configure_capability(seat, EIS_DEVICE_CAP_BUTTON); + eis_seat_configure_capability(seat, EIS_DEVICE_CAP_SCROLL); log_debug(peck, "EIS adding seat: '%s'\n", eis_seat_get_name(seat)); eis_seat_add(seat); @@ -554,6 +574,8 @@ peck_eis_create_pointer(struct peck *peck, struct eis_seat *seat, const char *na eis_device_configure_name(device, name); eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER); + eis_device_configure_capability(device, EIS_DEVICE_CAP_BUTTON); + eis_device_configure_capability(device, EIS_DEVICE_CAP_SCROLL); eis_device_add(device); return device; @@ -570,6 +592,8 @@ peck_eis_create_pointer_absolute(struct peck *peck, struct eis_seat *seat, const eis_device_configure_name(device, name); eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE); + eis_device_configure_capability(device, EIS_DEVICE_CAP_BUTTON); + eis_device_configure_capability(device, EIS_DEVICE_CAP_SCROLL); eis_region_add(region); eis_device_add(device); @@ -692,6 +716,8 @@ peck_handle_eis_seat_bind(struct peck *peck, struct eis_event *e) if (!eis_event_seat_has_capability(e, EIS_DEVICE_CAP_POINTER) && !eis_event_seat_has_capability(e, EIS_DEVICE_CAP_POINTER_ABSOLUTE) && !eis_event_seat_has_capability(e, EIS_DEVICE_CAP_KEYBOARD) && + !eis_event_seat_has_capability(e, EIS_DEVICE_CAP_BUTTON) && + !eis_event_seat_has_capability(e, EIS_DEVICE_CAP_SCROLL) && !eis_event_seat_has_capability(e, EIS_DEVICE_CAP_TOUCH)) eis_seat_remove(seat); } @@ -708,6 +734,10 @@ peck_eis_device_remove(struct peck *peck, struct eis_device *device) peck->eis_keyboard = eis_device_unref(device); if (device == peck->eis_touch) peck->eis_touch = eis_device_unref(device); + if (device == peck->eis_button) + peck->eis_button = eis_device_unref(device); + if (device == peck->eis_scroll) + peck->eis_scroll = eis_device_unref(device); } bool @@ -765,11 +795,11 @@ _peck_dispatch_eis(struct peck *peck, int lineno) break; case EIS_EVENT_POINTER_MOTION: case EIS_EVENT_POINTER_MOTION_ABSOLUTE: - case EIS_EVENT_POINTER_BUTTON: - case EIS_EVENT_POINTER_SCROLL_DELTA: - case EIS_EVENT_POINTER_SCROLL_STOP: - case EIS_EVENT_POINTER_SCROLL_CANCEL: - case EIS_EVENT_POINTER_SCROLL_DISCRETE: + case EIS_EVENT_BUTTON_BUTTON: + case EIS_EVENT_SCROLL_DELTA: + case EIS_EVENT_SCROLL_STOP: + case EIS_EVENT_SCROLL_CANCEL: + case EIS_EVENT_SCROLL_DISCRETE: case EIS_EVENT_KEYBOARD_KEY: case EIS_EVENT_TOUCH_DOWN: case EIS_EVENT_TOUCH_UP: @@ -1256,11 +1286,11 @@ peck_eis_event_type_name(enum eis_event_type type) CASE_STRING(DEVICE_STOP_EMULATING); CASE_STRING(POINTER_MOTION); CASE_STRING(POINTER_MOTION_ABSOLUTE); - CASE_STRING(POINTER_BUTTON); - CASE_STRING(POINTER_SCROLL_DELTA); - CASE_STRING(POINTER_SCROLL_STOP); - CASE_STRING(POINTER_SCROLL_CANCEL); - CASE_STRING(POINTER_SCROLL_DISCRETE); + CASE_STRING(BUTTON_BUTTON); + CASE_STRING(SCROLL_DELTA); + CASE_STRING(SCROLL_STOP); + CASE_STRING(SCROLL_CANCEL); + CASE_STRING(SCROLL_DISCRETE); CASE_STRING(KEYBOARD_KEY); CASE_STRING(TOUCH_DOWN); CASE_STRING(TOUCH_UP); diff --git a/test/eierpecken.h b/test/eierpecken.h index 1d9731c..406b816 100644 --- a/test/eierpecken.h +++ b/test/eierpecken.h @@ -185,6 +185,12 @@ peck_eis_get_default_pointer_absolute(struct peck *peck); struct eis_device * peck_eis_get_default_touch(struct peck *peck); +struct eis_device * +peck_eis_get_default_button(struct peck *peck); + +struct eis_device * +peck_eis_get_default_scroll(struct peck *peck); + struct ei_seat * peck_ei_get_default_seat(struct peck *peck); diff --git a/test/test-ei-device.c b/test/test-ei-device.c index 2a7b48f..c0a99e9 100644 --- a/test/test-ei-device.c +++ b/test/test-ei-device.c @@ -580,14 +580,14 @@ MUNIT_TEST(test_ei_device_scroll) with_server(peck) { _unref_(eis_event) *first = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); - munit_assert_double_equal(eis_event_pointer_get_scroll_x(first), 1.1, 2 /* precision */); - munit_assert_double_equal(eis_event_pointer_get_scroll_y(first), 2.2, 2 /* precision */); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); + munit_assert_double_equal(eis_event_scroll_get_dx(first), 1.1, 2 /* precision */); + munit_assert_double_equal(eis_event_scroll_get_dy(first), 2.2, 2 /* precision */); _unref_(eis_event) *second = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DISCRETE); - munit_assert_int(eis_event_pointer_get_scroll_discrete_x(second), ==, 3); - munit_assert_int(eis_event_pointer_get_scroll_discrete_y(second), ==, 4); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DISCRETE); + munit_assert_int(eis_event_scroll_get_discrete_dx(second), ==, 3); + munit_assert_int(eis_event_scroll_get_discrete_dy(second), ==, 4); } return MUNIT_OK; @@ -631,30 +631,30 @@ MUNIT_TEST(test_ei_device_scroll_stop) with_server(peck) { _unref_(eis_event) *scroll = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); _unref_(eis_event) *first = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_STOP); - munit_assert(eis_event_pointer_get_scroll_stop_x(first)); - munit_assert(!eis_event_pointer_get_scroll_stop_y(first)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_STOP); + munit_assert(eis_event_scroll_get_stop_x(first)); + munit_assert(!eis_event_scroll_get_stop_y(first)); _unref_(eis_event) *second = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_STOP); - munit_assert(!eis_event_pointer_get_scroll_stop_x(second)); - munit_assert(eis_event_pointer_get_scroll_stop_y(second)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_STOP); + munit_assert(!eis_event_scroll_get_stop_x(second)); + munit_assert(eis_event_scroll_get_stop_y(second)); /* third one doesn't trigger an event */ _unref_(eis_event) *again = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); _unref_(eis_event) *fourth = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_STOP); - munit_assert(eis_event_pointer_get_scroll_stop_x(fourth)); - munit_assert(eis_event_pointer_get_scroll_stop_y(fourth)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_STOP); + munit_assert(eis_event_scroll_get_stop_x(fourth)); + munit_assert(eis_event_scroll_get_stop_y(fourth)); _unref_(eis_event) *again_again = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); peck_assert_no_eis_events(eis); } @@ -700,30 +700,30 @@ MUNIT_TEST(test_ei_device_scroll_cancel) with_server(peck) { _unref_(eis_event) *scroll = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); _unref_(eis_event) *first = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_CANCEL); - munit_assert(eis_event_pointer_get_scroll_stop_x(first)); - munit_assert(!eis_event_pointer_get_scroll_stop_y(first)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_CANCEL); + munit_assert(eis_event_scroll_get_stop_x(first)); + munit_assert(!eis_event_scroll_get_stop_y(first)); _unref_(eis_event) *second = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_CANCEL); - munit_assert(!eis_event_pointer_get_scroll_stop_x(second)); - munit_assert(eis_event_pointer_get_scroll_stop_y(second)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_CANCEL); + munit_assert(!eis_event_scroll_get_stop_x(second)); + munit_assert(eis_event_scroll_get_stop_y(second)); /* third one doesn't trigger an event */ _unref_(eis_event) *again = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); _unref_(eis_event) *fourth = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_CANCEL); - munit_assert(eis_event_pointer_get_scroll_stop_x(fourth)); - munit_assert(eis_event_pointer_get_scroll_stop_y(fourth)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_CANCEL); + munit_assert(eis_event_scroll_get_stop_x(fourth)); + munit_assert(eis_event_scroll_get_stop_y(fourth)); _unref_(eis_event) *again_again = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); peck_assert_no_eis_events(eis); } @@ -761,22 +761,22 @@ MUNIT_TEST(test_ei_device_scroll_stop_cancel) with_server(peck) { _unref_(eis_event) *scroll = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_DELTA); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_DELTA); _unref_(eis_event) *stop = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_STOP); - munit_assert(eis_event_pointer_get_scroll_stop_x(stop)); - munit_assert(!eis_event_pointer_get_scroll_stop_y(stop)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_STOP); + munit_assert(eis_event_scroll_get_stop_x(stop)); + munit_assert(!eis_event_scroll_get_stop_y(stop)); _unref_(eis_event) *first = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_CANCEL); - munit_assert(eis_event_pointer_get_scroll_stop_x(first)); - munit_assert(!eis_event_pointer_get_scroll_stop_y(first)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_CANCEL); + munit_assert(eis_event_scroll_get_stop_x(first)); + munit_assert(!eis_event_scroll_get_stop_y(first)); _unref_(eis_event) *second = - peck_eis_next_event(eis, EIS_EVENT_POINTER_SCROLL_CANCEL); - munit_assert(!eis_event_pointer_get_scroll_stop_x(second)); - munit_assert(eis_event_pointer_get_scroll_stop_y(second)); + peck_eis_next_event(eis, EIS_EVENT_SCROLL_CANCEL); + munit_assert(!eis_event_scroll_get_stop_x(second)); + munit_assert(eis_event_scroll_get_stop_y(second)); /* third one doesn't trigger an event */ peck_assert_no_eis_events(eis); @@ -1660,9 +1660,9 @@ MUNIT_TEST(test_passive_ei_device_scroll_delta) with_server(peck) { struct eis_device *device = peck_eis_get_default_pointer(peck); - eis_device_pointer_scroll(device, 1.1, 2.2); + eis_device_scroll_delta(device, 1.1, 2.2); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_discrete(device, 3, 4); + eis_device_scroll_discrete(device, 3, 4); eis_device_frame(device, peck_eis_now(peck)); } @@ -1710,26 +1710,26 @@ MUNIT_TEST(test_passive_ei_device_scroll_stop) with_server(peck) { struct eis_device *device = peck_eis_get_default_pointer(peck); - eis_device_pointer_scroll(device, 1.1, 2.2); + eis_device_scroll_delta(device, 1.1, 2.2); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_stop(device, true, false); + eis_device_scroll_stop(device, true, false); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_stop(device, false, true); + eis_device_scroll_stop(device, false, true); eis_device_frame(device, peck_eis_now(peck)); /* This should not generate an event */ - eis_device_pointer_scroll_stop(device, true, true); + eis_device_scroll_stop(device, true, true); eis_device_frame(device, peck_eis_now(peck)); /* But scrolling again will re-enable stopping */ - eis_device_pointer_scroll(device, 3.3, 4.4); + eis_device_scroll_delta(device, 3.3, 4.4); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_stop(device, true, true); + eis_device_scroll_stop(device, true, true); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll(device, 3.3, 4.4); + eis_device_scroll_delta(device, 3.3, 4.4); /* This one is a client bug and shouldn't trigger an event */ - eis_device_pointer_scroll_stop(device, false, false); + eis_device_scroll_stop(device, false, false); eis_device_frame(device, peck_eis_now(peck)); } @@ -1795,26 +1795,26 @@ MUNIT_TEST(test_passive_ei_device_scroll_cancel) with_server(peck) { struct eis_device *device = peck_eis_get_default_pointer(peck); - eis_device_pointer_scroll(device, 1.1, 2.2); + eis_device_scroll_delta(device, 1.1, 2.2); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_cancel(device, true, false); + eis_device_scroll_cancel(device, true, false); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_cancel(device, false, true); + eis_device_scroll_cancel(device, false, true); eis_device_frame(device, peck_eis_now(peck)); /* This should not generate an event */ - eis_device_pointer_scroll_cancel(device, true, true); + eis_device_scroll_cancel(device, true, true); eis_device_frame(device, peck_eis_now(peck)); /* But scrolling again will re-enable stopping */ - eis_device_pointer_scroll(device, 3.3, 4.4); + eis_device_scroll_delta(device, 3.3, 4.4); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_cancel(device, true, true); + eis_device_scroll_cancel(device, true, true); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll(device, 3.3, 4.4); + eis_device_scroll_delta(device, 3.3, 4.4); /* This one is a client bug and shouldn't trigger an event */ - eis_device_pointer_scroll_cancel(device, false, false); + eis_device_scroll_cancel(device, false, false); eis_device_frame(device, peck_eis_now(peck)); } @@ -1881,21 +1881,21 @@ MUNIT_TEST(test_passive_ei_device_scroll_stop_cancel) /* cancel after stop is fine, stop after cancel is ignored */ with_server(peck) { struct eis_device *device = peck_eis_get_default_pointer(peck); - eis_device_pointer_scroll(device, 1.1, 2.2); + eis_device_scroll_delta(device, 1.1, 2.2); eis_device_frame(device, peck_eis_now(peck)); peck_mark(peck); - eis_device_pointer_scroll_stop(device, true, false); + eis_device_scroll_stop(device, true, false); peck_mark(peck); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_cancel(device, true, false); + eis_device_scroll_cancel(device, true, false); peck_mark(peck); eis_device_frame(device, peck_eis_now(peck)); - eis_device_pointer_scroll_cancel(device, false, true); + eis_device_scroll_cancel(device, false, true); eis_device_frame(device, peck_eis_now(peck)); peck_mark(peck); /* This should not generate an event */ - eis_device_pointer_scroll_stop(device, true, true); + eis_device_scroll_stop(device, true, true); eis_device_frame(device, peck_eis_now(peck)); } diff --git a/tools/eis-demo-server-uinput.c b/tools/eis-demo-server-uinput.c index af3a1f8..c86ab1e 100644 --- a/tools/eis-demo-server-uinput.c +++ b/tools/eis-demo-server-uinput.c @@ -72,6 +72,8 @@ create_mouse(struct eis_demo_server *server, struct eis_seat *seat, eis_device_configure_name(device, devicename); eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER); + eis_device_configure_capability(device, EIS_DEVICE_CAP_BUTTON); + eis_device_configure_capability(device, EIS_DEVICE_CAP_SCROLL); _cleanup_libevdev_ struct libevdev *dev = libevdev_new(); libevdev_set_name(dev, devicename); @@ -137,6 +139,8 @@ eis_demo_server_uinput_handle_event(struct eis_demo_server *server, eis_seat_configure_capability(seat, EIS_DEVICE_CAP_POINTER_ABSOLUTE); eis_seat_configure_capability(seat, EIS_DEVICE_CAP_KEYBOARD); eis_seat_configure_capability(seat, EIS_DEVICE_CAP_TOUCH); + eis_seat_configure_capability(seat, EIS_DEVICE_CAP_BUTTON); + eis_seat_configure_capability(seat, EIS_DEVICE_CAP_SCROLL); eis_seat_add(seat); break; } @@ -203,11 +207,11 @@ eis_demo_server_uinput_handle_event(struct eis_demo_server *server, } } break; - case EIS_EVENT_POINTER_BUTTON: + case EIS_EVENT_BUTTON_BUTTON: { struct eis_device *device = eis_event_get_device(e); - uint32_t button = eis_event_pointer_get_button(e); - bool state = eis_event_pointer_get_button_is_press(e); + uint32_t button = eis_event_button_get_button(e); + bool state = eis_event_button_get_is_press(e); colorprint("%s %s\n", libevdev_event_code_get_name(EV_KEY, button), state ? "press" : "release"); diff --git a/tools/eis-demo-server.c b/tools/eis-demo-server.c index 7d8e299..4415314 100644 --- a/tools/eis-demo-server.c +++ b/tools/eis-demo-server.c @@ -257,6 +257,8 @@ add_device(struct eis_demo_server *server, struct eis_client *client, struct eis_device *ptr = eis_seat_new_device(seat); eis_device_configure_name(ptr, "test pointer"); eis_device_configure_capability(ptr, EIS_DEVICE_CAP_POINTER); + eis_device_configure_capability(ptr, EIS_DEVICE_CAP_BUTTON); + eis_device_configure_capability(ptr, EIS_DEVICE_CAP_SCROLL); _unref_(eis_region) *rel_region = eis_device_new_region(ptr); eis_region_set_size(rel_region, 1920, 1080); eis_region_set_offset(rel_region, 0, 0); @@ -275,6 +277,8 @@ add_device(struct eis_demo_server *server, struct eis_client *client, struct eis_device *abs = eis_seat_new_device(seat); eis_device_configure_name(abs, "test abs pointer"); eis_device_configure_capability(abs, EIS_DEVICE_CAP_POINTER_ABSOLUTE); + eis_device_configure_capability(abs, EIS_DEVICE_CAP_BUTTON); + eis_device_configure_capability(abs, EIS_DEVICE_CAP_SCROLL); _unref_(eis_region) *region = eis_device_new_region(abs); eis_region_set_size(region, 1920, 1080); eis_region_set_offset(region, 0, 0); @@ -318,6 +322,10 @@ add_device(struct eis_demo_server *server, struct eis_client *client, device = steal(&touchscreen); break; } + case EIS_DEVICE_CAP_BUTTON: + case EIS_DEVICE_CAP_SCROLL: + /* Mixed in with pointer/abs - good enough for a demo server */ + break; } return device; @@ -473,25 +481,25 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server, eis_event_pointer_get_absolute_y(e)); } break; - case EIS_EVENT_POINTER_BUTTON: + case EIS_EVENT_BUTTON_BUTTON: { colorprint("button %u (%s)\n", - eis_event_pointer_get_button(e), - eis_event_pointer_get_button_is_press(e) ? "press" : "release"); + eis_event_button_get_button(e), + eis_event_button_get_is_press(e) ? "press" : "release"); } break; - case EIS_EVENT_POINTER_SCROLL_DELTA: + case EIS_EVENT_SCROLL_DELTA: { colorprint("scroll %.2f/%.2f\n", - eis_event_pointer_get_scroll_x(e), - eis_event_pointer_get_scroll_y(e)); + eis_event_scroll_get_dx(e), + eis_event_scroll_get_dy(e)); } break; - case EIS_EVENT_POINTER_SCROLL_DISCRETE: + case EIS_EVENT_SCROLL_DISCRETE: { colorprint("scroll discrete %d/%d\n", - eis_event_pointer_get_scroll_discrete_x(e), - eis_event_pointer_get_scroll_discrete_y(e)); + eis_event_scroll_get_discrete_dx(e), + eis_event_scroll_get_discrete_dy(e)); } break; case EIS_EVENT_KEYBOARD_KEY: @@ -680,17 +688,17 @@ int main(int argc, char **argv) eis_device_pointer_motion(ptr, -1, 1); /* BTN_LEFT */ colorprint("sending button event\n"); - eis_device_pointer_button(ptr, BTN_LEFT, true); + eis_device_button_button(ptr, BTN_LEFT, true); eis_device_frame(ptr, now); now += interval; - eis_device_pointer_button(ptr, BTN_LEFT, false); + eis_device_button_button(ptr, BTN_LEFT, false); eis_device_frame(ptr, now); now += interval; colorprint("sending scroll events\n"); - eis_device_pointer_scroll(ptr, 1, 1); + eis_device_scroll_delta(ptr, 1, 1); eis_device_frame(ptr, now); now += interval; - eis_device_pointer_scroll_discrete(ptr, 1, 1); + eis_device_scroll_discrete(ptr, 1, 1); eis_device_frame(ptr, now); now += interval; }