input: fix general settings to use simplified getter/setter.

This commit is contained in:
RadWolfie 2021-03-17 09:30:18 -05:00
parent 4985d9ca7e
commit 327490a8ed
6 changed files with 20 additions and 30 deletions

View File

@ -744,7 +744,7 @@ void Settings::SyncToEmulator()
// register Network settings // register Network settings
g_EmuShared->SetNetworkSettings(&m_network); g_EmuShared->SetNetworkSettings(&m_network);
// register Input settings // register Input gamepad settings
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
g_EmuShared->SetInputDevTypeSettings(&m_input_port[i].Type, i); g_EmuShared->SetInputDevTypeSettings(&m_input_port[i].Type, i);
if (m_input_port[i].Type != to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID)) { if (m_input_port[i].Type != to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID)) {
@ -766,9 +766,8 @@ void Settings::SyncToEmulator()
} }
} }
g_EmuShared->SetInputMoAxisSettings(m_input_general.MoAxisRange); // register Input general settings
g_EmuShared->SetInputMoWheelSettings(m_input_general.MoWheelRange); g_EmuShared->SetInputGeneralSettings(&m_input_general);
g_EmuShared->SetInputKbMoUnfocusSettings(m_input_general.IgnoreKbMoUnfocus);
// register Hacks settings // register Hacks settings
g_EmuShared->SetHackSettings(&m_hacks); g_EmuShared->SetHackSettings(&m_hacks);

View File

@ -134,12 +134,14 @@ public:
} m_audio; } m_audio;
static_assert(sizeof(s_audio) == 0x4C, assert_check_shared_memory(s_audio)); static_assert(sizeof(s_audio) == 0x4C, assert_check_shared_memory(s_audio));
// Input general settings
struct s_input_general { struct s_input_general {
long MoAxisRange; long MoAxisRange;
long MoWheelRange; long MoWheelRange;
bool IgnoreKbMoUnfocus; bool IgnoreKbMoUnfocus;
}; bool Reserved1[3];
s_input_general m_input_general; } m_input_general;
static_assert(sizeof(s_input_general) == 0xC, assert_check_shared_memory(s_input_general));
struct s_input_port { struct s_input_port {
int Type; int Type;

View File

@ -706,16 +706,13 @@ std::shared_ptr<InputDevice> InputDeviceManager::FindDevice(int usb_port, int du
void InputDeviceManager::UpdateOpt(bool is_gui) void InputDeviceManager::UpdateOpt(bool is_gui)
{ {
if (!is_gui) { if (!is_gui) {
long axis_range, wheel_range; Settings::s_input_general input_general;
bool ignore_kbmo; g_EmuShared->GetInputGeneralSettings(&input_general);
g_EmuShared->GetInputMoAxisSettings(&axis_range); DInput::mo_axis_range_pos = input_general.MoAxisRange;
g_EmuShared->GetInputMoWheelSettings(&wheel_range); DInput::mo_wheel_range_pos = input_general.MoWheelRange;
g_EmuShared->GetInputKbMoUnfocusSettings(&ignore_kbmo); DInput::mo_axis_range_neg = -(input_general.MoAxisRange);
DInput::mo_axis_range_pos = axis_range; DInput::mo_wheel_range_neg = -(input_general.MoWheelRange);
DInput::mo_wheel_range_pos = wheel_range; DInput::IgnoreKbMoUnfocus = input_general.IgnoreKbMoUnfocus;
DInput::mo_axis_range_neg = -(axis_range);
DInput::mo_wheel_range_neg = -(wheel_range);
DInput::IgnoreKbMoUnfocus = ignore_kbmo;
} }
else { else {
DInput::mo_axis_range_pos = g_Settings->m_input_general.MoAxisRange; DInput::mo_axis_range_pos = g_Settings->m_input_general.MoAxisRange;

View File

@ -152,7 +152,6 @@ EmuShared::EmuShared()
m_bEmulating_status = false; m_bEmulating_status = false;
m_bFirstLaunch = false; m_bFirstLaunch = false;
m_bClipCursor = false; m_bClipCursor = false;
m_bIgnoreKbMoUnfocus = true;
// Reserve space (default to 0) // Reserve space (default to 0)
m_bReserved4 = false; m_bReserved4 = false;

View File

@ -152,12 +152,8 @@ class EmuShared : public Mutex
// ****************************************************************** // ******************************************************************
// * Input option Accessors // * Input option Accessors
// ****************************************************************** // ******************************************************************
void GetInputMoAxisSettings(long *axis) { Lock(); *axis = m_MoAxisRange; Unlock(); } void GetInputGeneralSettings(Settings::s_input_general *input_general) { Lock(); *input_general = m_input_general; Unlock(); }
void SetInputMoAxisSettings(const long axis) { Lock(); m_MoAxisRange = axis; Unlock(); } void SetInputGeneralSettings(const Settings::s_input_general *input_general) { Lock(); m_input_general = *input_general; 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 // * LLE Flags Accessors
@ -301,15 +297,13 @@ class EmuShared : public Mutex
#endif #endif
bool m_bFirstLaunch; bool m_bFirstLaunch;
bool m_bClipCursor; bool m_bClipCursor;
bool m_bIgnoreKbMoUnfocus; bool m_bReserved3;
bool m_bReserved4; bool m_bReserved4;
unsigned int m_dwKrnlProcID; // Only used for kernel mode level. unsigned int m_dwKrnlProcID; // Only used for kernel mode level.
int m_DeviceType[4]; int m_DeviceType[4];
char m_DeviceControlNames[4][HIGHEST_NUM_BUTTONS][HOST_BUTTON_NAME_LENGTH]; char m_DeviceControlNames[4][HIGHEST_NUM_BUTTONS][HOST_BUTTON_NAME_LENGTH];
char m_DeviceName[4][50]; char m_DeviceName[4][50];
long m_MoAxisRange; int m_Reserved99[28]; // Reserve space
long m_MoWheelRange;
int m_Reserved99[26]; // Reserve space
// Settings class in memory should not be tampered by third-party. // Settings class in memory should not be tampered by third-party.
// Third-party program should only be allow to edit settings.ini file. // Third-party program should only be allow to edit settings.ini file.
@ -317,6 +311,7 @@ class EmuShared : public Mutex
Settings::s_video m_video; Settings::s_video m_video;
Settings::s_audio m_audio; Settings::s_audio m_audio;
Settings::s_network m_network; Settings::s_network m_network;
Settings::s_input_general m_input_general;
Settings::s_hack m_hacks; Settings::s_hack m_hacks;
}; };

View File

@ -74,9 +74,7 @@ void SyncInputSettings(int port_num, int dev_type, bool is_opt)
} }
} }
else { else {
g_EmuShared->SetInputMoAxisSettings(g_Settings->m_input_general.MoAxisRange); g_EmuShared->SetInputGeneralSettings(&g_Settings->m_input_general);
g_EmuShared->SetInputMoWheelSettings(g_Settings->m_input_general.MoWheelRange);
g_EmuShared->SetInputKbMoUnfocusSettings(g_Settings->m_input_general.IgnoreKbMoUnfocus);
port_num = PORT_INVALID; port_num = PORT_INVALID;
} }
#if 0 // lle usb #if 0 // lle usb