diff --git a/Core/PCE/Input/PceController.h b/Core/PCE/Input/PceController.h index 0e53f0cf2..10bcebad2 100644 --- a/Core/PCE/Input/PceController.h +++ b/Core/PCE/Input/PceController.h @@ -44,6 +44,18 @@ class PceController : public BaseControlDevice ClearBit(Buttons::Run); ClearBit(Buttons::Select); } + + if(!_emu->GetSettings()->GetPcEngineConfig().AllowInvalidInput) { + //If both U+D or L+R are pressed at the same time, act as if neither is pressed + if(IsPressed(Buttons::Up) && IsPressed(Buttons::Down)) { + ClearBit(Buttons::Down); + ClearBit(Buttons::Up); + } + if(IsPressed(Buttons::Left) && IsPressed(Buttons::Right)) { + ClearBit(Buttons::Left); + ClearBit(Buttons::Right); + } + } } void RefreshStateBuffer() override diff --git a/Core/SMS/Input/SmsController.h b/Core/SMS/Input/SmsController.h index 4f506db26..794c0c4fc 100644 --- a/Core/SMS/Input/SmsController.h +++ b/Core/SMS/Input/SmsController.h @@ -35,6 +35,18 @@ class SmsController : public BaseControlDevice SetPressedState(Buttons::A, keyMapping.TurboA); SetPressedState(Buttons::B, keyMapping.TurboB); } + + if(!_emu->GetSettings()->GetSmsConfig().AllowInvalidInput) { + //If both U+D or L+R are pressed at the same time, act as if neither is pressed + if(IsPressed(Buttons::Up) && IsPressed(Buttons::Down)) { + ClearBit(Buttons::Down); + ClearBit(Buttons::Up); + } + if(IsPressed(Buttons::Left) && IsPressed(Buttons::Right)) { + ClearBit(Buttons::Left); + ClearBit(Buttons::Right); + } + } } } diff --git a/Core/SNES/Input/SnesController.cpp b/Core/SNES/Input/SnesController.cpp index 640891d1e..2f28a06f4 100644 --- a/Core/SNES/Input/SnesController.cpp +++ b/Core/SNES/Input/SnesController.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "SNES/Input/SnesController.h" #include "Shared/Emulator.h" +#include "Shared/EmuSettings.h" #include "Shared/InputHud.h" SnesController::SnesController(Emulator* emu, uint8_t port, KeyMappingSet keyMappings) : BaseControlDevice(emu, ControllerType::SnesController, port, keyMappings) @@ -39,6 +40,19 @@ void SnesController::InternalSetStateFromInput() SetPressedState(Buttons::L, keyMapping.TurboL); SetPressedState(Buttons::R, keyMapping.TurboR); } + + bool allowInvalidInput = _emu->GetConsoleType() == ConsoleType::Nes ? _emu->GetSettings()->GetNesConfig().AllowInvalidInput : _emu->GetSettings()->GetSnesConfig().AllowInvalidInput; + if(!allowInvalidInput) { + //If both U+D or L+R are pressed at the same time, act as if neither is pressed + if(IsPressed(Buttons::Up) && IsPressed(Buttons::Down)) { + ClearBit(Buttons::Down); + ClearBit(Buttons::Up); + } + if(IsPressed(Buttons::Left) && IsPressed(Buttons::Right)) { + ClearBit(Buttons::Left); + ClearBit(Buttons::Right); + } + } } } diff --git a/Core/Shared/SettingTypes.h b/Core/Shared/SettingTypes.h index 2228ea5ac..4090fbe4e 100644 --- a/Core/Shared/SettingTypes.h +++ b/Core/Shared/SettingTypes.h @@ -497,6 +497,7 @@ struct PcEngineConfig ControllerConfig Port1; ControllerConfig Port1SubPorts[5]; + bool AllowInvalidInput = false; bool PreventSelectRunReset = false; PceConsoleType ConsoleType = PceConsoleType::Auto; @@ -542,6 +543,7 @@ struct SnesConfig ConsoleRegion Region = ConsoleRegion::Auto; + bool AllowInvalidInput = false; bool BlendHighResolutionModes = false; bool HideBgLayer1 = false; bool HideBgLayer2 = false; @@ -693,6 +695,7 @@ struct SmsConfig SmsRevision Revision = SmsRevision::Compatibility; + bool AllowInvalidInput = false; bool UseSgPalette = false; bool GgBlendFrames = true; bool RemoveSpriteLimit = false; diff --git a/UI/Config/PcEngineConfig.cs b/UI/Config/PcEngineConfig.cs index 784a0f8ba..e54307582 100644 --- a/UI/Config/PcEngineConfig.cs +++ b/UI/Config/PcEngineConfig.cs @@ -24,6 +24,7 @@ public class PcEngineConfig : BaseConfig [Reactive] public ControllerConfig Port1D { get; set; } = new(); [Reactive] public ControllerConfig Port1E { get; set; } = new(); + [Reactive] public bool AllowInvalidInput { get; set; } = false; [Reactive] public bool PreventSelectRunReset { get; set; } = true; [Reactive] public PceConsoleType ConsoleType { get; set; } = PceConsoleType.Auto; @@ -68,6 +69,7 @@ public void ApplyConfig() Port1D = Port1D.ToInterop(), Port1E = Port1E.ToInterop(), + AllowInvalidInput = this.AllowInvalidInput, PreventSelectRunReset = PreventSelectRunReset, ConsoleType = ConsoleType, @@ -119,6 +121,7 @@ public struct InteropPcEngineConfig public InteropControllerConfig Port1D; public InteropControllerConfig Port1E; + [MarshalAs(UnmanagedType.I1)] public bool AllowInvalidInput; [MarshalAs(UnmanagedType.I1)] public bool PreventSelectRunReset; public PceConsoleType ConsoleType; diff --git a/UI/Config/SmsConfig.cs b/UI/Config/SmsConfig.cs index 0181f2e7c..c25525be7 100644 --- a/UI/Config/SmsConfig.cs +++ b/UI/Config/SmsConfig.cs @@ -19,6 +19,8 @@ public class SmsConfig : BaseConfig [Reactive] public SmsControllerConfig Port1 { get; set; } = new(); [Reactive] public SmsControllerConfig Port2 { get; set; } = new(); + [Reactive] public bool AllowInvalidInput { get; set; } = false; + [ValidValues(ConsoleRegion.Auto, ConsoleRegion.Ntsc, ConsoleRegion.Pal)] [Reactive] public ConsoleRegion Region { get; set; } = ConsoleRegion.Auto; @@ -59,6 +61,7 @@ public void ApplyConfig() RamPowerOnState = RamPowerOnState, Revision = Revision, + AllowInvalidInput = this.AllowInvalidInput, UseSgPalette = UseSgPalette, GgBlendFrames = GgBlendFrames, RemoveSpriteLimit = RemoveSpriteLimit, @@ -95,6 +98,7 @@ public struct InteropSmsConfig public RamState RamPowerOnState; public SmsRevision Revision; + [MarshalAs(UnmanagedType.I1)] public bool AllowInvalidInput; [MarshalAs(UnmanagedType.I1)] public bool UseSgPalette; [MarshalAs(UnmanagedType.I1)] public bool GgBlendFrames; [MarshalAs(UnmanagedType.I1)] public bool RemoveSpriteLimit; diff --git a/UI/Config/SnesConfig.cs b/UI/Config/SnesConfig.cs index 832fdeef1..19c4179c1 100644 --- a/UI/Config/SnesConfig.cs +++ b/UI/Config/SnesConfig.cs @@ -27,6 +27,8 @@ public class SnesConfig : BaseConfig [Reactive] public SnesControllerConfig Port2C { get; set; } = new SnesControllerConfig(); [Reactive] public SnesControllerConfig Port2D { get; set; } = new SnesControllerConfig(); + [Reactive] public bool AllowInvalidInput { get; set; } = false; + [ValidValues(ConsoleRegion.Auto, ConsoleRegion.Ntsc, ConsoleRegion.Pal)] [Reactive] public ConsoleRegion Region { get; set; } = ConsoleRegion.Auto; @@ -88,6 +90,8 @@ public void ApplyConfig() Region = this.Region, + AllowInvalidInput = this.AllowInvalidInput, + BlendHighResolutionModes = this.BlendHighResolutionModes, HideBgLayer1 = this.HideBgLayer1, HideBgLayer2 = this.HideBgLayer2, @@ -146,6 +150,7 @@ public struct InteropSnesConfig public ConsoleRegion Region; + [MarshalAs(UnmanagedType.I1)] public bool AllowInvalidInput; [MarshalAs(UnmanagedType.I1)] public bool BlendHighResolutionModes; [MarshalAs(UnmanagedType.I1)] public bool HideBgLayer1; [MarshalAs(UnmanagedType.I1)] public bool HideBgLayer2; diff --git a/UI/Localization/resources.en.xml b/UI/Localization/resources.en.xml index f2b4ed471..5058939c5 100644 --- a/UI/Localization/resources.en.xml +++ b/UI/Localization/resources.en.xml @@ -48,6 +48,7 @@ Controllers General Automatically configure controllers when loading a game + Allow invalid input (e.g Down + Up or Left + Right at the same time) Light detection radius for light guns: Small Large @@ -88,6 +89,10 @@ Port 4: Multitap Configuration Warning: Your current configuration contains conflicting key bindings - some physical buttons on your keyboard or gamepad are mapped to multiple buttons on the NES controller. If this is not intentional, please review and correct your key bindings. + + Controllers + General + Allow invalid input (e.g Down + Up or Left + Right at the same time)
General @@ -352,7 +357,6 @@ Enable DMC sample duplication glitch (late-G & H CPU behavior) Enable CPU test mode registers Console model: - Allow invalid input (e.g Down + Up or Left + Right at the same time)
@@ -362,6 +366,7 @@ Emulation Default power on state for RAM: + General Allow invalid input (e.g Down + Up or Left + Right at the same time) Video @@ -406,6 +411,7 @@ Save Type: Real-Time Clock: Default power on state for RAM: + General Allow invalid input (e.g Down + Up or Left + Right at the same time) Enable mGBA log API @@ -502,7 +508,8 @@ Port 4: Port 5: - Input settings + General + Allow invalid input (e.g Down + Up or Left + Right at the same time) Disable Run+Select combination (to avoid resets in games)
@@ -559,6 +566,9 @@ Port 2: General + + General + Allow invalid input (e.g Down + Up or Left + Right at the same time)
diff --git a/UI/Views/GameboyConfigView.axaml b/UI/Views/GameboyConfigView.axaml index b02efe92b..99ecf9baa 100644 --- a/UI/Views/GameboyConfigView.axaml +++ b/UI/Views/GameboyConfigView.axaml @@ -69,23 +69,27 @@ - - - - -