Merge pull request #657 from booto/gcpademu_needs_less_magic

GCPadStatus: coalescing magic numbers into consts
This commit is contained in:
Dolphin Bot 2014-07-21 14:01:45 +02:00
commit 67ff926f1e
4 changed files with 23 additions and 16 deletions

View File

@ -58,10 +58,10 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
{ {
// if gui has lock (messing with controls), skip this input cycle // if gui has lock (messing with controls), skip this input cycle
// center axes and return // center axes and return
_pPADStatus->stickX = 0x80; _pPADStatus->stickX = GCPadStatus::MAIN_STICK_CENTER_X;
_pPADStatus->stickY = 0x80; _pPADStatus->stickY = GCPadStatus::MAIN_STICK_CENTER_Y;
_pPADStatus->substickX = 0x80; _pPADStatus->substickX = GCPadStatus::C_STICK_CENTER_X;
_pPADStatus->substickY = 0x80; _pPADStatus->substickY = GCPadStatus::C_STICK_CENTER_Y;
return; return;
} }

View File

@ -103,12 +103,12 @@ void GCPad::GetInput(GCPadStatus* const pad)
// sticks // sticks
m_main_stick->GetState(&x, &y); m_main_stick->GetState(&x, &y);
pad->stickX = 0x80 + (x * 0x7F); pad->stickX = GCPadStatus::MAIN_STICK_CENTER_X + (x * GCPadStatus::MAIN_STICK_RADIUS);
pad->stickY = 0x80 + (y * 0x7F); pad->stickY = GCPadStatus::MAIN_STICK_CENTER_Y + (y * GCPadStatus::MAIN_STICK_RADIUS);
m_c_stick->GetState(&x, &y); m_c_stick->GetState(&x, &y);
pad->substickX = 0x80 + (x * 0x7F); pad->substickX = GCPadStatus::C_STICK_CENTER_X + (x * GCPadStatus::C_STICK_RADIUS);
pad->substickY = 0x80 + (y * 0x7F); pad->substickY = GCPadStatus::C_STICK_CENTER_Y + (y * GCPadStatus::C_STICK_RADIUS);
// triggers // triggers
m_triggers->GetState(&pad->button, trigger_bitmasks, triggers); m_triggers->GetState(&pad->button, trigger_bitmasks, triggers);

View File

@ -244,7 +244,7 @@ void TASInputDlg::ResetValues()
void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus) void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
{ {
if (PadStatus->stickX != 128) if (PadStatus->stickX != GCPadStatus::MAIN_STICK_CENTER_X)
{ {
mainX = PadStatus->stickX; mainX = PadStatus->stickX;
mstickx = true; mstickx = true;
@ -254,11 +254,11 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (mstickx) else if (mstickx)
{ {
mstickx = false; mstickx = false;
mainX = 128; mainX = GCPadStatus::MAIN_STICK_CENTER_X;
wx_mainX_t->SetValue(wxString::Format("%i", mainX)); wx_mainX_t->SetValue(wxString::Format("%i", mainX));
} }
if (PadStatus->stickY != 128) if (PadStatus->stickY != GCPadStatus::MAIN_STICK_CENTER_Y)
{ {
mainY = PadStatus->stickY; mainY = PadStatus->stickY;
msticky = true; msticky = true;
@ -267,11 +267,11 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (msticky) else if (msticky)
{ {
msticky = false; msticky = false;
mainY = 128; mainY = GCPadStatus::MAIN_STICK_CENTER_Y;
wx_mainY_t->SetValue(wxString::Format("%i", mainY)); wx_mainY_t->SetValue(wxString::Format("%i", mainY));
} }
if (PadStatus->substickX != 128) if (PadStatus->substickX != GCPadStatus::C_STICK_CENTER_X)
{ {
cX = PadStatus->substickX; cX = PadStatus->substickX;
cstickx = true; cstickx = true;
@ -280,11 +280,11 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (cstickx) else if (cstickx)
{ {
cstickx = false; cstickx = false;
cX = 128; cX = GCPadStatus::C_STICK_CENTER_X;
wx_cX_t->SetValue(wxString::Format("%i", cX)); wx_cX_t->SetValue(wxString::Format("%i", cX));
} }
if (PadStatus->substickY != 128) if (PadStatus->substickY != GCPadStatus::C_STICK_CENTER_Y)
{ {
cY = PadStatus->substickY; cY = PadStatus->substickY;
csticky = true; csticky = true;
@ -293,7 +293,7 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
else if (csticky) else if (csticky)
{ {
csticky = false; csticky = false;
cY = 128; cY = GCPadStatus::C_STICK_CENTER_Y;
wx_cY_t->SetValue(wxString::Format("%i", cY)); wx_cY_t->SetValue(wxString::Format("%i", cY));
} }

View File

@ -45,4 +45,11 @@ struct GCPadStatus
unsigned char analogA; // 0 <= analogA <= 255 unsigned char analogA; // 0 <= analogA <= 255
unsigned char analogB; // 0 <= analogB <= 255 unsigned char analogB; // 0 <= analogB <= 255
signed char err; // one of PAD_ERR_* number 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;
}; };