diff --git a/help/cfg-input.html b/help/cfg-input.html
index 0749f1e2..854c811d 100644
--- a/help/cfg-input.html
+++ b/help/cfg-input.html
@@ -33,6 +33,7 @@ then you should leave these values at 0.
When cursor keys are used for joystick emulation and are allowed to be read from the keyboard, then some games won't work correctly (eg. Lode Runner).
When cursor keys are blocked from being read from the keyboard, then simple command-line cursor editing in AppleSoft won't work.
+ Swap 0/1: Swap buttons 0 and 1.
Auto-fire (all 3 buttons): For each button pressed, the button's state will be toggled when read.
Keyboard auto-centering: When keys used for joystick emulation are released then the joystick will return to the central position.
diff --git a/help/img/input.png b/help/img/input.png
index 6a834a5d..79a38d4a 100644
Binary files a/help/img/input.png and b/help/img/input.png differ
diff --git a/resource/Applewin.rc b/resource/Applewin.rc
index a20b23a0..d89c9935 100644
--- a/resource/Applewin.rc
+++ b/resource/Applewin.rc
@@ -130,8 +130,9 @@ BEGIN
LTEXT "&Y-trim:",IDC_STATIC,115,56,28,8
CTEXT "0",IDC_STATIC,137,49,24,20,SS_CENTERIMAGE
CONTROL "Spin1",IDC_SPIN_YTRIM,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,161,53,10,14
- CONTROL "Allow cursor keys to be read from keyboard ",IDC_CURSORCONTROL,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,75,155,10
+ CONTROL "Allow cursor keys to be read from keyboard",IDC_CURSORCONTROL,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,75,150,10
+ CONTROL "Swap 0/1",IDC_SWAPBUTTONS0AND1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,75,41,10
CONTROL "Auto-fire (all 3 buttons)",IDC_AUTOFIRE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,90,89,10
CONTROL "Keyboard auto-centering",IDC_CENTERINGCONTROL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,90,96,10
CONTROL "&Scroll Lock acts as toggle for full-speed CPU",IDC_SCROLLLOCK_TOGGLE,
diff --git a/resource/resource.h b/resource/resource.h
index 7c6b5402..d1ff4186 100644
--- a/resource/resource.h
+++ b/resource/resource.h
@@ -110,6 +110,7 @@
#define IDC_CURSORCONTROL 1066
#define IDC_AUTOFIRE 1067
#define IDC_CENTERINGCONTROL 1068
+#define IDC_SWAPBUTTONS0AND1 1069
#define IDC_COMBO_HDD1 1078
#define IDC_COMBO_HDD2 1079
#define IDC_COMBO_DISK1 1080
diff --git a/source/Applewin.cpp b/source/Applewin.cpp
index 58be97f6..a982f619 100644
--- a/source/Applewin.cpp
+++ b/source/Applewin.cpp
@@ -702,6 +702,8 @@ void LoadConfiguration(void)
sg_PropertySheet.SetJoystickCursorControl(dwTmp);
if(REGLOAD(TEXT(REGVALUE_AUTOFIRE), &dwTmp))
sg_PropertySheet.SetAutofire(dwTmp);
+ if(REGLOAD(TEXT(REGVALUE_SWAP_BUTTONS_0_AND_1), &dwTmp))
+ sg_PropertySheet.SetButtonsSwapState(dwTmp ? true : false);
if(REGLOAD(TEXT(REGVALUE_CENTERING_CONTROL), &dwTmp))
sg_PropertySheet.SetJoystickCenteringControl(dwTmp);
@@ -1591,7 +1593,7 @@ static bool ProcessCmdLine(LPSTR lpCmdLine)
}
else if (strcmp(lpCmdLine, "-swap-buttons") == 0)
{
- JoySwapButton0and1(true);
+ sg_PropertySheet.SetButtonsSwapState(true);
}
else if (strcmp(lpCmdLine, "-spkr-inc") == 0)
{
diff --git a/source/Common.h b/source/Common.h
index fd55f0f7..dc6947e9 100644
--- a/source/Common.h
+++ b/source/Common.h
@@ -85,6 +85,7 @@ enum AppMode_e
#define REGVALUE_CURSOR_CONTROL "Joystick Cursor Control"
#define REGVALUE_CENTERING_CONTROL "Joystick Centering Control"
#define REGVALUE_AUTOFIRE "Autofire"
+#define REGVALUE_SWAP_BUTTONS_0_AND_1 "Swap buttons 0 and 1"
#define REGVALUE_MOUSE_CROSSHAIR "Mouse crosshair"
#define REGVALUE_MOUSE_RESTRICT_TO_WINDOW "Mouse restrict to window"
#define REGVALUE_THE_FREEZES_F8_ROM "The Freeze's F8 Rom"
diff --git a/source/Configuration/IPropertySheet.h b/source/Configuration/IPropertySheet.h
index 8efbecff..b6b7a4e3 100644
--- a/source/Configuration/IPropertySheet.h
+++ b/source/Configuration/IPropertySheet.h
@@ -18,6 +18,8 @@ __interface IPropertySheet
void SetJoystickCenteringControl(UINT uValue);
UINT GetAutofire(UINT uButton);
void SetAutofire(UINT uValue);
+ bool GetButtonsSwapState(void);
+ void SetButtonsSwapState(bool value);
UINT GetMouseShowCrosshair(void);
void SetMouseShowCrosshair(UINT uValue);
UINT GetMouseRestrictToWindow(void);
diff --git a/source/Configuration/PageInput.cpp b/source/Configuration/PageInput.cpp
index 9badd74f..9a79fdba 100644
--- a/source/Configuration/PageInput.cpp
+++ b/source/Configuration/PageInput.cpp
@@ -197,6 +197,7 @@ BOOL CPageInput::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM
CheckDlgButton(hWnd, IDC_CURSORCONTROL, m_uCursorControl ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_AUTOFIRE, m_bmAutofire ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_SWAPBUTTONS0AND1, m_bSwapButtons0and1 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_CENTERINGCONTROL, m_uCenteringControl == JOYSTICK_MODE_CENTERING ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_SCROLLLOCK_TOGGLE, m_uScrollLockToggle ? BST_CHECKED : BST_UNCHECKED);
@@ -234,6 +235,7 @@ void CPageInput::DlgOK(HWND hWnd)
m_uCursorControl = IsDlgButtonChecked(hWnd, IDC_CURSORCONTROL) ? 1 : 0;
m_bmAutofire = IsDlgButtonChecked(hWnd, IDC_AUTOFIRE) ? 7 : 0; // bitmap of 3 bits
+ m_bSwapButtons0and1 = IsDlgButtonChecked(hWnd, IDC_SWAPBUTTONS0AND1) ? true : false;
m_uCenteringControl = IsDlgButtonChecked(hWnd, IDC_CENTERINGCONTROL) ? 1 : 0;
m_uMouseShowCrosshair = IsDlgButtonChecked(hWnd, IDC_MOUSE_CROSSHAIR) ? 1 : 0;
m_uMouseRestrictToWindow = IsDlgButtonChecked(hWnd, IDC_MOUSE_RESTRICT_TO_WINDOW) ? 1 : 0;
@@ -243,6 +245,7 @@ void CPageInput::DlgOK(HWND hWnd)
REGSAVE(TEXT(REGVALUE_SCROLLLOCK_TOGGLE), m_uScrollLockToggle);
REGSAVE(TEXT(REGVALUE_CURSOR_CONTROL), m_uCursorControl);
REGSAVE(TEXT(REGVALUE_AUTOFIRE), m_bmAutofire);
+ REGSAVE(TEXT(REGVALUE_SWAP_BUTTONS_0_AND_1), m_bSwapButtons0and1);
REGSAVE(TEXT(REGVALUE_CENTERING_CONTROL), m_uCenteringControl);
REGSAVE(TEXT(REGVALUE_MOUSE_CROSSHAIR), m_uMouseShowCrosshair);
REGSAVE(TEXT(REGVALUE_MOUSE_RESTRICT_TO_WINDOW), m_uMouseRestrictToWindow);
diff --git a/source/Configuration/PageInput.h b/source/Configuration/PageInput.h
index 1c2641e2..da64840d 100644
--- a/source/Configuration/PageInput.h
+++ b/source/Configuration/PageInput.h
@@ -16,6 +16,7 @@ public:
m_uCursorControl(1),
m_uCenteringControl(JOYSTICK_MODE_CENTERING),
m_bmAutofire(0),
+ m_bSwapButtons0and1(false),
m_uMouseShowCrosshair(0),
m_uMouseRestrictToWindow(0),
m_CPMChoice(CPM_UNPLUGGED)
@@ -34,6 +35,8 @@ public:
void SetJoystickCenteringControl(UINT uValue){ m_uCenteringControl = uValue; }
UINT GetAutofire(UINT uButton) { return (m_bmAutofire >> uButton) & 1; } // Get a specific button
void SetAutofire(UINT uValue) { m_bmAutofire = uValue; } // Set all buttons
+ bool GetButtonsSwapState(void){ return m_bSwapButtons0and1; }
+ void SetButtonsSwapState(bool value){ m_bSwapButtons0and1 = value; }
UINT GetMouseShowCrosshair(void){ return m_uMouseShowCrosshair; }
void SetMouseShowCrosshair(UINT uValue){ m_uMouseShowCrosshair = uValue; }
UINT GetMouseRestrictToWindow(void){ return m_uMouseRestrictToWindow; }
@@ -81,6 +84,7 @@ private:
UINT m_uCursorControl; // 1 = Allow AppleII to read cursor keys from $C000 (when using keyboard for joystick emu)
UINT m_uCenteringControl; // 1 = Centering, 0=Floating (when using keyboard for joystick emu)
UINT m_bmAutofire; // bitmask b2:0
+ bool m_bSwapButtons0and1;
UINT m_uMouseShowCrosshair;
UINT m_uMouseRestrictToWindow;
diff --git a/source/Configuration/PropertySheet.h b/source/Configuration/PropertySheet.h
index 838b58df..ae187884 100644
--- a/source/Configuration/PropertySheet.h
+++ b/source/Configuration/PropertySheet.h
@@ -41,6 +41,8 @@ public:
virtual void SetJoystickCenteringControl(UINT uValue){ m_PageInput.SetJoystickCenteringControl(uValue); }
virtual UINT GetAutofire(UINT uButton) { return m_PageInput.GetAutofire(uButton); }
virtual void SetAutofire(UINT uValue) { m_PageInput.SetAutofire(uValue); }
+ virtual bool GetButtonsSwapState(void) { return m_PageInput.GetButtonsSwapState(); }
+ virtual void SetButtonsSwapState(bool value) { m_PageInput.SetButtonsSwapState(value); }
virtual UINT GetMouseShowCrosshair(void){ return m_PageInput.GetMouseShowCrosshair(); }
virtual void SetMouseShowCrosshair(UINT uValue){ m_PageInput.SetMouseShowCrosshair(uValue); }
virtual UINT GetMouseRestrictToWindow(void){ return m_PageInput.GetMouseRestrictToWindow(); }
diff --git a/source/Joystick.cpp b/source/Joystick.cpp
index 997623c0..8f2dbaaa 100644
--- a/source/Joystick.cpp
+++ b/source/Joystick.cpp
@@ -303,13 +303,6 @@ void JoyInitialize()
//===========================================================================
-static bool g_swapButton0and1 = false;
-
-void JoySwapButton0and1(bool swap)
-{
- g_swapButton0and1 = swap;
-}
-
static UINT g_buttonVirtKey[2] = { VK_MENU, VK_MENU | KF_EXTENDED }; // VK_MENU == ALT Key
void JoySetButtonVirtualKey(UINT button, UINT virtKey)
@@ -350,13 +343,14 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep)
BOOL keychange = 0;
bool bIsCursorKey = false;
+ const bool swapButtons0and1 = sg_PropertySheet.GetButtonsSwapState();
- if (virtKeyWithExtended == g_buttonVirtKey[!g_swapButton0and1 ? 0 : 1])
+ if (virtKeyWithExtended == g_buttonVirtKey[!swapButtons0and1 ? 0 : 1])
{
keychange = 1;
keydown[JK_OPENAPPLE] = down;
}
- else if (virtKeyWithExtended == g_buttonVirtKey[!g_swapButton0and1 ? 1 : 0])
+ else if (virtKeyWithExtended == g_buttonVirtKey[!swapButtons0and1 ? 1 : 0])
{
keychange = 1;
keydown[JK_CLOSEDAPPLE] = down;
diff --git a/source/Joystick.h b/source/Joystick.h
index d56f0637..c354f1ec 100644
--- a/source/Joystick.h
+++ b/source/Joystick.h
@@ -25,7 +25,6 @@ void JoySetTrim(short nValue, bool bAxisX);
short JoyGetTrim(bool bAxisX);
void JoyportControl(const UINT uControl);
void JoySetHookAltKeys(bool hook);
-void JoySwapButton0and1(bool swap);
void JoySetButtonVirtualKey(UINT button, UINT virtKey);
void JoySaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
void JoyLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);