diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 15:05:06 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 15:05:06 +0300 |
| commit | 98f0d51157fa2a2b8ccaae54ed4850a88d223d01 (patch) | |
| tree | 90b03d0930986620d95eb0f45c07b96e1331783c /tests/common/test_tablet_example.c | |
| parent | 339e1ad7adb8340732ee856d0f6f0d2c7f1455d1 (diff) | |
Simplify surface state, examples, and library installation
Diffstat (limited to 'tests/common/test_tablet_example.c')
| -rw-r--r-- | tests/common/test_tablet_example.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/common/test_tablet_example.c b/tests/common/test_tablet_example.c index 15dde9c..77e79f6 100644 --- a/tests/common/test_tablet_example.c +++ b/tests/common/test_tablet_example.c @@ -6,8 +6,20 @@ static void pointer(struct app *app, enum yasl_pointer_kind kind, enum yasl_pointer_device device, int button, int x, int y, uint16_t pressure) { - struct yasl_input_event event = {.kind = YASL_INPUT_MOUSE, .mouse = { - .kind = kind, .device = device, .button = button, .pos = {x, y}, .pen.pressure = pressure}}; + struct yasl_event event = {0}; + if (kind == YASL_PTR_MOTION) { + event.type = YASL_EVENT_MOUSE_MOTION; + event.mouse_motion.pos = (struct yasl_vector2i){x, y}; + event.mouse_motion.device = device; + event.mouse_motion.pen.pressure = pressure; + } else { + event.type = YASL_EVENT_MOUSE_BUTTON; + event.mouse_button.pos = (struct yasl_vector2i){x, y}; + event.mouse_button.device = device; + event.mouse_button.button = button; + event.mouse_button.pressed = kind == YASL_PTR_PRESS; + event.mouse_button.pen.pressure = pressure; + } input(app, &event); } @@ -38,13 +50,13 @@ int main(void) pointer(&app, YASL_PTR_PRESS, YASL_PTR_DEV_ERASER, 0, 80, 160, 65535); assert(app.canvas[(size_t)160 * app.geometry.size.x + 80] == PAPER && app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK); - struct yasl_input_event reset = {.kind = YASL_INPUT_RESET}; + struct yasl_event reset = {.type = YASL_EVENT_INPUT_RESET}; input(&app, &reset); pointer(&app, YASL_PTR_MOTION, YASL_PTR_DEV_ERASER, 0, 130, 160, 65535); assert(!app.down && app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK); pointer(&app, YASL_PTR_PRESS, YASL_PTR_DEV_MOUSE, 0, 300, 200, 0); assert(app.canvas[(size_t)200 * app.geometry.size.x + 300] == INK); - struct yasl_input_event blur = {.kind = YASL_INPUT_FOCUS, .focus.focused = false}; + struct yasl_event blur = {.type = YASL_EVENT_WINDOW_FOCUS, .focus.focused = false}; input(&app, &blur); assert(!app.down); assert(resize_canvas(&app, (struct yasl_geometry){{800, 600}, 240})); |
