Add L/R trigger button tilt support.

This commit is contained in:
Unknown W. Brackets
2015-12-20 23:16:45 -08:00
parent a89245a387
commit 64da0f54e4
3 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -387,7 +387,7 @@ void GameSettingsScreen::CreateViews() {
#if defined(MOBILE_DEVICE)
controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, co->T("HapticFeedback", "Haptic Feedback (vibration)")));
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons"};
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons", "L/R Trigger Buttons"};
controlsSettings->Add(new PopupMultiChoice(&g_Config.iTiltInputType, co->T("Tilt Input Type"), tiltTypes, 0, ARRAY_SIZE(tiltTypes), co->GetName(), screenManager()))->OnClick.Handle(this, &GameSettingsScreen::OnTiltTypeChange);
Choice *customizeTilt = controlsSettings->Add(new Choice(co->T("Customize tilt")));
+23
View File
@@ -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);
+4 -2
View File
@@ -6,7 +6,8 @@ namespace TiltEventProcessor {
TILT_NULL = 0,
TILT_ANALOG,
TILT_DPAD,
TILT_ACTION_BUTTON
TILT_ACTION_BUTTON,
TILT_TRIGGER_BUTTON,
};
@@ -33,7 +34,8 @@ namespace TiltEventProcessor {
//and the deadzone radius.
void GenerateAnalogStickEvent(const Tilt &tilt);
void GenerateDPadEvent(const Tilt &tilt);
void GenerateActionButtonEvent(const Tilt &tilt);
void GenerateActionButtonEvent(const Tilt &tilt);
void GenerateTriggerButtonEvent(const Tilt &tilt);
void ResetTiltEvents();