Merge pull request #7728 from jordan-woyak/pad-perfect-calib

SI_DeviceGCController: Calibrate to perfect neutral instead of initial input state.
This commit is contained in:
JMC47 2019-01-28 21:11:46 -05:00 committed by GitHub
commit 0e1669e1c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 28 deletions

View File

@ -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);

View File

@ -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);
};

View File

@ -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,