From 4a0e93fe28dfc63b03b146cf7dbb52e253747883 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 10 Jun 2018 18:14:34 +0100 Subject: [PATCH] Added new -alt-enter cmd-line switch to allow configuration of Alt+Enter behaviour (#556) --- help/CommandLine.html | 7 ++++++- help/keyboard.html | 2 +- source/Applewin.cpp | 8 ++++++++ source/Frame.cpp | 20 +++++++++++++++----- source/Frame.h | 2 ++ 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/help/CommandLine.html b/help/CommandLine.html index 106d71c6..0d48ca57 100644 --- a/help/CommandLine.html +++ b/help/CommandLine.html @@ -68,8 +68,13 @@

-dcd
For the SSC's 6551's Status register's DCD bit, use this switch to force AppleWin to use the state of the MS_RLSD_ON bit from GetCommModemStatus().

+ -alt-enter=<toggle-full-screen|open-apple-enter>
+ Define the behavior of Alt+Enter: + -

Debug arguments:

diff --git a/help/keyboard.html b/help/keyboard.html index 527e0658..5e6de04d 100644 --- a/help/keyboard.html +++ b/help/keyboard.html @@ -73,7 +73,7 @@

Ctrl+PrintScrn:
Copy the text screen (auto detect 40/80 columns) to the clipboard.

Alt+Enter:
- Toggle between windowed and full screen video modes. (NB. Will conflict with emulation when doing Open Apple + Enter.)

+ Default: Toggle between windowed and full screen video modes. (NB. Will conflict with emulation and prevent Open Apple + Enter from being readable. Use the Command Line switch to allow Open Apple + Enter to be readable.)

Function Keys F1-F8:
These PC function keys correspond to buttons on the toolbar.

Function Key F2 + Ctrl:
diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 512cc541..188ab1b7 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -1257,6 +1257,14 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) { sg_SSC.SupportDCD(true); } + else if (strcmp(lpCmdLine, "-alt-enter=toggle-full-screen") == 0) // GH#556 + { + SetAltEnterToggleFullScreen(true); + } + else if (strcmp(lpCmdLine, "-alt-enter=open-apple-enter") == 0) // GH#556 + { + SetAltEnterToggleFullScreen(false); + } else // unsupported { LogFileOutput("Unsupported arg: %s\n", lpCmdLine); diff --git a/source/Frame.cpp b/source/Frame.cpp index 6a6f0c98..ee031b02 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -175,6 +175,15 @@ void ScreenWindowResize(const bool bCtrlKey); void FrameResizeWindow(int nNewScale); +// ========================================================================== + +static bool g_bAltEnter_ToggleFullScreen = true; // Default for ALT+ENTER is to toggle between windowed and full-screen modes + +void SetAltEnterToggleFullScreen(bool mode) +{ + g_bAltEnter_ToggleFullScreen = mode; +} + // ========================================================================== // Display construction: @@ -1733,15 +1742,15 @@ LRESULT CALLBACK FrameWndProc ( } break; - case WM_SYSKEYDOWN: + case WM_SYSKEYDOWN: // ALT + any key; or F10 KeybUpdateCtrlShiftStatus(); // http://msdn.microsoft.com/en-us/library/windows/desktop/gg153546(v=vs.85).aspx // v1.25.0: Alt-Return Alt-Enter toggle fullscreen - if (g_bAltKey && (wparam == VK_RETURN)) // NB. VK_RETURN = 0x0D; Normally WM_CHAR will be 0x0A but ALT key triggers as WM_SYSKEYDOWN and VK_MENU + if (g_bAltEnter_ToggleFullScreen && g_bAltKey && (wparam == VK_RETURN)) // NB. VK_RETURN = 0x0D; Normally WM_CHAR will be 0x0A but ALT key triggers as WM_SYSKEYDOWN and VK_MENU return 0; // NOP -- eat key - else - PostMessage(window,WM_KEYDOWN,wparam,lparam); + + PostMessage(window,WM_KEYDOWN,wparam,lparam); if ((wparam == VK_F10) || (wparam == VK_MENU)) // VK_MENU == ALT Key return 0; @@ -1752,10 +1761,11 @@ LRESULT CALLBACK FrameWndProc ( KeybUpdateCtrlShiftStatus(); // v1.25.0: Alt-Return Alt-Enter toggle fullscreen - if (g_bAltKey && (wparam == VK_RETURN)) // NB. VK_RETURN = 0x0D; Normally WM_CHAR will be 0x0A but ALT key triggers as WM_SYSKEYDOWN and VK_MENU + if (g_bAltEnter_ToggleFullScreen && g_bAltKey && (wparam == VK_RETURN)) // NB. VK_RETURN = 0x0D; Normally WM_CHAR will be 0x0A but ALT key triggers as WM_SYSKEYDOWN and VK_MENU ScreenWindowResize(false); else PostMessage(window,WM_KEYUP,wparam,lparam); + break; case WM_MENUCHAR: // GH#556 - Suppress the Windows Default Beep (ie. Ding) whenever ALT+ is pressed diff --git a/source/Frame.h b/source/Frame.h index 0528bfe5..672b95e9 100644 --- a/source/Frame.h +++ b/source/Frame.h @@ -61,3 +61,5 @@ UINT GetFrameBufferHeight(void); UINT Get3DBorderWidth(void); UINT Get3DBorderHeight(void); + + void SetAltEnterToggleFullScreen(bool mode);