From d2749a9c44a1e03832bb2e5d531b498e0e25204c Mon Sep 17 00:00:00 2001 From: tomch Date: Sat, 26 Jul 2008 21:52:35 +0000 Subject: [PATCH] Fix: Old bug - uninitialised local static! (bFreshReset) Change: Better formatting --- AppleWin/source/Keyboard.cpp | 103 ++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 49 deletions(-) diff --git a/AppleWin/source/Keyboard.cpp b/AppleWin/source/Keyboard.cpp index 0cb6d8c5..3cf8acf5 100644 --- a/AppleWin/source/Keyboard.cpp +++ b/AppleWin/source/Keyboard.cpp @@ -166,16 +166,17 @@ DWORD KeybGetNumQueries () // Used in determining 'idleness' of Apple system //=========================================================================== void KeybQueueKeypress (int key, BOOL bASCII) { - static bool bFreshReset; + static bool bFreshReset = false; if (bASCII == ASCII) { if (bFreshReset && key == 0x03) { - bFreshReset = 0; + bFreshReset = false; return; // Swallow spurious CTRL-C caused by CTRL-BREAK } - bFreshReset = 0; + + bFreshReset = false; if (key > 0x7F) return; @@ -185,29 +186,29 @@ void KeybQueueKeypress (int key, BOOL bASCII) if (g_bCapsLock && (key >= 'a') && (key <='z')) { P8Shift = true; - keycode = key - 32; + keycode = key - 32; } else { - keycode = key; + keycode = key; } //The latter line should be applied for Pravtes 8A/C only, but not for Pravets 82/M !!! if ((g_bCapsLock == false) && (key >= 'A') && (key <='Z')) { - P8Shift = true; - if (g_Apple2Type == A2TYPE_PRAVETS8A) - keycode = key + 32; + P8Shift = true; + if (g_Apple2Type == A2TYPE_PRAVETS8A) + keycode = key + 32; } - + //Remap some keys for Pravets82/M if (g_Apple2Type == A2TYPE_PRAVETS82) { if (key == 64) keycode = 96; if (key == '^') - keycode = '~'; - + keycode = '~'; + if (g_bCapsLock == false) //i.e. cyrillic letters { if (key == '`') keycode = '^'; @@ -216,53 +217,57 @@ void KeybQueueKeypress (int key, BOOL bASCII) } else //(g_bCapsLock == true) //i.e. latin letters { - if (key == 91) keycode = 123; - if (key == 93) keycode = 125; - if (key == 124) keycode = 92; + if (key == 91) keycode = 123; + if (key == 93) keycode = 125; + if (key == 124) keycode = 92; } } //Remap some keys for Pravets8A/C, which has a different charset for Pravtes82/M, whose keys MUST NOT be remapped. if (g_Apple2Type == A2TYPE_PRAVETS8A) //&& (g_bCapsLock == false)) + { if (g_bCapsLock == false) //i.e. cyrillic letters { - if (key == '[') keycode = '{'; - if (key == ']') keycode = '}'; - if (key == '`') keycode = '~'; - if (key == 92) keycode = 96; - if (GetCapsLockAllowed ()== true) - { - if ((key == 92) || (key == 124)) keycode = 96; //Ý to Þ - //This shall be rewriten, so that enabling CAPS_LOCK (i.e. F10) will not invert these keys values) - //The same for latin letters. - if ((key == '{') || (key == '}') || (key == '~') || (key == 124) || (key == '^') || (key == 95)) - P8Shift = true; + if (key == '[') keycode = '{'; + if (key == ']') keycode = '}'; + if (key == '`') keycode = '~'; + if (key == 92) keycode = 96; + if (GetCapsLockAllowed ()== true) + { + if ((key == 92) || (key == 124)) keycode = 96; //Ý to Þ + //This shall be rewriten, so that enabling CAPS_LOCK (i.e. F10) will not invert these keys values) + //The same for latin letters. + if ((key == '{') || (key == '}') || (key == '~') || (key == 124) || (key == '^') || (key == 95)) + P8Shift = true; + } } - } - else //i.e. latin letters + else //i.e. latin letters { if (GetCapsLockAllowed() == false) { - if (key == '{') keycode = '['; - if (key == '}') keycode = ']'; - if (key == 124) - keycode = 92; - /*if (key == 92) - keycode = 124;*/ + if (key == '{') keycode = '['; + if (key == '}') keycode = ']'; + if (key == 124) + keycode = 92; + /*if (key == 92) + keycode = 124;*/ //Characters ` and ~ cannot be generated in 7bit character mode, so they are replaced with } else { - if (key == '{') keycode = 91; - if (key == '}') keycode = 93; - if (key == 124) keycode = 92; - if ((key == '[') || (key == ']') || (key == 92) || (key == '^') || (key == 95)) - P8Shift= true; - if (key == 96) //This line shall generate sth. else i.e. ` In fact. this character is not generateable by the pravets keyboard. - {keycode = '^'; - P8Shift= true;} - if (key == 126) keycode = '^'; - } - } + if (key == '{') keycode = 91; + if (key == '}') keycode = 93; + if (key == 124) keycode = 92; + if ((key == '[') || (key == ']') || (key == 92) || (key == '^') || (key == 95)) + P8Shift= true; + if (key == 96) //This line shall generate sth. else i.e. ` In fact. this character is not generateable by the pravets keyboard. + { + keycode = '^'; + P8Shift= true; + } + if (key == 126) keycode = '^'; + } + } + } } else { @@ -271,10 +276,10 @@ void KeybQueueKeypress (int key, BOOL bASCII) } else { - if (key >= '`') - keycode = key - 32; - else - keycode = key; + if (key >= '`') + keycode = key - 32; + else + keycode = key; } } lastvirtkey = LOBYTE(VkKeyScan(key)); @@ -298,7 +303,7 @@ void KeybQueueKeypress (int key, BOOL bASCII) #endif CpuReset(); - bFreshReset = 1; + bFreshReset = true; return; }