diff --git a/Core/Helpers/DiagnosticsBundle.cs b/Core/Helpers/DiagnosticsBundle.cs
index 6f6b7ff..3ed6d5b 100644
--- a/Core/Helpers/DiagnosticsBundle.cs
+++ b/Core/Helpers/DiagnosticsBundle.cs
@@ -1,4 +1,5 @@
using Microsoft.Win32;
+using OpenStreamMS.Services.Gamepad;
using OpenStreamMS.Core.Api;
using OpenStreamMS.Services;
using OpenStreamMS.Services.Drivers;
@@ -76,6 +77,7 @@ void Section(string name, Action action)
Section("procs", () => AddText(zip, "processes.txt", Processes(), redact));
Section("ports", () => AddText(zip, "listening-ports.txt", ListeningPorts(), redact));
Section("pnp", () => AddText(zip, "pnputil-problem-devices.txt", Run("pnputil.exe", "/enum-devices /problem"), redact));
+ Section("controllers", () => AddText(zip, "controllers.txt", Controllers(), redact));
Section("drivers", () => AddText(zip, "pnputil-drivers.txt", Run("pnputil.exe", "/enum-drivers"), redact));
Section("openstreamms", () => AddText(zip, "openstreamms.json", OpenStreamState(src, summary), redact));
@@ -188,6 +190,83 @@ private static string RdpRegistry()
return sb.ToString();
}
+ ///
+ /// Mandos conectados y lo que hace falta para ver por dónde llega uno a otra sesión aunque
+ /// HidHide lo oculte (issue #11, mandos Xbox One): en qué clases está instalado el filtro de
+ /// HidHide, su configuración, y el árbol completo de cada mando (todos los nodos, de
+ /// cualquier clase, con driver, filtros y estado). Los nodos ocultados llevan [oculto].
+ ///
+ private static string Controllers()
+ {
+ var sb = new StringBuilder();
+ sb.AppendLine("== Filtro de HidHide por clase (UpperFilters) ==");
+ foreach (var (name, guid) in new[]
+ {
+ ("HID", "{745a17a0-74d3-11d0-b6fe-00a0c90f57da}"),
+ ("XUSB (Xbox 360)", "{d61ca365-5af4-4486-998b-9db4734c6ca3}"),
+ ("XboxComposite (Xbox One/GIP)", "{05f5cfe2-4733-4950-a6bb-07aad01a3a84}"),
+ })
+ {
+ using var key = Registry.LocalMachine.OpenSubKey($@"SYSTEM\CurrentControlSet\Control\Class\{guid}");
+ var filters = key?.GetValue("UpperFilters") is string[] f ? string.Join(",", f) : "-";
+ sb.AppendLine($"{name,-30} {filters}");
+ }
+
+ sb.AppendLine().AppendLine("== Configuración de HidHide (registro) ==");
+ var jailed = new HashSet(StringComparer.OrdinalIgnoreCase);
+ try
+ {
+ using var key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\HidHide\Parameters");
+ if (key is null) sb.AppendLine("(sin clave Parameters)");
+ else
+ foreach (var value in key.GetValueNames())
+ {
+ var data = key.GetValue(value);
+ var lines = data is string[] multi ? multi : [data?.ToString() ?? ""];
+ sb.AppendLine($"{value}:");
+ foreach (var line in lines)
+ {
+ sb.AppendLine($" {line}");
+ jailed.Add(line.Split('!')[0]);
+ }
+ }
+ }
+ catch (Exception ex) { sb.AppendLine($"(no se pudo leer: {ex.Message})"); }
+
+ sb.AppendLine().AppendLine("== Mandos conectados (árbol completo de cada uno) ==");
+ var controllers = GamepadSessionIsolation.Cm.GameControllers().ToList();
+ var roots = controllers.Select(GamepadSessionIsolation.Cm.RootOf).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
+ var listed = new HashSet(StringComparer.OrdinalIgnoreCase);
+ if (roots.Count == 0) sb.AppendLine("(ninguno)");
+ foreach (var root in roots)
+ {
+ void Node(string id, int depth)
+ {
+ listed.Add(id);
+ sb.Append(' ', depth * 2).Append(jailed.Contains(id) ? "[oculto] " : "").AppendLine(GamepadSessionIsolation.Cm.Describe(id));
+ foreach (var child in GamepadSessionIsolation.Cm.Children(id)) Node(child, depth + 1);
+ }
+ Node(root, 0);
+ sb.AppendLine();
+ }
+
+ // Nodos de la pila de mandos de Windows que no cuelgan de ningún mando de arriba
+ // (bus sintético de Xbox, GameInput, adaptadores inalámbricos sin mando…).
+ string[] services = ["xboxgip", "dc1-controller", "xinputhid", "xusb22", "gameinput", "xboxgipsynthetic"];
+ var others = GamepadSessionIsolation.Cm.AllPresent()
+ .Where(id => !listed.Contains(id))
+ .Where(id => GamepadSessionIsolation.Cm.ServiceOf(id) is { } svc && services.Any(x => svc.StartsWith(x, StringComparison.OrdinalIgnoreCase))
+ || id.Contains("Gip", StringComparison.OrdinalIgnoreCase)
+ || id.Contains("SyntheticGamepad", StringComparison.OrdinalIgnoreCase)
+ || id.Contains("GameInput", StringComparison.OrdinalIgnoreCase))
+ .ToList();
+ sb.AppendLine("== Otros nodos de la pila de mandos de Windows ==");
+ if (others.Count == 0) sb.AppendLine("(ninguno)");
+ foreach (var id in others)
+ sb.Append(jailed.Contains(id) ? "[oculto] " : "").AppendLine(GamepadSessionIsolation.Cm.Describe(id));
+ return sb.ToString();
+ }
+
private static string ServicesInfo()
{
string[] names =
@@ -420,6 +499,8 @@ OpenStreamMS diagnostic bundle / paquete de diagnóstico
- 00-summary.txt: Windows version and build, OpenStreamMS version, drivers, sessions.
- system.txt, services.txt, rdp-registry.txt, windows-sessions.txt, processes.txt,
listening-ports.txt, pnputil-*.txt: PC hardware, Windows and driver information.
+ - controllers.txt: connected controllers with their full device tree (driver, filters,
+ state) and the HidHide filter and settings, to see how a controller reaches a session.
- openstreamms.json: state of OpenStreamMS (RDP Wrapper, RemoteIdd, drivers, sessions, seats).
- logs/, sunshine/, programdata/: OpenStreamMS logs and each Sunshine log, including
the previous run (sunshine.log.1).
diff --git a/Services/Gamepad/GamepadSessionIsolation.cs b/Services/Gamepad/GamepadSessionIsolation.cs
index 74785d1..91ced6e 100644
--- a/Services/Gamepad/GamepadSessionIsolation.cs
+++ b/Services/Gamepad/GamepadSessionIsolation.cs
@@ -470,9 +470,21 @@ private void ScanPhysical()
foreach (var gone in _physical.Keys.Where(id => !Cm.Exists(id)).ToList())
_physical.Remove(gone);
- HidePhysical(Cm.GameControllers().Where(id => ViGEmPadOf(id) is null).ToList());
+ HidePhysical(WithHidHideChildren(Cm.GameControllers().Where(id => ViGEmPadOf(id) is null)));
}
+ ///
+ /// Cada mando con sus nodos hijos de las clases que filtra HidHide. Un mando Xbox One (GIP)
+ /// puede publicar la entrada también por colecciones HID hijas que Windows no marca como
+ /// mando (p. ej. "definidas por el fabricante"): sin ocultarlas, otras sesiones lo leían
+ /// por ahí aunque el nodo del mando estuviera oculto (issue #11).
+ ///
+ private static List WithHidHideChildren(IEnumerable controllers) =>
+ controllers
+ .SelectMany(id => Cm.Descendants(id).Where(Cm.IsHidHideClass).Prepend(id))
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+
///
/// Deja cada mando físico visible solo en su sesión destino: la del puesto que lo reclama
/// (por puerto USB), o la de consola si ningún puesto lo tiene asignado. Si alguno estaba
@@ -675,7 +687,7 @@ public void Dispose()
finally { Marshal.FreeHGlobal(filter); }
}
- public static IEnumerable DeviceIds(string filter,
+ public static IEnumerable DeviceIds(string? filter,
int flags = CM_GETIDLIST_FILTER_ENUMERATOR | CM_GETIDLIST_FILTER_PRESENT)
{
if (CM_Get_Device_ID_List_SizeW(out int len, filter, flags) != CR_SUCCESS || len <= 1) return [];
@@ -781,6 +793,69 @@ public static List Descendants(string deviceId)
return result;
}
+ private const int CM_DRP_DEVICEDESC = 0x1;
+ private const int CM_DRP_SERVICE = 0x5;
+ private const int CM_DRP_FRIENDLYNAME = 0xD;
+ private const int CM_DRP_UPPERFILTERS = 0x12;
+ private const int CM_DRP_LOWERFILTERS = 0x13;
+
+ /// Todos los nodos presentes.
+ public static IEnumerable AllPresent() => DeviceIds(null, CM_GETIDLIST_FILTER_PRESENT);
+
+ /// Servicio (driver de función) del nodo, o null.
+ public static string? ServiceOf(string deviceId) => RegistryStrings(deviceId, CM_DRP_SERVICE).FirstOrDefault();
+
+ ///
+ /// Una línea con lo que hace falta para saber por dónde llega un mando a una sesión:
+ /// nombre, clase, driver, filtros y estado (o código de problema).
+ ///
+ public static string Describe(string deviceId)
+ {
+ string name = RegistryStrings(deviceId, CM_DRP_FRIENDLYNAME).FirstOrDefault()
+ ?? RegistryStrings(deviceId, CM_DRP_DEVICEDESC).FirstOrDefault() ?? "";
+ int semi = name.LastIndexOf(';');
+ if (semi >= 0) name = name[(semi + 1)..]; // "@oem12.inf,%desc%;Nombre"
+ string cls = ClassGuid(deviceId) switch
+ {
+ null => "-",
+ var c when c.Equals(HidClass, StringComparison.OrdinalIgnoreCase) => "HID",
+ var c when c.Equals(XnaCompositeClass, StringComparison.OrdinalIgnoreCase) => "XUSB (Xbox 360)",
+ var c when c.Equals(XboxCompositeClass, StringComparison.OrdinalIgnoreCase) => "XboxComposite (Xbox One/GIP)",
+ var c => c,
+ };
+ string state = "?";
+ if (CM_Locate_DevNodeW(out int inst, deviceId, CM_LOCATE_DEVNODE_NORMAL) == CR_SUCCESS &&
+ CM_Get_DevNode_Status(out uint status, out uint problem, inst, 0) == CR_SUCCESS)
+ state = problem != 0 ? $"problema {problem}" : (status & DN_STARTED) != 0 ? "arrancado" : "sin arrancar";
+ string Join(int prop) => string.Join(",", RegistryStrings(deviceId, prop)) is { Length: > 0 } v ? v : "-";
+ return $"{deviceId} | {name} | clase {cls} | driver {ServiceOf(deviceId) ?? "-"} | " +
+ $"filtros sup. {Join(CM_DRP_UPPERFILTERS)} inf. {Join(CM_DRP_LOWERFILTERS)} | {state}";
+ }
+
+ ///
+ /// Dispositivo físico del que cuelga un nodo: se sube mientras el padre no sea un hub
+ /// USB, un bus o la raíz (máximo 8 niveles).
+ ///
+ public static string RootOf(string deviceId)
+ {
+ string current = deviceId;
+ for (int i = 0; i < 8 && Parent(current) is { } parent; i++)
+ {
+ if (IsBusOrHub(parent)) break;
+ current = parent;
+ }
+ return current;
+ }
+
+ private static bool IsBusOrHub(string deviceId) =>
+ deviceId.StartsWith(@"USB\ROOT_HUB", StringComparison.OrdinalIgnoreCase) ||
+ deviceId.StartsWith(@"PCI", StringComparison.OrdinalIgnoreCase) ||
+ deviceId.StartsWith(@"ACPI", StringComparison.OrdinalIgnoreCase) ||
+ deviceId.StartsWith(@"ROOT", StringComparison.OrdinalIgnoreCase) ||
+ deviceId.StartsWith(@"HTREE", StringComparison.OrdinalIgnoreCase) ||
+ deviceId.StartsWith(@"BTH", StringComparison.OrdinalIgnoreCase) ||
+ HardwareIds(deviceId).Any(h => h.StartsWith(@"USB\Class_09", StringComparison.OrdinalIgnoreCase));
+
private static string? Id(int devInst)
{
var buf = new char[512];
diff --git a/tests/OpenStreamMS.Tests/DiagnosticsControllersTests.cs b/tests/OpenStreamMS.Tests/DiagnosticsControllersTests.cs
new file mode 100644
index 0000000..f11ab36
--- /dev/null
+++ b/tests/OpenStreamMS.Tests/DiagnosticsControllersTests.cs
@@ -0,0 +1,22 @@
+using System.Reflection;
+
+namespace OpenStreamMS.Tests;
+
+public class DiagnosticsControllersTests
+{
+ [Fact]
+ public void Controllers_ListsHidHideFiltersAndControllerTrees()
+ {
+ var type = typeof(OpenStreamMS.Core.Api.StreamSessionService).Assembly
+ .GetType("OpenStreamMS.Core.Helpers.DiagnosticsBundle", throwOnError: true)!;
+ var method = type.GetMethod("Controllers", BindingFlags.NonPublic | BindingFlags.Static)!;
+
+ var text = (string)method.Invoke(null, null)!;
+
+ Assert.Contains("== Filtro de HidHide por clase (UpperFilters) ==", text);
+ Assert.Contains("XboxComposite (Xbox One/GIP)", text);
+ Assert.Contains("== Configuración de HidHide (registro) ==", text);
+ Assert.Contains("== Mandos conectados (árbol completo de cada uno) ==", text);
+ Assert.Contains("== Otros nodos de la pila de mandos de Windows ==", text);
+ }
+}