Files
MesenCE/UI/Views/ControllerConfigViewLocator.cs
SourMesen 1489d34441 SNES: Added support for BlueRetro controller (#220)
This controller/adapter supports rumble as well as reading the state of both analog sticks and the L/R triggers.

Code by @RandalLinden
2026-07-16 05:10:26 -07:00

51 lines
1.9 KiB
C#

using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Mesen.Config;
using Mesen.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesen.Views
{
public class ControllerConfigViewLocator : IDataTemplate
{
public Control Build(object? data)
{
KeyMappingViewModel? mappings = data as KeyMappingViewModel;
if(mappings != null) {
return mappings.Type switch {
ControllerType.SnesController or ControllerType.SnesRumbleController or ControllerType.SnesBlueRetroController => new SnesControllerView(),
ControllerType.SnesNttDataKeypad => new SnesNttDataKeypadControllerView(),
ControllerType.NesController => new NesControllerView(),
ControllerType.FamicomController => new NesControllerView(),
ControllerType.FamicomControllerP2 => new NesControllerView(true),
ControllerType.BandaiHyperShot => new NesCustomControllerView(),
ControllerType.Pachinko => new NesCustomControllerView(),
ControllerType.FcnsController => new NesCustomControllerView(),
ControllerType.HoriTrack => new NesControllerView(),
ControllerType.GameboyController => new NesControllerView(),
ControllerType.GbaController => new GbaControllerView(),
ControllerType.PceController => new PceControllerView(),
ControllerType.PceAvenuePad6 => new PceAvenuePad6View(),
ControllerType.SmsController => new SmsControllerView(),
ControllerType.WsController => new WsControllerView(),
ControllerType.WsControllerVertical => new WsControllerVerticalView(),
ControllerType.Pcv2Controller => new WsPcv2ControllerView(),
_ => new DefaultControllerView()
};
}
return new TextBlock { Text = "No matching view found for controller type" };
}
public bool Match(object? data)
{
return data is KeyMappingViewModel;
}
}
}