Added new switch: '-no-hook-alt' - used to prevent left/right ALT from emulating open/closed apple keys (#583)

This commit is contained in:
tomcw 2018-11-10 15:55:20 +00:00
parent 6fb5b3b0e8
commit 14e0bb7b71
4 changed files with 24 additions and 7 deletions

View File

@ -1313,6 +1313,10 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{
g_bHookAltGrControl = true;
}
else if (strcmp(lpCmdLine, "-no-hook-alt") == 0) // GH#583
{
JoySetHookAltKeys(false);
}
else if (strcmp(lpCmdLine, "-spkr-inc") == 0)
{
lpCmdLine = GetCurrArg(lpNextArg);

View File

@ -1378,10 +1378,10 @@ LRESULT CALLBACK FrameWndProc (
else if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_LOGO) || (g_nAppMode == MODE_STEPPING))
{
// NB. Alt Gr (Right-Alt): this normally send 2 WM_KEYDOWN messages for: VK_LCONTROL, then VK_RMENU
// . NB. The keyboard hook filter now suppresses VK_LCONTROL
// . NB. The keyboard hook filter will suppress VK_LCONTROL (if -hook-altgr-control is passed on the cmd-line)
bool extended = (HIWORD(lparam) & KF_EXTENDED) != 0;
BOOL down = 1;
BOOL autorep = (HIWORD(lparam) & KF_REPEAT) != 0;
bool down = true;
bool autorep = (HIWORD(lparam) & KF_REPEAT) != 0;
BOOL IsJoyKey = JoyProcessKey((int)wparam, extended, down, autorep);
#if DEBUG_KEY_MESSAGES
@ -1436,8 +1436,8 @@ LRESULT CALLBACK FrameWndProc (
else
{
bool extended = (HIWORD(lparam) & KF_EXTENDED) != 0;
BOOL down = 0;
BOOL autorep = 0;
bool down = false;
bool autorep = false;
BOOL bIsJoyKey = JoyProcessKey((int)wparam, extended, down, autorep);
#if DEBUG_KEY_MESSAGES

View File

@ -111,6 +111,15 @@ static UINT g_bJoyportEnabled = 0; // Set to use Joyport to drive the 3 button i
static UINT g_uJoyportActiveStick = 0;
static UINT g_uJoyportReadMode = JOYPORT_LEFTRIGHT;
static bool g_bHookAltKeys = true;
//===========================================================================
void JoySetHookAltKeys(bool hook)
{
g_bHookAltKeys = hook;
}
//===========================================================================
void CheckJoystick0()
{
@ -296,7 +305,7 @@ void JoyInitialize()
#define SUPPORT_CURSOR_KEYS
BOOL JoyProcessKey(int virtkey, BOOL extended, BOOL down, BOOL autorep)
BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep)
{
static struct
{
@ -314,6 +323,9 @@ BOOL JoyProcessKey(int virtkey, BOOL extended, BOOL down, BOOL autorep)
return 0;
}
if (!g_bHookAltKeys && virtkey == VK_MENU) // GH#583
return 0;
//
BOOL keychange = 0;

View File

@ -8,7 +8,7 @@ enum JOY1CHOICE {J1C_DISABLED=0, J1C_JOYSTICK2, J1C_KEYBD_CURSORS, J1C_KEYBD_NUM
enum {JOYSTICK_MODE_FLOATING=0, JOYSTICK_MODE_CENTERING}; // Joystick centering control
void JoyInitialize();
BOOL JoyProcessKey(int,BOOL,BOOL,BOOL);
BOOL JoyProcessKey(int,bool,bool,bool);
void JoyReset();
void JoySetButton(eBUTTON,eBUTTONSTATE);
BOOL JoySetEmulationType(HWND,DWORD,int, const bool bMousecardActive);
@ -24,6 +24,7 @@ DWORD JoyGetJoyType(UINT num);
void JoySetTrim(short nValue, bool bAxisX);
short JoyGetTrim(bool bAxisX);
void JoyportControl(const UINT uControl);
void JoySetHookAltKeys(bool hook);
void JoySetSnapshot_v1(const unsigned __int64 JoyCntrResetCycle);
void JoySaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
void JoyLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);