Skip to content

Commit

Permalink
add xbox configuration
Browse files Browse the repository at this point in the history
add spanish and thai translation
  • Loading branch information
duchuule committed Oct 7, 2015
1 parent ee61143 commit 2f78a7a
Show file tree
Hide file tree
Showing 7 changed files with 1,443 additions and 10 deletions.
87 changes: 77 additions & 10 deletions ControllerInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,100 @@ namespace VBA10
{
if(this->xboxPad->IsConnected())
{


XINPUT_STATE state = this->xboxPad->GetState();

if (EmulatorSettings::Current->TurboBehavior == 0)
this->state.TurboTogglePressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
else
this->state.TurboPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
ZeroMemory(&this->state, sizeof(ControllerState));


//buttons that do not allow reassignment
this->state.LeftPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) || (state.Gamepad.sThumbLX < (-XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
this->state.RightPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) || (state.Gamepad.sThumbLX > (XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
this->state.RightPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) || (state.Gamepad.sThumbLX >(XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
this->state.UpPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) || (state.Gamepad.sThumbLY > (XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
this->state.DownPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) || (state.Gamepad.sThumbLY < (-XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));

this->state.StartPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_START);
this->state.SelectPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK);

this->state.APressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_A);
this->state.BPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) || (state.Gamepad.wButtons & XINPUT_GAMEPAD_B);
this->state.LPressed = ( (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) || state.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD);
this->state.RPressed = ( (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) || state.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD);
//other buttons that allow reassignment
bool turboButtonPressed = false;

if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A)
GetMapping(EmulatorSettings::Current->XboxA, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.wButtons & XINPUT_GAMEPAD_B)
GetMapping(EmulatorSettings::Current->XboxB, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.wButtons & XINPUT_GAMEPAD_X)
GetMapping(EmulatorSettings::Current->XboxX, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.wButtons & XINPUT_GAMEPAD_Y)
GetMapping(EmulatorSettings::Current->XboxY, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) //L1
GetMapping(EmulatorSettings::Current->XboxL1, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) //R1
GetMapping(EmulatorSettings::Current->XboxR1, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) //L2
GetMapping(EmulatorSettings::Current->XboxL2, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) //R2
GetMapping(EmulatorSettings::Current->XboxR2, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

//this->state.TurboPressed = ((state.Gamepad.BCenterXTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) || (state.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD));
if (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) //L3
GetMapping(EmulatorSettings::Current->XboxL3, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) //R3
GetMapping(EmulatorSettings::Current->XboxR3, &this->state.APressed, &this->state.BPressed, &this->state.LPressed,
&this->state.RPressed, &turboButtonPressed);

if (EmulatorSettings::Current->TurboBehavior == 0)
this->state.TurboTogglePressed = turboButtonPressed;
else
this->state.TurboPressed = turboButtonPressed;






}else
{
ZeroMemory(&this->state, sizeof(ControllerState));
}
}


void ControllerInput::GetMapping(int pressedButton, bool* a, bool* b, bool* l, bool* r, bool* turbo)
{
if (pressedButton == 1)
*a = true;
else if (pressedButton == 2)
*b = true;
else if (pressedButton == 3)
*l = true;
else if (pressedButton == 4)
*r = true;
else if (pressedButton == 5)
{
*a = true;
*b = true;
}
else if (pressedButton == 6)
*turbo = true;
}

}
#endif
2 changes: 2 additions & 0 deletions ControllerInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace VBA10
private:
ControllerState state;
CXBOXController *xboxPad;

void GetMapping(int pressedButton, bool* a, bool* b, bool* l, bool* r, bool* turbo);
};
}
#endif
4 changes: 4 additions & 0 deletions HelpPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
<LineBreak />
<Run Text="- Vladimir Volkov for Russian translation."/>
<LineBreak />
<Run Text="- Andrés Ricaurte for Spanish translation."/>
<LineBreak />
<Run Text="- Danupol Intranurak for Thai translation."/>
<LineBreak />
<LineBreak />
<Run Text="The author is not responsible for any illegal use of this software. Further more, there is no warranty for this software and the author is not liable for any damages."/>
<LineBreak/>
Expand Down
Loading

0 comments on commit 2f78a7a

Please sign in to comment.