CsWinRT
CsWinRT copied to clipboard
Bug: Exception when calling Windows.Gaming.Input.RawGameController.GetCurrentReading -> Cannot handle array marshalling for non-blittable type 'System.Boolean'
Description
This works for non-AoT. In AoT projects, calling Windows.Gaming.Input.RawGameController.GetCurrentReading is throwing an exception, Cannot handle array marshalling for non-blittable type: 'System.Boolean'.
The generated code appears to be:
public ulong GetCurrentReading(bool[] buttonArray, GameControllerSwitchPosition[] switchArray, double[] axisArray)
{
return IRawGameControllerMethods.GetCurrentReading(_objRef_global__Windows_Gaming_Input_IRawGameController, buttonArray, switchArray, axisArray);
}
The definition of GetCurrentReading in the IDL for the COM interface appears to be:
HRESULT GetCurrentReading([in] UINT32 __buttonArraySize, [out] [size_is(__buttonArraySize)] boolean* buttonArray, [in] UINT32 __switchArraySize, [out] [size_is(__switchArraySize)] Windows.Gaming.Input.GameControllerSwitchPosition* switchArray, [in] UINT32 __axisArraySize, [out] [size_is(__axisArraySize)] DOUBLE* axisArray, [out] [retval] UINT64* timestamp);
Steps To Reproduce
- Create a WinAppSDK C# project, using Blank WinUI3, packaged template.
- Enable "PublishAot" on the project
- Make the following changes in app.xaml.cs:
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
Windows.Gaming.Input.RawGameController.RawGameControllerAdded += RawGameController_RawGameControllerAdded;
m_window = new MainWindow();
m_window.Activate();
}
private void RawGameController_RawGameControllerAdded(object? sender, Windows.Gaming.Input.RawGameController controller)
{
var buttons = new bool[controller.ButtonCount];
var switches = new Windows.Gaming.Input.GameControllerSwitchPosition[controller.SwitchCount];
var axes = new double[controller.AxisCount];
var timestamp = controller.GetCurrentReading(buttons, switches, axes);
}
- Plug in a gamepad or some other game controller
Expected Behavior
RawGameController.GetCurrentReading Should fill the array with button state.
Instead, it throws the following exception in WinRT.Runtime.dll: Cannot handle array marshalling for non blittable type 'System.Boolean'.
Version Info
cswinrt 2.2.0.0 Microsoft.WindowsAppSDK 1.6.250205002 Microsoft.Windows.SDK.Net.Ref.Windows 10.0.19041.57
Additional Context
No response