Fix configuration of analog shoulder buttons for analog turbo/slow motion when using a PS5 controller

This commit is contained in:
Lior Halphon 2021-06-01 00:46:06 +03:00
parent 1e5e236e84
commit b444ecd1ee
1 changed files with 28 additions and 13 deletions

View File

@ -478,31 +478,46 @@
static const unsigned gb_to_joykit[] = { static const unsigned gb_to_joykit[] = {
[GBRight]=JOYButtonUsageDPadRight, [GBRight] = JOYButtonUsageDPadRight,
[GBLeft]=JOYButtonUsageDPadLeft, [GBLeft] = JOYButtonUsageDPadLeft,
[GBUp]=JOYButtonUsageDPadUp, [GBUp] = JOYButtonUsageDPadUp,
[GBDown]=JOYButtonUsageDPadDown, [GBDown] = JOYButtonUsageDPadDown,
[GBA]=JOYButtonUsageA, [GBA] = JOYButtonUsageA,
[GBB]=JOYButtonUsageB, [GBB] = JOYButtonUsageB,
[GBSelect]=JOYButtonUsageSelect, [GBSelect] = JOYButtonUsageSelect,
[GBStart]=JOYButtonUsageStart, [GBStart] = JOYButtonUsageStart,
[GBTurbo]=JOYButtonUsageL1, [GBTurbo] = JOYButtonUsageL1,
[GBRewind]=JOYButtonUsageL2, [GBRewind] = JOYButtonUsageL2,
[GBUnderclock]=JOYButtonUsageR1, [GBUnderclock] = JOYButtonUsageR1,
}; };
// Todo: JoyKit might need an API to match an axis to a button
if (joystick_configuration_state == GBUnderclock) { if (joystick_configuration_state == GBUnderclock) {
for (JOYAxis *axis in controller.axes) { for (JOYAxis *axis in controller.axes) {
if (axis.value > 0.5) { if (axis.value > 0.5 ||
(axis.usage == JOYAxisUsageL1 && button.usage == JOYButtonUsageL1) ||
(axis.usage == JOYAxisUsageL2 && button.usage == JOYButtonUsageL2) ||
(axis.usage == JOYAxisUsageL3 && button.usage == JOYButtonUsageL3) ||
(axis.usage == JOYAxisUsageR1 && button.usage == JOYButtonUsageR1) ||
(axis.usage == JOYAxisUsageR2 && button.usage == JOYButtonUsageR2) ||
(axis.usage == JOYAxisUsageR3 && button.usage == JOYButtonUsageR3)) {
mapping[@"AnalogUnderclock"] = @(axis.uniqueID); mapping[@"AnalogUnderclock"] = @(axis.uniqueID);
break;
} }
} }
} }
if (joystick_configuration_state == GBTurbo) { if (joystick_configuration_state == GBTurbo) {
for (JOYAxis *axis in controller.axes) { for (JOYAxis *axis in controller.axes) {
if (axis.value > 0.5) { if (axis.value > 0.5 ||
(axis.usage == JOYAxisUsageL1 && button.usage == JOYButtonUsageL1) ||
(axis.usage == JOYAxisUsageL2 && button.usage == JOYButtonUsageL2) ||
(axis.usage == JOYAxisUsageL3 && button.usage == JOYButtonUsageL3) ||
(axis.usage == JOYAxisUsageR1 && button.usage == JOYButtonUsageR1) ||
(axis.usage == JOYAxisUsageR2 && button.usage == JOYButtonUsageR2) ||
(axis.usage == JOYAxisUsageR3 && button.usage == JOYButtonUsageR3)) {
mapping[@"AnalogTurbo"] = @(axis.uniqueID); mapping[@"AnalogTurbo"] = @(axis.uniqueID);
break;
} }
} }
} }