Add L/R trigger button tilt support.
This commit is contained in:
parent
a89245a387
commit
64da0f54e4
3 changed files with 28 additions and 3 deletions
|
@ -89,6 +89,10 @@ void TiltEventProcessor::TranslateTiltToInput(const Tilt &tilt) {
|
|||
case TILT_ACTION_BUTTON:
|
||||
GenerateActionButtonEvent(tilt);
|
||||
break;
|
||||
|
||||
case TILT_TRIGGER_BUTTON:
|
||||
GenerateTriggerButtonEvent(tilt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,6 +158,25 @@ void TiltEventProcessor::GenerateActionButtonEvent(const Tilt &tilt) {
|
|||
tiltButtonsDown |= buttons[direction];
|
||||
}
|
||||
|
||||
void TiltEventProcessor::GenerateTriggerButtonEvent(const Tilt &tilt) {
|
||||
u32 upButtons = 0;
|
||||
u32 downButtons = 0;
|
||||
// KISS, let's only look at X. Expect deadzone to already be applied.
|
||||
if (tilt.x_ == 0.0f) {
|
||||
upButtons = CTRL_LTRIGGER | CTRL_RTRIGGER;
|
||||
} else if (tilt.x_ < 0.0f) {
|
||||
downButtons = CTRL_LTRIGGER;
|
||||
upButtons = CTRL_RTRIGGER;
|
||||
} else if (tilt.x_ > 0.0f) {
|
||||
downButtons = CTRL_RTRIGGER;
|
||||
upButtons = CTRL_LTRIGGER;
|
||||
}
|
||||
|
||||
__CtrlButtonUp(upButtons);
|
||||
__CtrlButtonDown(downButtons);
|
||||
tiltButtonsDown = (tiltButtonsDown & ~upButtons) | downButtons;
|
||||
}
|
||||
|
||||
void TiltEventProcessor::ResetTiltEvents() {
|
||||
// Reset the buttons we have marked pressed.
|
||||
__CtrlButtonUp(tiltButtonsDown);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue