CoreIndependentInputSource 클래스

정의

상호 운용 시나리오에 대한 핵심 입력 API를 표시합니다.

public ref class CoreIndependentInputSource sealed : ICoreInputSourceBase, ICorePointerInputSource
public ref class CoreIndependentInputSource sealed : ICoreInputSourceBase, ICorePointerInputSource2
public ref class CoreIndependentInputSource sealed : ICoreInputSourceBase, ICorePointerInputSource2, ICorePointerRedirector
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class CoreIndependentInputSource final : ICoreInputSourceBase, ICorePointerInputSource
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class CoreIndependentInputSource final : ICoreInputSourceBase, ICorePointerInputSource2
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class CoreIndependentInputSource final : ICoreInputSourceBase, ICorePointerInputSource2, ICorePointerRedirector
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource2
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource2, ICorePointerRedirector
Public NotInheritable Class CoreIndependentInputSource
Implements ICoreInputSourceBase, ICorePointerInputSource
Public NotInheritable Class CoreIndependentInputSource
Implements ICoreInputSourceBase, ICorePointerInputSource2
Public NotInheritable Class CoreIndependentInputSource
Implements ICoreInputSourceBase, ICorePointerInputSource2, ICorePointerRedirector
상속
Object Platform::Object IInspectable CoreIndependentInputSource
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

독립 입력 초기화

// MainPage.cpp
#include "pch.h"
#include "MainPage.h"
#include <winrt/Windows.System.Threading.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/Windows.UI.Xaml.Controls.h>

using namespace winrt;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;

Windows::Foundation::IAsyncAction m_inputLoopWorker;
...
    // Create a task to register for independent input and begin processing input messages.
    Windows::System::Threading::WorkItemHandler workItemHandler([this](Windows::Foundation::IAsyncAction const& /* action */)
    {
        // The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on.
        Windows::UI::Core::CoreIndependentInputSource coreInput{
            MySwapChainPanel().CreateCoreIndependentInputSource(
                Windows::UI::Core::CoreInputDeviceTypes::Mouse |
                Windows::UI::Core::CoreInputDeviceTypes::Touch |
                Windows::UI::Core::CoreInputDeviceTypes::Pen)
        };

        // Register for pointer events, which will be raised on the background thread.
        coreInput.PointerPressed({ this, &MainPage::SCP_OnPointerPressed });
        coreInput.PointerMoved({ this, &MainPage::SCP_OnPointerMoved });
        coreInput.PointerReleased({ this, &MainPage::SCP_OnPointerReleased });

        // Begin processing input messages as they're delivered.
        coreInput.Dispatcher().ProcessEvents(Windows::UI::Core::CoreProcessEventsOption::ProcessUntilQuit);
    });

    // Run task on a dedicated high priority background thread.
    m_inputLoopWorker = Windows::System::Threading::ThreadPool::RunAsync(
        workItemHandler, Windows::System::Threading::WorkItemPriority::High,
        Windows::System::Threading::WorkItemOptions::TimeSliced);
...
void MainPage::SCP_OnPointerPressed(Windows::Foundation::IInspectable const& /* sender */,
    Windows::UI::Core::PointerEventArgs const& /* args */) {}
void MainPage::SCP_OnPointerMoved(Windows::Foundation::IInspectable const& /* sender */,
    Windows::UI::Core::PointerEventArgs const& /* args */) {}
void MainPage::SCP_OnPointerReleased(Windows::Foundation::IInspectable const& /* sender */,
    Windows::UI::Core::PointerEventArgs const& /* args */) {}
// Create a task to register for independent input and begin processing input messages.
auto workItemHandler = ref new WorkItemHandler([this] (IAsyncAction ^)
{
   // The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on.
   CoreIndependentInputSource^ coreInput = CreateCoreIndependentInputSource(
      Windows::UI::Core::CoreInputDeviceTypes::Mouse |
      Windows::UI::Core::CoreInputDeviceTypes::Touch |
      Windows::UI::Core::CoreInputDeviceTypes::Pen
   );

   // Register for pointer events, which will be raised on the background thread.
   coreInput->PointerPressed += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerPressed);
   coreInput->PointerMoved += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerMoved);
   coreInput->PointerReleased += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerReleased);

   // Begin processing input messages as they're delivered.
   coreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
});

// Run task on a dedicated high priority background thread.
m_inputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced);

CreateCoreIndependentInputSource 및 CoreIndependentInputSource를 사용하는 방법에 대한 자세한 예제 코드는 XAML SwapChainPanel DirectX interop 샘플의 일부인 클래스 정의를 참조 DrawingPanel 하세요.

설명

SwapChainBackgroundPanel.CreateCoreIndependentInputSource 또는 SwapChainPanel.CreateCoreIndependentInputSource를 호출하여 이 클래스의 instance 만듭니다.

CoreIndependentInputSource 클래스를 사용하면 백그라운드 스레드에서 입력 처리 논리를 의도적으로 제공하기 때문에 앱이 XAML UI 스레드와 독립적으로 입력 및 렌더링을 처리할 수 있습니다. UI가 아닌 스레드에서 CreateCoreIndependentInputSource 를 호출해야 합니다. 그렇지 않으면 CreateCoreIndependentInputSource 메서드 호출이 실패합니다.

버전 기록

Windows 버전 SDK 버전 추가된 값
1803 17134 DispatcherQueue

속성

Dispatcher

창에 대한 이벤트 디스패처를 가져옵니다.

DispatcherQueue

CoreIndependentInputSource와 연결된 DispatcherQueue를 가져옵니다.

HasCapture

창에 포인터 캡처가 있는지 여부를 보고하는 값을 가져옵니다.

IsInputEnabled

UWP 앱에 대해 입력을 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

PointerCursor

앱에서 사용하는 포인터 커서를 가져오거나 설정합니다.

PointerPosition

포인터의 클라이언트 좌표를 가져옵니다.

메서드

ReleasePointerCapture()

UWP 앱에 대한 포인터 캡처를 사용하지 않도록 설정합니다.

SetPointerCapture()

UWP 앱에 대한 포인터 캡처를 사용하도록 설정합니다.

이벤트

InputEnabled

UWP 앱에 대한 입력을 사용하거나 사용하지 않도록 설정할 때 발생합니다.

PointerCaptureLost

포인터가 다른 UWP 앱으로 이동할 때 발생합니다. 이 이벤트는 PointerExited 이후에 발생하며 이 포인터에 대해 앱에서 받은 마지막 이벤트입니다.

PointerEntered

포인터가 UWP 앱의 경계 상자로 이동할 때 발생합니다.

PointerExited

포인터가 UWP 앱의 경계 상자 밖으로 이동할 때 발생합니다.

PointerMoved

포인터가 UWP 앱의 경계 상자 내에서 이동할 때 발생합니다.

PointerPressed

UWP 앱의 경계 사각형 내에서 마우스 단추를 클릭하거나 터치 또는 펜 접촉이 감지될 때 발생합니다.

PointerReleased

UWP 앱의 경계 사각형 내에서 마우스 단추를 놓거나 터치 또는 펜 접촉이 해제될 때 발생합니다.

PointerRoutedAway

포인터가 다른 입력 개체로 리디렉션될 때 포인터 입력을 수신하는 입력 개체에서 발생합니다(별도의 프로세스일 수 있음).

PointerRoutedReleased

입력 개체에서 CoreIndependentInputSource.PointerReleased 이벤트를 발생시키는 포인터와 연결되어 있지만 현재 입력을 받지 않는 모든 입력 개체에서 발생합니다.

PointerRoutedTo

캡처된 포인터 입력이 이전에 다른 개체로 전달되고 이 개체로 전달될 때 발생합니다.

PointerWheelChanged

휠 단추를 회전할 때 발생합니다.

적용 대상

추가 정보