Hi there,
Okay, here’s the thing. Some users are experiencing this issue with our game: for those who do have Win10 Anniversary Update, the Xbox One controller mapping I did is working nice, but for those using a Win10 pre-Anniversary the controller axis mapping is completely messed up.
So, what I’m going to do is to check which version of Win10 they are using, and apply a different mapping for the XOne pad depending on the current OS version. But I’m a bit lost on one thing: how can I check by code whether their Win10 is Anniversary Update or not? SystemInfo.operatingSystem
is of no use, since it is always returning “Windows 10 (10.0.0)”.
Thanks in advance.
Okay, someone from the Unity tech team (@Tautvydas-Zilys) has shown me how to detect if W10A, I’m copying here his method so any future user looking for this can also know how to achieve this.
[DllImport("api-ms-win-core-winrt-string-l1-1-0.dll")]
private static extern int WindowsCreateString([MarshalAs(UnmanagedType.LPWStr)]string sourceString, int stringLength, out IntPtr hstring);
[DllImport("api-ms-win-core-winrt-string-l1-1-0.dll")]
private static extern int WindowsDeleteString(IntPtr hstring);
[DllImport("api-ms-win-core-winrt-l1-1-0.dll")]
private static extern int RoGetActivationFactory(IntPtr className, ref Guid guid, out IntPtr instance);
public static bool IsRunningOnAnniversaryUpdateOrNewer()
{
try
{
const string kAppExtensionClassName = "Windows.ApplicationModel.AppExtensions.AppExtensionCatalog";
var classNameHString = IntPtr.Zero;
if (WindowsCreateString(kAppExtensionClassName, kAppExtensionClassName.Length, out classNameHString) != 0)
return false;
try
{
IntPtr appExtensionCatalogStatics;
var IID_IAppExtensionCatalogStatics = new Guid(1010198154, 24344, 20235, 156, 229, 202, 182, 29, 25, 111, 17);
if (RoGetActivationFactory(classNameHString, ref IID_IAppExtensionCatalogStatics, out appExtensionCatalogStatics) != 0)
return false;
if (appExtensionCatalogStatics != IntPtr.Zero)
{
Marshal.Release(appExtensionCatalogStatics);
return true;
}
return false;
}
finally
{
WindowsDeleteString(classNameHString);
}
}
catch
{
return false;
}
}
It checks whether a Windows runtime class Windows.ApplicationModel.AppExtensions.AppExtensionCatalog
exists on the system, which was added in anniversary update:
https://msdn.microsoft.com/library/windows/apps/windows.applicationmodel.appextensions.appextensioncatalog