在Windows 10应用中,您可以通过以下方式从后台线程获得低延迟鼠标/笔/触摸输入:
var workItemHandler = new WorkItemHandler((action) =>
{
SwapChainPanel mPanel = (SwapChainPanel)inputElement;
CoreIndependentInputSource coreIndependentInputSource;
coreIndependentInputSource = mPanel.CreateCoreIndependentInputSource(CoreInputDeviceTypes.Touch | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Mouse);
coreIndependentInputSource.PointerPressed += CoreWindow_PointerPressed;
coreIndependentInputSource.PointerMoved += CoreWindow_PointerMoved;
coreIndependentInputSource.PointerReleased += CoreWindow_PointerReleased;
coreIndependentInputSource.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessUntilQuit);
});
但您必须从CoreWindow或UI元素提供的路由事件中获取键盘输入。 (您也可以从窗口获取鼠标输入,但它会遇到完全相同的问题)
这导致键盘输入在鼠标移动/点击时被阻止。
如何在不使用鼠标输入延迟的路由事件的情况下获取键盘输入?