Pass Ctrl-C to the emulator.

Use F2 to leave.


Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2017-06-04 19:05:14 +01:00
parent 97e672cf4d
commit 2b60a1e0a7
3 changed files with 35 additions and 8 deletions

View file

@ -14,8 +14,9 @@
#include "Video.h"
#include "frontends/ncurses/world.h"
#include "ncurses.h"
static void ContinueExecution()
static bool ContinueExecution()
{
const auto start = std::chrono::steady_clock::now();
@ -37,7 +38,14 @@ static void ContinueExecution()
DiskUpdatePosition(uActualCyclesExecuted);
ProcessKeyboard();
const int key = ProcessKeyboard();
switch (key)
{
case KEY_F(2):
return false;
}
if (g_dwCyclesThisFrame >= dwClksPerFrame)
{
g_dwCyclesThisFrame -= dwClksPerFrame;
@ -55,13 +63,14 @@ static void ContinueExecution()
usleep(nExecutionPeriodUsec - ms);
}
}
return true;
}
void EnterMessageLoop()
{
while (true)
while (ContinueExecution())
{
ContinueExecution();
}
}
@ -126,6 +135,9 @@ void foo(int argc, const char * argv [])
EnterMessageLoop();
}
while (g_bRestart);
VideoUninitialize();
}
int main(int argc, const char * argv [])

View file

@ -62,8 +62,11 @@ namespace
void sig_handler(int signo)
{
endwin();
exit(1);
// Ctrl-C
// is there a race condition here?
// is it a problem?
nextKey = 0x83;
keyReady = true;
}
chtype mapCharacter(BYTE ch)
@ -358,6 +361,11 @@ void VideoInitialize()
signal(SIGINT, sig_handler);
}
void VideoUninitialize()
{
endwin();
}
void VideoRedrawScreen()
{
@ -419,7 +427,7 @@ void VideoRedrawScreen()
wrefresh(frame->getWindow());
}
void ProcessKeyboard()
int ProcessKeyboard()
{
const int inch = wgetch(frame->getWindow());
@ -474,6 +482,12 @@ void ProcessKeyboard()
{
nextKey = ch | 0x80;
keyReady = true;
return ERR;
}
else
{
// pass it back
return inch;
}
}

View file

@ -1,5 +1,6 @@
#pragma once
void ProcessKeyboard();
int ProcessKeyboard();
void VideoInitialize();
void VideoUninitialize();
void VideoRedrawScreen();