From 83bf40491b966a7252ba50e4d5ee7be9f74a7a43 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Wed, 12 Aug 2026 14:55:04 -0400 Subject: [PATCH] fix: Refine touchpanel device selection and logging Improve logic to check for MPC3Basic type using pattern matching. Update debug and error messages to report actual device type. Clarify conditional structure for better readability. --- .../Touchpanels/Mpc4Touchpanel.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Mpc4Touchpanel.cs b/src/PepperDash.Essentials.Core/Touchpanels/Mpc4Touchpanel.cs index 5de2f69a..ef9df608 100644 --- a/src/PepperDash.Essentials.Core/Touchpanels/Mpc4Touchpanel.cs +++ b/src/PepperDash.Essentials.Core/Touchpanels/Mpc4Touchpanel.cs @@ -48,15 +48,14 @@ namespace PepperDash.Essentials.Core.Touchpanels Debug.LogMessage(LogEventLevel.Information, this, "Using MPC4x302TouchscreenSlot"); _touchpanel = processor.MPC4x302TouchscreenSlot; } + else if (processor.ControllerTouchScreenSlotDevice != null && processor.ControllerTouchScreenSlotDevice is MPC3Basic mpc) + { + Debug.LogMessage(LogEventLevel.Information, this, "Using ControllerTouchScreenSlotDevice:{0}", processor.ControllerTouchScreenSlotDevice.GetType().Name); + _touchpanel = mpc; + } else { - Debug.LogMessage(LogEventLevel.Information, this, "Using ControllerTouchScreenSlotDevice"); - _touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; - } - - if (_touchpanel == null) - { - Debug.LogMessage(LogEventLevel.Error, this, "Failed to construct MPC4 Touchpanel Controller with key {0}, check configuration, processor is type: {1}", key, processor.TouchscreenType); + Debug.LogMessage(LogEventLevel.Error, this, "Failed to find MPC4 Touchpanel Controller with key {0}, check configuration, processor is type: {1}", key, processor.ControllerTouchScreenSlotDevice?.GetType().Name ?? "unknown"); return; }