Merge pull request #2152 from ergo720/ignore_kbmo_opt

Added option to allow kb/mo input when the rendering window is unfocused
This commit is contained in:
Luke Usher 2021-03-12 11:29:18 +00:00 committed by GitHub
commit 61e7e30e29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 8 deletions

View File

@ -131,6 +131,7 @@ static const char *section_input_general = "input-general";
static struct {
const char *mo_axis_range = "MouseAxisRange";
const char *mo_wheel_range = "MouseWheelRange";
const char *ignore_kbmo_unfocus = "IgnoreKbMoUnfocus";
} sect_input_general;
static const char* section_controller_dinput = "controller-dinput";
@ -451,6 +452,7 @@ bool Settings::LoadConfig()
m_input_general.MoAxisRange = m_si.GetLongValue(section_input_general, sect_input_general.mo_axis_range, MO_AXIS_DEFAULT_RANGE);
m_input_general.MoWheelRange = m_si.GetLongValue(section_input_general, sect_input_general.mo_wheel_range, MO_WHEEL_DEFAULT_RANGE);
m_input_general.IgnoreKbMoUnfocus = m_si.GetLongValue(section_input_general, sect_input_general.ignore_kbmo_unfocus, 1);
// ==== Input General End ==============
@ -615,6 +617,7 @@ bool Settings::Save(std::string file_path)
m_si.SetLongValue(section_input_general, sect_input_general.mo_axis_range, m_input_general.MoAxisRange, nullptr, false, true);
m_si.SetLongValue(section_input_general, sect_input_general.mo_wheel_range, m_input_general.MoWheelRange, nullptr, false, true);
m_si.SetLongValue(section_input_general, sect_input_general.ignore_kbmo_unfocus, m_input_general.IgnoreKbMoUnfocus, nullptr, false, true);
// ==== Input General End =========
@ -765,6 +768,7 @@ void Settings::SyncToEmulator()
g_EmuShared->SetInputMoAxisSettings(m_input_general.MoAxisRange);
g_EmuShared->SetInputMoWheelSettings(m_input_general.MoWheelRange);
g_EmuShared->SetInputKbMoUnfocusSettings(m_input_general.IgnoreKbMoUnfocus);
// register Hacks settings
g_EmuShared->SetHackSettings(&m_hacks);

View File

@ -137,6 +137,7 @@ public:
struct s_input_general {
long MoAxisRange;
long MoWheelRange;
bool IgnoreKbMoUnfocus;
};
s_input_general m_input_general;

View File

@ -158,7 +158,7 @@ namespace DInput
bool KeyboardMouse::UpdateInput()
{
if (mo_leave_wnd) {
if (static_cast<uint8_t>(mo_leave_wnd) & static_cast<uint8_t>(IgnoreKbMoUnfocus)) {
std::memset(&m_state_in, 0, sizeof(m_state_in));
return true;
}

View File

@ -36,6 +36,7 @@ namespace DInput
{
inline bool bKbMoEnumerated = false;
inline bool mo_leave_wnd = false;
inline bool IgnoreKbMoUnfocus = true;
inline LONG mo_axis_range_pos = 0;
inline LONG mo_axis_range_neg = 0;
inline LONG mo_wheel_range_pos = 0;

View File

@ -701,12 +701,15 @@ void InputDeviceManager::UpdateOpt(bool is_gui)
{
if (!is_gui) {
long axis_range, wheel_range;
bool ignore_kbmo;
g_EmuShared->GetInputMoAxisSettings(&axis_range);
g_EmuShared->GetInputMoWheelSettings(&wheel_range);
g_EmuShared->GetInputKbMoUnfocusSettings(&ignore_kbmo);
DInput::mo_axis_range_pos = axis_range;
DInput::mo_wheel_range_pos = wheel_range;
DInput::mo_axis_range_neg = -(axis_range);
DInput::mo_wheel_range_neg = -(wheel_range);
DInput::IgnoreKbMoUnfocus = ignore_kbmo;
}
else {
DInput::mo_axis_range_pos = g_Settings->m_input_general.MoAxisRange;

View File

@ -152,9 +152,9 @@ EmuShared::EmuShared()
m_bEmulating_status = false;
m_bFirstLaunch = false;
m_bClipCursor = false;
m_bIgnoreKbMoUnfocus = true;
// Reserve space (default to 0)
m_bReserved3 = false;
m_bReserved4 = false;
m_Reserved5 = 0;
m_Reserved6 = 0.0f;

View File

@ -156,6 +156,8 @@ class EmuShared : public Mutex
void SetInputMoAxisSettings(const long axis) { Lock(); m_MoAxisRange = axis; Unlock(); }
void GetInputMoWheelSettings(long *wheel) { Lock(); *wheel = m_MoWheelRange; Unlock(); }
void SetInputMoWheelSettings(const long wheel) { Lock(); m_MoWheelRange = wheel; Unlock(); }
void GetInputKbMoUnfocusSettings(bool *flag) { Lock(); *flag = m_bIgnoreKbMoUnfocus; Unlock(); }
void SetInputKbMoUnfocusSettings(const bool flag) { Lock(); m_bIgnoreKbMoUnfocus = flag; Unlock(); }
// ******************************************************************
// * LLE Flags Accessors
@ -299,7 +301,7 @@ class EmuShared : public Mutex
#endif
bool m_bFirstLaunch;
bool m_bClipCursor;
bool m_bReserved3;
bool m_bIgnoreKbMoUnfocus;
bool m_bReserved4;
unsigned int m_dwKrnlProcID; // Only used for kernel mode level.
int m_DeviceType[4];

View File

@ -76,6 +76,7 @@ void SyncInputSettings(int port_num, int dev_type, bool is_opt)
else {
g_EmuShared->SetInputMoAxisSettings(g_Settings->m_input_general.MoAxisRange);
g_EmuShared->SetInputMoWheelSettings(g_Settings->m_input_general.MoWheelRange);
g_EmuShared->SetInputKbMoUnfocusSettings(g_Settings->m_input_general.IgnoreKbMoUnfocus);
port_num = PORT_INVALID;
}
#if 0 // lle usb
@ -94,6 +95,8 @@ void UpdateInputOpt(HWND hwnd)
g_Settings->m_input_general.MoAxisRange = std::stol(buffer);
SendMessage(GetDlgItem(hwnd, IDC_WHEEL_RANGE), WM_GETTEXT, 30, reinterpret_cast<LPARAM>(buffer));
g_Settings->m_input_general.MoWheelRange = std::stol(buffer);
LRESULT ret = SendMessage(GetDlgItem(hwnd, IDC_IGNORE_KBMO_UNFOCUS), BM_GETCHECK, 0, 0);
g_Settings->m_input_general.IgnoreKbMoUnfocus = (ret == BST_CHECKED);
}
void ShowInputConfig(HWND hwnd, HWND ChildWnd)
@ -138,6 +141,7 @@ INT_PTR CALLBACK DlgInputConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
std::to_string(g_Settings->m_input_general.MoAxisRange).c_str() :
std::to_string(g_Settings->m_input_general.MoWheelRange).c_str()));
}
SendMessage(GetDlgItem(hWndDlg, IDC_IGNORE_KBMO_UNFOCUS), BM_SETCHECK, static_cast<WPARAM>(g_Settings->m_input_general.IgnoreKbMoUnfocus), 0);
// Reset option/input changes flag
g_bHasOptChanges = false;
@ -251,6 +255,16 @@ INT_PTR CALLBACK DlgInputConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
g_bHasOptChanges = true;
}
}
break;
case IDC_IGNORE_KBMO_UNFOCUS:
{
if (HIWORD(wParam) == BN_CLICKED) {
g_bHasOptChanges = true;
}
}
break;
}
}
break;

View File

@ -84,7 +84,7 @@ END
// Dialog
//
IDD_INPUT_CFG DIALOGEX 0, 0, 243, 175
IDD_INPUT_CFG DIALOGEX 0, 0, 243, 188
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Cxbx-Reloaded : Input Configuration"
FONT 8, "Verdana", 0, 0, 0x1
@ -102,11 +102,13 @@ BEGIN
LTEXT "Port 2",IDC_STATIC,23,48,20,10
LTEXT "Port 3",IDC_STATIC,23,69,20,10
LTEXT "Port 4",IDC_STATIC,23,90,20,10
GROUPBOX "Options",IDC_INPUT_OPTIONS,13,119,217,49,WS_GROUP,WS_EX_CLIENTEDGE
GROUPBOX "Options",IDC_INPUT_OPTIONS,13,119,217,64,WS_GROUP,WS_EX_CLIENTEDGE
EDITTEXT IDC_MOUSE_RANGE,95,129,121,14
EDITTEXT IDC_WHEEL_RANGE,95,147,121,14
LTEXT "Mouse axis range",IDC_STATIC,23,129,69,14,SS_CENTERIMAGE
LTEXT "Mouse wheel range",IDC_STATIC,23,146,68,14,SS_CENTERIMAGE
CONTROL "Ignore Keyboard/Mouse when unfocus",IDC_IGNORE_KBMO_UNFOCUS,
"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,23,166,139,10
END
IDD_XID_DUKE_CFG DIALOGEX 0, 0, 528, 280
@ -218,8 +220,8 @@ BEGIN
LTEXT "Oxygen Supply System",IDC_STATIC,133,118,80,14,SS_CENTERIMAGE
PUSHBUTTON "",IDC_FILT_CONTROL_SYSTEM,223,136,57,14,BS_FLAT
LTEXT "Filt Control System",IDC_STATIC,133,136,80,14,SS_CENTERIMAGE
PUSHBUTTON "",IDC_BTN_SIGHT_CHANGE,223,154,57,14, BS_FLAT
LTEXT "Sight Change",IDC_STATIC,133,154,80,14, SS_CENTERIMAGE
PUSHBUTTON "",IDC_BTN_SIGHT_CHANGE,223,154,57,14,BS_FLAT
LTEXT "Sight Change",IDC_STATIC,133,154,80,14,SS_CENTERIMAGE
PUSHBUTTON "",IDC_LEVER_LEFT,67,172,57,14,BS_FLAT
LTEXT "Lever Left",IDC_STATIC,25,172,42,14,SS_CENTERIMAGE
PUSHBUTTON "",IDC_LEVER_RIGHT,67,191,57,14,BS_FLAT
@ -387,7 +389,7 @@ BEGIN
COMBOBOX IDC_EE_AVSETTINGS,100,135,140,10,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_EE_AUDIOSETTINGS,100,150,140,10,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_EE_GAME_PRTL_CRTL,100,166,140,10,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_EE_PRTL_PASS,100,183,140,12, ES_PASSWORD
EDITTEXT IDC_EE_PRTL_PASS,100,183,140,12,ES_PASSWORD
COMBOBOX IDC_EE_MOVIE_PRTL_CRTL,100,198,140,10,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_EE_DVDREGION,100,214,140,10,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "PAL 60Hz",IDC_EE_PAL60HZ,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_DISABLED | WS_TABSTOP,13,235,50,10

View File

@ -195,6 +195,7 @@
#define ID_GUI_STATUS_XBOX_LED_COLOUR 1098
#define ID_GUI_STATUS_LOG_ENABLED 1099
#define IDC_AC_MUTE_WHEN_UNFOCUS 1100
#define IDC_IGNORE_KBMO_UNFOCUS 1101
#define IDC_XBOX_PORT_0 1158
#define IDC_XBOX_PORT_1 1166
#define IDC_XBOX_PORT_2 1174