mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Add L/R trigger button tilt support.
This commit is contained in:
@@ -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")));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user