feat(ui): add timeout for gui spinloop
This commit is contained in:
parent
21295b8d03
commit
2b9a479b96
|
@ -134,6 +134,7 @@ pub const Gui = struct {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
SDL.SDL_QUIT => break :emu_loop,
|
SDL.SDL_QUIT => break :emu_loop,
|
||||||
SDL.SDL_KEYDOWN => {
|
SDL.SDL_KEYDOWN => {
|
||||||
|
// TODO: Make use of compare_and_xor?
|
||||||
const key_code = event.key.keysym.sym;
|
const key_code = event.key.keysym.sym;
|
||||||
var keyinput = cpu.bus.io.keyinput.load(.Monotonic);
|
var keyinput = cpu.bus.io.keyinput.load(.Monotonic);
|
||||||
|
|
||||||
|
@ -154,6 +155,7 @@ pub const Gui = struct {
|
||||||
cpu.bus.io.keyinput.store(keyinput.raw, .Monotonic);
|
cpu.bus.io.keyinput.store(keyinput.raw, .Monotonic);
|
||||||
},
|
},
|
||||||
SDL.SDL_KEYUP => {
|
SDL.SDL_KEYUP => {
|
||||||
|
// TODO: Make use of compare_and_xor?
|
||||||
const key_code = event.key.keysym.sym;
|
const key_code = event.key.keysym.sym;
|
||||||
var keyinput = cpu.bus.io.keyinput.load(.Monotonic);
|
var keyinput = cpu.bus.io.keyinput.load(.Monotonic);
|
||||||
|
|
||||||
|
@ -204,19 +206,27 @@ pub const Gui = struct {
|
||||||
self.state.emulation = .Inactive;
|
self.state.emulation = .Inactive;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.Active => {
|
.Active => skip_draw: {
|
||||||
const is_std = mode == .Standard;
|
const is_std = mode == .Standard;
|
||||||
|
|
||||||
if (is_std) channel.emu.push(.Pause);
|
if (is_std) channel.emu.push(.Pause);
|
||||||
defer if (is_std) channel.emu.push(.Resume);
|
defer if (is_std) channel.emu.push(.Resume);
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
.Standard => {
|
.Standard => blk: {
|
||||||
// TODO: add timeout
|
const limit = 15; // TODO: What should this be?
|
||||||
while (true) switch (channel.gui.pop() orelse continue) {
|
|
||||||
.Paused => break,
|
for (0..limit) |_| {
|
||||||
.Quit => unreachable, // only signaled in debug mode
|
const message = channel.gui.pop() orelse continue;
|
||||||
};
|
|
||||||
|
switch (message) {
|
||||||
|
.Paused => break :blk,
|
||||||
|
.Quit => unreachable,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("timed out waiting for emu thread to pause (limit: {})", .{limit});
|
||||||
|
break :skip_draw;
|
||||||
},
|
},
|
||||||
.Debug => blk: {
|
.Debug => blk: {
|
||||||
switch (channel.gui.pop() orelse break :blk) {
|
switch (channel.gui.pop() orelse break :blk) {
|
||||||
|
|
Loading…
Reference in New Issue