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:
commit
0e1669e1c7
|
@ -26,21 +26,14 @@ namespace SerialInterface
|
||||||
CSIDevice_GCController::CSIDevice_GCController(SIDevices device, int device_number)
|
CSIDevice_GCController::CSIDevice_GCController(SIDevices device, int device_number)
|
||||||
: ISIDevice(device, device_number)
|
: ISIDevice(device, device_number)
|
||||||
{
|
{
|
||||||
}
|
// Here we set origin to perfectly centered values.
|
||||||
|
// This purposely differs from real hardware which sets origin to current input state.
|
||||||
void CSIDevice_GCController::Calibrate()
|
// 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.
|
||||||
GCPadStatus pad_origin = GetPadStatus();
|
m_origin.origin_stick_x = GCPadStatus::MAIN_STICK_CENTER_X;
|
||||||
memset(&m_origin, 0, sizeof(SOrigin));
|
m_origin.origin_stick_y = GCPadStatus::MAIN_STICK_CENTER_Y;
|
||||||
m_origin.button = pad_origin.button;
|
m_origin.substick_x = GCPadStatus::C_STICK_CENTER_X;
|
||||||
m_origin.origin_stick_x = pad_origin.stickX;
|
m_origin.substick_y = GCPadStatus::C_STICK_CENTER_Y;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSIDevice_GCController::RunBuffer(u8* buffer, int length)
|
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");
|
INFO_LOG(SERIALINTERFACE, "PAD - Get Origin");
|
||||||
|
|
||||||
if (!m_calibrated)
|
|
||||||
Calibrate();
|
|
||||||
|
|
||||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
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");
|
INFO_LOG(SERIALINTERFACE, "PAD - Recalibrate");
|
||||||
|
|
||||||
if (!m_calibrated)
|
|
||||||
Calibrate();
|
|
||||||
|
|
||||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
||||||
{
|
{
|
||||||
|
@ -336,7 +323,6 @@ void CSIDevice_GCController::SendCommand(u32 command, u8 poll)
|
||||||
// Savestate support
|
// Savestate support
|
||||||
void CSIDevice_GCController::DoState(PointerWrap& p)
|
void CSIDevice_GCController::DoState(PointerWrap& p)
|
||||||
{
|
{
|
||||||
p.Do(m_calibrated);
|
|
||||||
p.Do(m_origin);
|
p.Do(m_origin);
|
||||||
p.Do(m_mode);
|
p.Do(m_mode);
|
||||||
p.Do(m_timer_button_combo_start);
|
p.Do(m_timer_button_combo_start);
|
||||||
|
|
|
@ -65,10 +65,9 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
// struct to compare input against
|
// struct to compare input against
|
||||||
// Set on connection and (standard pad only) on button combo
|
// Set on connection to perfect neutral values
|
||||||
SOrigin m_origin;
|
// (standard pad only) Set on button combo to current input state
|
||||||
|
SOrigin m_origin = {};
|
||||||
bool m_calibrated = false;
|
|
||||||
|
|
||||||
// PADAnalogMode
|
// PADAnalogMode
|
||||||
// Dunno if we need to do this, game/lib should set it?
|
// 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);
|
static void Rumble(int pad_num, ControlState strength);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Calibrate();
|
|
||||||
void HandleMoviePadStatus(GCPadStatus* pad_status);
|
void HandleMoviePadStatus(GCPadStatus* pad_status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
|
||||||
static std::thread g_save_thread;
|
static std::thread g_save_thread;
|
||||||
|
|
||||||
// Don't forget to increase this after doing changes on the savestate system
|
// 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.
|
// Maps savestate versions to Dolphin versions.
|
||||||
// Versions after 42 don't need to be added to this list,
|
// Versions after 42 don't need to be added to this list,
|
||||||
|
|
Loading…
Reference in New Issue