Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCPadStatus: coalescing magic numbers into consts #657

Merged
merged 1 commit into from Jul 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Source/Core/Core/HW/GCPad.cpp
Expand Up @@ -58,10 +58,10 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
{
// if gui has lock (messing with controls), skip this input cycle
// center axes and return
_pPADStatus->stickX = 0x80;
_pPADStatus->stickY = 0x80;
_pPADStatus->substickX = 0x80;
_pPADStatus->substickY = 0x80;
_pPADStatus->stickX = GCPadStatus::MAIN_STICK_CENTER_X;
_pPADStatus->stickY = GCPadStatus::MAIN_STICK_CENTER_Y;
_pPADStatus->substickX = GCPadStatus::C_STICK_CENTER_X;
_pPADStatus->substickY = GCPadStatus::C_STICK_CENTER_Y;
return;
}

Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Core/HW/GCPadEmu.cpp
Expand Up @@ -103,12 +103,12 @@ void GCPad::GetInput(GCPadStatus* const pad)

// sticks
m_main_stick->GetState(&x, &y);
pad->stickX = 0x80 + (x * 0x7F);
pad->stickY = 0x80 + (y * 0x7F);
pad->stickX = GCPadStatus::MAIN_STICK_CENTER_X + (x * GCPadStatus::MAIN_STICK_RADIUS);
pad->stickY = GCPadStatus::MAIN_STICK_CENTER_Y + (y * GCPadStatus::MAIN_STICK_RADIUS);

m_c_stick->GetState(&x, &y);
pad->substickX = 0x80 + (x * 0x7F);
pad->substickY = 0x80 + (y * 0x7F);
pad->substickX = GCPadStatus::C_STICK_CENTER_X + (x * GCPadStatus::C_STICK_RADIUS);
pad->substickY = GCPadStatus::C_STICK_CENTER_Y + (y * GCPadStatus::C_STICK_RADIUS);

// triggers
m_triggers->GetState(&pad->button, trigger_bitmasks, triggers);
Expand Down
16 changes: 8 additions & 8 deletions Source/Core/DolphinWX/TASInputDlg.cpp
Expand Up @@ -244,7 +244,7 @@ void TASInputDlg::ResetValues()

void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
{
if (PadStatus->stickX != 128)
if (PadStatus->stickX != GCPadStatus::MAIN_STICK_CENTER_X)
{
mainX = PadStatus->stickX;
mstickx = true;
Expand All @@ -254,11 +254,11 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (mstickx)
{
mstickx = false;
mainX = 128;
mainX = GCPadStatus::MAIN_STICK_CENTER_X;
wx_mainX_t->SetValue(wxString::Format("%i", mainX));
}

if (PadStatus->stickY != 128)
if (PadStatus->stickY != GCPadStatus::MAIN_STICK_CENTER_Y)
{
mainY = PadStatus->stickY;
msticky = true;
Expand All @@ -267,11 +267,11 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (msticky)
{
msticky = false;
mainY = 128;
mainY = GCPadStatus::MAIN_STICK_CENTER_Y;
wx_mainY_t->SetValue(wxString::Format("%i", mainY));
}

if (PadStatus->substickX != 128)
if (PadStatus->substickX != GCPadStatus::C_STICK_CENTER_X)
{
cX = PadStatus->substickX;
cstickx = true;
Expand All @@ -280,11 +280,11 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (cstickx)
{
cstickx = false;
cX = 128;
cX = GCPadStatus::C_STICK_CENTER_X;
wx_cX_t->SetValue(wxString::Format("%i", cX));
}

if (PadStatus->substickY != 128)
if (PadStatus->substickY != GCPadStatus::C_STICK_CENTER_Y)
{
cY = PadStatus->substickY;
csticky = true;
Expand All @@ -293,7 +293,7 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (csticky)
{
csticky = false;
cY = 128;
cY = GCPadStatus::C_STICK_CENTER_Y;
wx_cY_t->SetValue(wxString::Format("%i", cY));
}

Expand Down
7 changes: 7 additions & 0 deletions Source/Core/InputCommon/GCPadStatus.h
Expand Up @@ -45,4 +45,11 @@ struct GCPadStatus
unsigned char analogA; // 0 <= analogA <= 255
unsigned char analogB; // 0 <= analogB <= 255
signed char err; // one of PAD_ERR_* number

static const u8 MAIN_STICK_CENTER_X = 0x80;
static const u8 MAIN_STICK_CENTER_Y = 0x80;
static const u8 MAIN_STICK_RADIUS = 0x7f;
static const u8 C_STICK_CENTER_X = 0x80;
static const u8 C_STICK_CENTER_Y = 0x80;
static const u8 C_STICK_RADIUS = 0x7f;
};