core: centralize EventQueue and EventIterator declaration
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
1fab277bf7
commit
2eac60caf1
4 changed files with 17 additions and 43 deletions
|
|
@ -19,21 +19,12 @@ const objc = @import("objc");
|
|||
|
||||
const log = std.log.scoped(.mach);
|
||||
|
||||
const EventQueue = std.fifo.LinearFifo(Event, .Dynamic);
|
||||
pub const EventIterator = struct {
|
||||
queue: *EventQueue,
|
||||
|
||||
pub inline fn next(self: *EventIterator) ?Event {
|
||||
return self.queue.readItem();
|
||||
}
|
||||
};
|
||||
|
||||
pub const Darwin = @This();
|
||||
|
||||
allocator: std.mem.Allocator,
|
||||
core: *Core,
|
||||
|
||||
events: EventQueue,
|
||||
events: Core.EventQueue,
|
||||
input_state: Core.InputState,
|
||||
// modifiers: KeyMods,
|
||||
|
||||
|
|
@ -148,8 +139,8 @@ pub fn update(_: *Darwin) !void {
|
|||
}
|
||||
|
||||
// May be called from any thread.
|
||||
pub inline fn pollEvents(n: *Darwin) EventIterator {
|
||||
return EventIterator{ .queue = &n.events };
|
||||
pub inline fn pollEvents(n: *Darwin) Core.EventIterator {
|
||||
return .{ .queue = &n.events };
|
||||
}
|
||||
|
||||
// May be called from any thread.
|
||||
|
|
|
|||
|
|
@ -21,21 +21,12 @@ const KeyMods = Core.KeyMods;
|
|||
|
||||
const log = std.log.scoped(.mach);
|
||||
|
||||
const EventQueue = std.fifo.LinearFifo(Event, .Dynamic);
|
||||
pub const EventIterator = struct {
|
||||
queue: *EventQueue,
|
||||
|
||||
pub inline fn next(self: *EventIterator) ?Event {
|
||||
return self.queue.readItem();
|
||||
}
|
||||
};
|
||||
|
||||
pub const Null = @This();
|
||||
|
||||
allocator: std.mem.Allocator,
|
||||
core: *Core,
|
||||
|
||||
events: EventQueue,
|
||||
events: Core.EventQueue,
|
||||
input_state: Core.InputState,
|
||||
modifiers: KeyMods,
|
||||
|
||||
|
|
@ -65,8 +56,8 @@ pub fn update(_: *Null) !void {
|
|||
}
|
||||
|
||||
// May be called from any thread.
|
||||
pub inline fn pollEvents(n: *Null) EventIterator {
|
||||
return EventIterator{ .queue = &n.events };
|
||||
pub inline fn pollEvents(n: *Null) Core.EventIterator {
|
||||
return .{ .queue = &n.events };
|
||||
}
|
||||
|
||||
// May be called from any thread.
|
||||
|
|
|
|||
|
|
@ -151,14 +151,6 @@ pub fn update(self: *Win32) !void {
|
|||
}
|
||||
}
|
||||
|
||||
pub const EventIterator = struct {
|
||||
queue: *EventQueue,
|
||||
|
||||
pub fn next(self: *EventIterator) ?Event {
|
||||
return self.queue.readItem();
|
||||
}
|
||||
};
|
||||
|
||||
pub fn pollEvents(self: *Win32) EventIterator {
|
||||
return .{ .queue = &self.events };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue