Single keyboard handler.
Seems to work... Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
84332ada39
commit
874f4be666
5 changed files with 57 additions and 52 deletions
|
@ -41,6 +41,7 @@ add_library(appleii SHARED
|
|||
linux/paddle.cpp
|
||||
linux/version.cpp
|
||||
linux/registry.cpp
|
||||
linux/keyboard.cpp
|
||||
|
||||
linux/duplicates/Video.cpp
|
||||
linux/duplicates/Mockingboard.cpp
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "linux/interface.h"
|
||||
#include "linux/paddle.h"
|
||||
#include "linux/data.h"
|
||||
#include "linux/keyboard.h"
|
||||
|
||||
#include "frontends/ncurses/nframe.h"
|
||||
#include "frontends/ncurses/colors.h"
|
||||
|
@ -54,9 +55,6 @@ namespace
|
|||
#define SW_PAGE2 (g_uVideoMode & VF_PAGE2)
|
||||
#define SW_TEXT (g_uVideoMode & VF_TEXT)
|
||||
|
||||
BYTE nextKey = 0;
|
||||
bool keyReady = false;
|
||||
|
||||
bool g_bTextFlashState = false;
|
||||
|
||||
double alpha = 10.0;
|
||||
|
@ -67,8 +65,7 @@ namespace
|
|||
// Ctrl-C
|
||||
// is there a race condition here?
|
||||
// is it a problem?
|
||||
nextKey = 0x83;
|
||||
keyReady = true;
|
||||
addKeyToBuffer(0x03);
|
||||
}
|
||||
|
||||
chtype mapCharacter(BYTE ch)
|
||||
|
@ -517,8 +514,7 @@ int ProcessKeyboard()
|
|||
|
||||
if (ch != ERR)
|
||||
{
|
||||
nextKey = ch | 0x80;
|
||||
keyReady = true;
|
||||
addKeyToBuffer(ch);
|
||||
return ERR;
|
||||
}
|
||||
else
|
||||
|
@ -533,23 +529,6 @@ void ProcessInput()
|
|||
paddle->poll();
|
||||
}
|
||||
|
||||
BYTE KeybGetKeycode ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BYTE KeybReadData()
|
||||
{
|
||||
LogFileTimeUntilFirstKeyRead();
|
||||
return nextKey;
|
||||
}
|
||||
|
||||
BYTE KeybReadFlag()
|
||||
{
|
||||
BYTE result = keyReady ? nextKey : 0;
|
||||
nextKey = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Speaker
|
||||
|
||||
|
|
|
@ -5,16 +5,9 @@
|
|||
|
||||
#include "StdAfx.h"
|
||||
#include "linux/data.h"
|
||||
#include "linux/keyboard.h"
|
||||
#include "MouseInterface.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
BYTE keyCode = 0;
|
||||
bool keyWaiting = false;
|
||||
|
||||
}
|
||||
|
||||
Video::Video(QWidget *parent) : VIDEO_BASECLASS(parent)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
|
@ -128,8 +121,7 @@ void Video::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
if (ch)
|
||||
{
|
||||
keyCode = ch;
|
||||
keyWaiting = true;
|
||||
addKeyToBuffer(ch);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
@ -198,21 +190,3 @@ void Video::mouseReleaseEvent(QMouseEvent *event)
|
|||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard
|
||||
|
||||
BYTE KeybGetKeycode ()
|
||||
{
|
||||
return keyCode;
|
||||
}
|
||||
|
||||
BYTE KeybReadData()
|
||||
{
|
||||
return keyCode | (keyWaiting ? 0x80 : 0x00);
|
||||
}
|
||||
|
||||
BYTE KeybReadFlag()
|
||||
{
|
||||
keyWaiting = false;
|
||||
return keyCode;
|
||||
}
|
||||
|
|
48
source/linux/keyboard.cpp
Normal file
48
source/linux/keyboard.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include "linux/keyboard.h"
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "Applewin.h"
|
||||
|
||||
#include <queue>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::queue<BYTE> keys;
|
||||
BYTE keycode = 0;
|
||||
}
|
||||
|
||||
void addKeyToBuffer(BYTE key)
|
||||
{
|
||||
keys.push(key);
|
||||
}
|
||||
|
||||
BYTE KeybGetKeycode()
|
||||
{
|
||||
return keycode;
|
||||
}
|
||||
|
||||
BYTE KeybReadData()
|
||||
{
|
||||
LogFileTimeUntilFirstKeyRead();
|
||||
|
||||
if (keys.empty())
|
||||
{
|
||||
return keycode;
|
||||
}
|
||||
else
|
||||
{
|
||||
keycode = keys.front();
|
||||
const BYTE result = keycode | 0x80;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE KeybReadFlag()
|
||||
{
|
||||
if (!keys.empty())
|
||||
{
|
||||
keys.pop();
|
||||
}
|
||||
|
||||
return KeybReadData();
|
||||
}
|
3
source/linux/keyboard.h
Normal file
3
source/linux/keyboard.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "linux/windows/wincompat.h"
|
||||
|
||||
void addKeyToBuffer(BYTE key);
|
Loading…
Add table
Reference in a new issue