Keyboard:

. When in MODE_LOGO, don't pass WM_CHAR to Apple II keyboard (now consistent with WM_KEYDOWN)
. Small refactor for Apple II keyboard's WM_KEYDOWN handler
Move code for log init & done to Log.cpp
This commit is contained in:
tomcw 2018-07-15 15:38:37 +01:00
parent 881e51874b
commit c457241229
5 changed files with 54 additions and 26 deletions

View File

@ -1077,12 +1077,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
if (((strcmp(lpCmdLine, "-l") == 0) || (strcmp(lpCmdLine, "-log") == 0)) && (g_fh == NULL))
{
g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text mode)
setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf)
CHAR aDateStr[80], aTimeStr[80];
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aDateStr, sizeof(aDateStr));
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aTimeStr, sizeof(aTimeStr));
fprintf(g_fh, "*** Logging started: %s %s\n", aDateStr, aTimeStr);
LogInit();
}
else if (strcmp(lpCmdLine, "-noreg") == 0)
{
@ -1559,12 +1554,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
tfe_shutdown();
LogFileOutput("Exit: tfe_shutdown()\n");
if (g_fh)
{
fprintf(g_fh,"*** Logging ended\n\n");
fclose(g_fh);
g_fh = NULL;
}
LogDone();
RiffFinishWriteFile();

View File

@ -1098,7 +1098,8 @@ LRESULT CALLBACK FrameWndProc (
{
if( !g_bDebuggerEatKey )
{
KeybQueueKeypress((int)wparam, ASCII);
if (g_nAppMode != MODE_LOGO) // !MODE_LOGO - not emulating so don't pass to the VM's keyboard
KeybQueueKeypress((int)wparam, ASCII);
}
else
{
@ -1399,7 +1400,8 @@ LRESULT CALLBACK FrameWndProc (
BOOL autorep = (HIWORD(lparam) & KF_REPEAT) != 0;
BOOL IsJoyKey = JoyProcessKey((int)wparam, extended, down, autorep);
if (!IsJoyKey && (g_nAppMode != MODE_LOGO))
if (!IsJoyKey &&
(g_nAppMode != MODE_LOGO)) // !MODE_LOGO - not emulating so don't pass to the VM's keyboard
{
KeybQueueKeypress((int)wparam, NOT_ASCII);

View File

@ -37,8 +37,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Video.h" // Needed by TK3000 //e, to refresh the frame at each |Mode| change
static BYTE asciicode[2][10] = {
{0x08,0x0D,0x15,0x2F,0x00,0x00,0x00,0x00,0x00,0x00},
{0x08,0x0B,0x15,0x0A,0x00,0x00,0x00,0x00,0x00,0x7F}
// VK_LEFT/UP/RIGHT/DOWN/SELECT, VK_PRINT/EXECUTE/SNAPSHOT/INSERT/DELETE
{0x08,0x0D,0x15,0x2F,0x00, 0x00,0x00,0x00,0x00,0x00}, // Apple II
{0x08,0x0B,0x15,0x0A,0x00, 0x00,0x00,0x00,0x00,0x7F} // Apple //e
}; // Convert PC arrow keys to Apple keycodes
bool g_bShiftKey = false;
@ -49,7 +50,6 @@ static bool g_bTK3KModeKey = false; //TK3000 //e |Mode| key
static bool g_bCapsLock = true; //Caps lock key for Apple2 and Lat/Cyr lock for Pravets8
static bool g_bP8CapsLock = true; //Caps lock key of Pravets 8A/C
static int lastvirtkey = 0; // Current PC keycode
static BYTE keycode = 0; // Current Apple keycode
static BOOL keywaiting = 0;
@ -102,7 +102,7 @@ bool KeybGetShiftStatus ()
//===========================================================================
void KeybUpdateCtrlShiftStatus()
{
g_bShiftKey = (GetKeyState( VK_SHIFT ) & KF_UP) ? true : false; // 0x8000 KF_UP
g_bShiftKey = (GetKeyState( VK_SHIFT ) & KF_UP) ? true : false;
g_bCtrlKey = (GetKeyState( VK_CONTROL) & KF_UP) ? true : false;
g_bAltKey = (GetKeyState( VK_MENU ) & KF_UP) ? true : false;
}
@ -271,8 +271,6 @@ void KeybQueueKeypress (int key, BOOL bASCII)
keycode = key;
}
}
lastvirtkey = LOBYTE(VkKeyScan(key));
}
else //(bASCII != ASCII) // WM_KEYDOWN
{
@ -299,13 +297,24 @@ void KeybQueueKeypress (int key, BOOL bASCII)
FrameRefreshStatus(DRAW_LEDS); // TODO: Implement |Mode| LED in the UI; make it appear only when in TK3000 mode
VideoRedrawScreen(); // TODO: Still need to implement page mode switching and 'whatnot'
}
return;
}
if (!((key >= VK_LEFT) && (key <= VK_DELETE) && asciicode[IS_APPLE2 ? 0 : 1][key - VK_LEFT]))
if (key >= VK_LEFT && key <= VK_DELETE)
{
BYTE n = asciicode[IS_APPLE2 ? 0 : 1][key - VK_LEFT]; // Convert to Apple arrow keycode
if (!n)
return;
keycode = n;
}
else if ((GetKeyState( VK_RMENU ) & KF_UP)) // Right ALT
{
//
}
else
{
return;
keycode = asciicode[IS_APPLE2 ? 0 : 1][key - VK_LEFT]; // Convert to Apple arrow keycode
lastvirtkey = key;
}
}
keywaiting = 1;

View File

@ -32,6 +32,31 @@ FILE* g_fh = NULL;
//---------------------------------------------------------------------------
void LogInit(void)
{
if (g_fh)
return;
g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text mode)
setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf)
CHAR aDateStr[80], aTimeStr[80];
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aDateStr, sizeof(aDateStr));
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aTimeStr, sizeof(aTimeStr));
fprintf(g_fh, "*** Logging started: %s %s\n", aDateStr, aTimeStr);
}
void LogDone(void)
{
if (!g_fh)
return;
fprintf(g_fh,"*** Logging ended\n\n");
fclose(g_fh);
g_fh = NULL;
}
//---------------------------------------------------------------------------
void LogOutput(LPCTSTR format, ...)
{
TCHAR output[256];

View File

@ -10,5 +10,7 @@
extern FILE* g_fh; // Filehandle for log file
extern void LogOutput(LPCTSTR format, ...);
extern void LogFileOutput(LPCTSTR format, ...);
void LogInit(void);
void LogDone(void);
void LogOutput(LPCTSTR format, ...);
void LogFileOutput(LPCTSTR format, ...);