Help needed with WSANative plugin to listen Surface Pen events

Hi guys,

Using WSANative plugin to check if a Surface user is using Surface Pen eraser on my coloring application.

Is this possible to get working with il2cpp?
Or any other way to check if Pen is used?

From MainPage.xaml.cs
private void ConfigureInput()
{

Window.Current.CoreWindow.PointerPressed += (s, e) =>
{
if (WSANativeInput.PointerPressed != null)
{
PointerPointProperties pointerProperties = e.CurrentPoint.Properties;
try
{
WSANativeInput.PointerPressed(new WSAPointerProperties()
{
InputType = e.CurrentPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Touch ? WSAInputType.Touch :
e.CurrentPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Pen ? WSAInputType.Pen : WSAInputType.Mouse,
IsLeftButtonPressed = pointerProperties.IsLeftButtonPressed,
IsRightButtonPressed = pointerProperties.IsRightButtonPressed,
IsEraser = pointerProperties.IsEraser,
IsInverted = pointerProperties.IsInverted
});
}
catch
{

}

}
};

}

You can just use that code from your Unity C# script in some Awake() method. You’ll need to wrap it in #if ENABLE_WINMD_SUPPORT/#endif define. You will also need to make sure that it’s called from the right thread by using UnityEngine.WSA.Application.InvokeOnUIThread.

Lastly, you may want to use CoreWindow.GetForCurrentThread() instead of Window.Current - the latter only works if you use XAML build type, while the former works on D3D/ExecutableOnly app types too.

Thank you very much!