mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-21 07:17:41 +00:00
Support ClosedApple+key with Alt Gr when combined with a regular keyboard key:
. When Alt Gr is pressed, then manually post WM_CHAR message on receiving a WM_KEYDOWN (manually translate and account for shift/control/caps-lock) . Hook filter: suppress Alt Gr's (ie. RMENU's) fake LCONTROL messages Also: . Hook filter: allow Ctrl+Shift+Esc (for Task Manager) . Keyboard: refactor only use accessor functions to get the Alt/Control/Shift state
This commit is contained in:
+56
-27
@@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "Tape.h"
|
||||
#include "YamlHelper.h"
|
||||
#include "Video.h" // Needed by TK3000 //e, to refresh the frame at each |Mode| change
|
||||
#include "Log.h"
|
||||
|
||||
static BYTE asciicode[2][10] = {
|
||||
// VK_LEFT/UP/RIGHT/DOWN/SELECT, VK_PRINT/EXECUTE/SNAPSHOT/INSERT/DELETE
|
||||
@@ -65,36 +66,31 @@ void KeybReset()
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool KeybGetAltStatus ()
|
||||
{
|
||||
return g_bAltKey;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool KeybGetCapsStatus ()
|
||||
bool KeybGetCapsStatus()
|
||||
{
|
||||
return g_bCapsLock;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool KeybGetP8CapsStatus()
|
||||
{
|
||||
return g_bP8CapsLock;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
/*
|
||||
bool KeybGetCapsAllowed() //For Pravets 8A/C only
|
||||
bool KeybGetAltStatus()
|
||||
{
|
||||
return g_CapsLockAllowed;
|
||||
return g_bAltKey;
|
||||
}
|
||||
*/
|
||||
|
||||
//===========================================================================
|
||||
bool KeybGetCtrlStatus ()
|
||||
bool KeybGetCtrlStatus()
|
||||
{
|
||||
return g_bCtrlKey;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool KeybGetShiftStatus ()
|
||||
bool KeybGetShiftStatus()
|
||||
{
|
||||
return g_bShiftKey;
|
||||
}
|
||||
@@ -102,9 +98,9 @@ bool KeybGetShiftStatus ()
|
||||
//===========================================================================
|
||||
void KeybUpdateCtrlShiftStatus()
|
||||
{
|
||||
g_bShiftKey = (GetKeyState( VK_SHIFT ) < 0) ? true : false; // L or R shift
|
||||
g_bCtrlKey = (GetKeyState( VK_CONTROL) < 0) ? true : false; // L or R ctrl
|
||||
g_bAltKey = (GetKeyState( VK_MENU ) < 0) ? true : false; // L or R alt
|
||||
g_bCtrlKey = (GetKeyState( VK_CONTROL) < 0) ? true : false; // L or R ctrl
|
||||
g_bShiftKey = (GetKeyState( VK_SHIFT ) < 0) ? true : false; // L or R shift
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@@ -114,7 +110,10 @@ BYTE KeybGetKeycode () // Used by IORead_C01x() and TapeRead() for Pravets8A
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void KeybQueueKeypress(WPARAM key, Keystroke_e bASCII)
|
||||
|
||||
bool IsVirtualKeyAnAppleIIKey(WPARAM wparam);
|
||||
|
||||
void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII)
|
||||
{
|
||||
if (bASCII == ASCII) // WM_CHAR
|
||||
{
|
||||
@@ -205,7 +204,7 @@ void KeybQueueKeypress(WPARAM key, Keystroke_e bASCII)
|
||||
}
|
||||
else //i.e. latin letters
|
||||
{
|
||||
if (GetCapsLockAllowed() == false)
|
||||
if (GetCapsLockAllowed() == false)
|
||||
{
|
||||
if (key == '{') keycode = '[';
|
||||
if (key == '}') keycode = ']';
|
||||
@@ -309,7 +308,27 @@ void KeybQueueKeypress(WPARAM key, Keystroke_e bASCII)
|
||||
}
|
||||
else if ((GetKeyState(VK_RMENU) < 0)) // Right Alt (aka Alt Gr)
|
||||
{
|
||||
//
|
||||
if (IsVirtualKeyAnAppleIIKey(key))
|
||||
{
|
||||
// When Alt Gr is down, then WM_CHAR is not posted - so fix this.
|
||||
// NB. Still get WM_KEYDOWN/WM_KEYUP for the virtual key, so AKD works.
|
||||
WPARAM newKey = key;
|
||||
|
||||
// Translate if shift or ctrl is down
|
||||
if (key >= 'A' && key <= 'Z')
|
||||
{
|
||||
if ( (GetKeyState(VK_SHIFT) >= 0) && !g_bCapsLock )
|
||||
newKey += 'a' - 'A'; // convert to lowercase key
|
||||
else if (GetKeyState(VK_CONTROL) < 0)
|
||||
{
|
||||
LogOutput("L-Control=%d, R-Control=%d\n", GetKeyState(VK_LCONTROL), GetKeyState(VK_RCONTROL));
|
||||
newKey -= 'A' - 1; // convert to control-key
|
||||
}
|
||||
}
|
||||
|
||||
PostMessage(g_hFrameWindow, WM_CHAR, newKey, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -401,16 +420,8 @@ const UINT kAKDNumElements = 256/64;
|
||||
static uint64_t g_AKDFlags[2][kAKDNumElements] = { {0,0,0,0}, // normal
|
||||
{0,0,0,0}}; // extended
|
||||
|
||||
// NB. Don't need to be concerned about if numpad/cursors are used for joystick,
|
||||
// since parent calls JoyProcessKey() just before this.
|
||||
void KeybAnyKeyDown(UINT message, WPARAM wparam, bool bIsExtended)
|
||||
static bool IsVirtualKeyAnAppleIIKey(WPARAM wparam)
|
||||
{
|
||||
if (wparam > 255)
|
||||
{
|
||||
_ASSERT(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wparam == VK_BACK ||
|
||||
wparam == VK_TAB ||
|
||||
wparam == VK_RETURN ||
|
||||
@@ -425,6 +436,24 @@ void KeybAnyKeyDown(UINT message, WPARAM wparam, bool bIsExtended)
|
||||
(wparam >= VK_OEM_1 && wparam <= VK_OEM_3) || // 7 in total
|
||||
(wparam >= VK_OEM_4 && wparam <= VK_OEM_8) || // 5 in total
|
||||
(wparam == VK_OEM_102))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// NB. Don't need to be concerned about if numpad/cursors are used for joystick,
|
||||
// since parent calls JoyProcessKey() just before this.
|
||||
void KeybAnyKeyDown(UINT message, WPARAM wparam, bool bIsExtended)
|
||||
{
|
||||
if (wparam > 255)
|
||||
{
|
||||
_ASSERT(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsVirtualKeyAnAppleIIKey(wparam))
|
||||
{
|
||||
UINT offset = wparam >> 6;
|
||||
UINT bit = wparam & 0x3f;
|
||||
|
||||
Reference in New Issue
Block a user