summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2019-01-28 21:11:46 -0500
committerGitHub <noreply@github.com>2019-01-28 21:11:46 -0500
commit0e1669e1c7adef2fa5ef0db402b71c0f5c1f0dc4 (patch)
treed093fbbab3538ea35ec2e68baf3b7bf12642b4ae /Source/Core
parentcf8da5629759514d07482ae7455ee89505dcab14 (diff)
parent3cd3e84486a54d8c53d89ed2aaf23e5931821443 (diff)
Merge pull request #7728 from jordan-woyak/pad-perfect-calib
SI_DeviceGCController: Calibrate to perfect neutral instead of initial input state.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/SI/SI_DeviceGCController.cpp30
-rw-r--r--Source/Core/Core/HW/SI/SI_DeviceGCController.h8
-rw-r--r--Source/Core/Core/State.cpp2
3 files changed, 12 insertions, 28 deletions
diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
index 441981178e..7e6ee9bd3f 100644
--- a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
+++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
@@ -26,21 +26,14 @@ namespace SerialInterface
CSIDevice_GCController::CSIDevice_GCController(SIDevices device, int device_number)
: ISIDevice(device, device_number)
{
-}
-
-void CSIDevice_GCController::Calibrate()
-{
- GCPadStatus pad_origin = GetPadStatus();
- memset(&m_origin, 0, sizeof(SOrigin));
- m_origin.button = pad_origin.button;
- m_origin.origin_stick_x = pad_origin.stickX;
- m_origin.origin_stick_y = pad_origin.stickY;
- m_origin.substick_x = pad_origin.substickX;
- m_origin.substick_y = pad_origin.substickY;
- m_origin.trigger_left = pad_origin.triggerLeft;
- m_origin.trigger_right = pad_origin.triggerRight;
-
- m_calibrated = true;
+ // Here we set origin to perfectly centered values.
+ // This purposely differs from real hardware which sets origin to current input state.
+ // That behavior is less than ideal as the user may have inadvertently moved from neutral.
+ // The X+Y+Start button combo can override this if desired.
+ m_origin.origin_stick_x = GCPadStatus::MAIN_STICK_CENTER_X;
+ m_origin.origin_stick_y = GCPadStatus::MAIN_STICK_CENTER_Y;
+ m_origin.substick_x = GCPadStatus::C_STICK_CENTER_X;
+ m_origin.substick_y = GCPadStatus::C_STICK_CENTER_Y;
}
int CSIDevice_GCController::RunBuffer(u8* buffer, int length)
@@ -87,9 +80,6 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int length)
{
INFO_LOG(SERIALINTERFACE, "PAD - Get Origin");
- if (!m_calibrated)
- Calibrate();
-
u8* calibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
@@ -103,9 +93,6 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int length)
{
INFO_LOG(SERIALINTERFACE, "PAD - Recalibrate");
- if (!m_calibrated)
- Calibrate();
-
u8* calibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
@@ -336,7 +323,6 @@ void CSIDevice_GCController::SendCommand(u32 command, u8 poll)
// Savestate support
void CSIDevice_GCController::DoState(PointerWrap& p)
{
- p.Do(m_calibrated);
p.Do(m_origin);
p.Do(m_mode);
p.Do(m_timer_button_combo_start);
diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.h b/Source/Core/Core/HW/SI/SI_DeviceGCController.h
index 8c117ccc3b..b42f574613 100644
--- a/Source/Core/Core/HW/SI/SI_DeviceGCController.h
+++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.h
@@ -65,10 +65,9 @@ protected:
};
// struct to compare input against
- // Set on connection and (standard pad only) on button combo
- SOrigin m_origin;
-
- bool m_calibrated = false;
+ // Set on connection to perfect neutral values
+ // (standard pad only) Set on button combo to current input state
+ SOrigin m_origin = {};
// PADAnalogMode
// Dunno if we need to do this, game/lib should set it?
@@ -111,7 +110,6 @@ public:
static void Rumble(int pad_num, ControlState strength);
protected:
- void Calibrate();
void HandleMoviePadStatus(GCPadStatus* pad_status);
};
diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp
index 15c51c7986..65416a5589 100644
--- a/Source/Core/Core/State.cpp
+++ b/Source/Core/Core/State.cpp
@@ -74,7 +74,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
static std::thread g_save_thread;
// Don't forget to increase this after doing changes on the savestate system
-static const u32 STATE_VERSION = 99; // Last changed in PR 6020
+static const u32 STATE_VERSION = 100; // Last changed in PR 7728
// Maps savestate versions to Dolphin versions.
// Versions after 42 don't need to be added to this list,