summaryrefslogtreecommitdiff
path: root/tests/cocoa/test_tablet.m
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cocoa/test_tablet.m')
-rw-r--r--tests/cocoa/test_tablet.m42
1 files changed, 21 insertions, 21 deletions
diff --git a/tests/cocoa/test_tablet.m b/tests/cocoa/test_tablet.m
index ed6dc64..715a66e 100644
--- a/tests/cocoa/test_tablet.m
+++ b/tests/cocoa/test_tablet.m
@@ -35,13 +35,13 @@
}
@end
-static struct yasl_mouse_event next(struct yasl_surface *surface)
+static struct yasl_event next(struct yasl_surface *surface)
{
- struct yasl_input_event event;
- while (yasl_surface_input_poll(surface, &event))
- if (event.kind == YASL_INPUT_MOUSE) return event.mouse;
+ struct yasl_event event;
+ while (yasl_surface_poll_event(surface, &event))
+ return event;
assert(!"Expected a pointer event");
- return (struct yasl_mouse_event){0};
+ return (struct yasl_event){0};
}
int main(void)
@@ -54,8 +54,8 @@ int main(void)
assert(surface);
NSWindow *window = (NSWindow *)yasl_surface_get_native_handle(surface);
NSView *view = window.contentView;
- struct yasl_input_event event;
- while (yasl_surface_input_poll(surface, &event)) {}
+ struct yasl_event event;
+ while (yasl_surface_poll_event(surface, &event)) {}
TabletSample *sample = [TabletSample new];
NSEvent *native = (NSEvent *)sample;
sample.type = NSEventTypeTabletProximity;
@@ -67,16 +67,16 @@ int main(void)
sample.locationInWindow = NSMakePoint(100, 120);
sample.sampleTilt = NSMakePoint(-0.5, 0.5);
[view mouseMoved:native];
- struct yasl_mouse_event ev = next(surface);
- assert(ev.device == YASL_PTR_DEV_PEN && ev.kind == YASL_PTR_MOTION && !ev.pen.pressure);
- assert(ev.pen.tilt_x == -45 && ev.pen.tilt_y == -45);
+ struct yasl_event ev = next(surface);
+ assert(ev.pointer.device == YASL_PTR_DEV_PEN && ev.type == YASL_EVENT_POINTER_MOTION && !ev.pointer.pen.pressure);
+ assert(ev.pointer.pen.tilt_x == -45 && ev.pointer.pen.tilt_y == -45);
sample.type = NSEventTypeLeftMouseDown;
sample.samplePressure = 0.5;
[view mouseDown:native];
ev = next(surface);
- assert(ev.device == YASL_PTR_DEV_PEN && ev.kind == YASL_PTR_PRESS && ev.button == 0);
- assert(ev.pen.pressure == 32767);
- struct yasl_vector2i position = ev.pos;
+ assert(ev.pointer.device == YASL_PTR_DEV_PEN && ev.type == YASL_EVENT_POINTER_DOWN && ev.pointer.button == YASL_BUTTON_PRIMARY);
+ assert(ev.pointer.pen.pressure == 32767);
+ struct yasl_vector2i position = ev.pointer.pos;
/* Native tablet events cover stationary pressure changes. */
sample.type = NSEventTypeTabletPoint;
sample.subtype = NSEventSubtypeMouseEvent;
@@ -84,19 +84,19 @@ int main(void)
sample.samplePressure = 1.5;
[view tabletPoint:native];
ev = next(surface);
- assert(ev.kind == YASL_PTR_MOTION && ev.pen.pressure == 65535);
- assert(ev.pos.x == position.x && ev.pos.y == position.y);
+ assert(ev.type == YASL_EVENT_POINTER_MOTION && ev.pointer.pen.pressure == 65535);
+ assert(ev.pointer.pos.x == position.x && ev.pointer.pos.y == position.y);
sample.samplePressure = 0; /* Zero does not release a held tip button. */
[view tabletPoint:native];
- assert(next(surface).kind == YASL_PTR_MOTION);
+ assert(next(surface).type == YASL_EVENT_POINTER_MOTION);
sample.buttonMask = 0;
[view tabletPoint:native];
ev = next(surface);
- assert(ev.kind == YASL_PTR_RELEASE && !ev.pen.pressure && ev.device == YASL_PTR_DEV_PEN);
+ assert(ev.type == YASL_EVENT_POINTER_UP && !ev.pointer.pen.pressure && ev.pointer.device == YASL_PTR_DEV_PEN);
sample.type = NSEventTypeTabletProximity;
sample.enteringProximity = NO;
[view tabletProximity:native];
- assert(next(surface).kind == YASL_PTR_LEAVE);
+ assert(next(surface).type == YASL_EVENT_POINTER_LEAVE);
sample.enteringProximity = YES;
sample.tool = NSPointingDeviceTypeEraser;
[view tabletProximity:native];
@@ -105,16 +105,16 @@ int main(void)
sample.buttonMask = NSEventButtonMaskPenTip;
[view tabletPoint:native];
ev = next(surface);
- assert(ev.device == YASL_PTR_DEV_ERASER && ev.kind == YASL_PTR_PRESS && ev.pen.pressure > 0);
+ assert(ev.pointer.device == YASL_PTR_DEV_ERASER && ev.type == YASL_EVENT_POINTER_DOWN && ev.pointer.pen.pressure > 0);
sample.type = NSEventTypeTabletProximity;
sample.enteringProximity = NO;
[view tabletProximity:native];
ev = next(surface);
- assert(ev.device == YASL_PTR_DEV_ERASER && ev.kind == YASL_PTR_LEAVE && !ev.pen.pressure);
+ assert(ev.pointer.device == YASL_PTR_DEV_ERASER && ev.type == YASL_EVENT_POINTER_LEAVE && !ev.pointer.pen.pressure);
sample.type = NSEventTypeMouseMoved;
[view mouseMoved:native];
ev = next(surface);
- assert(ev.device == YASL_PTR_DEV_MOUSE && !ev.pen.pressure);
+ assert(ev.pointer.device == YASL_PTR_DEV_MOUSE && !ev.pointer.pen.pressure);
[sample release];
yasl_surface_destroy(surface);
yasl_display_close(display);