Merge pull request #2043 from Microsoft/petea/silentgazedetection
Don't obtain a GazeInputSourcePreview instance until it is known that…
This commit is contained in:
Коммит
3ee738530c
|
@ -69,8 +69,7 @@ GazePointer::GazePointer()
|
|||
|
||||
InitializeHistogram();
|
||||
|
||||
auto view = GazeInputSourcePreview::GetForCurrentView();
|
||||
_watcher = view->CreateWatcher();
|
||||
_watcher = GazeInputSourcePreview::CreateWatcher();
|
||||
_watcher->Added += ref new TypedEventHandler<GazeDeviceWatcherPreview^, GazeDeviceWatcherAddedPreviewEventArgs^>(this, &GazePointer::OnDeviceAdded);
|
||||
_watcher->Removed += ref new TypedEventHandler<GazeDeviceWatcherPreview^, GazeDeviceWatcherRemovedPreviewEventArgs^>(this, &GazePointer::OnDeviceRemoved);
|
||||
_watcher->Start();
|
||||
|
@ -83,6 +82,8 @@ void GazePointer::OnDeviceAdded(GazeDeviceWatcherPreview^ sender, GazeDeviceWatc
|
|||
if (_deviceCount == 1)
|
||||
{
|
||||
IsDeviceAvailableChanged(nullptr, nullptr);
|
||||
|
||||
InitializeGazeInputSource();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,15 +172,18 @@ void GazePointer::InitializeHistogram()
|
|||
|
||||
void GazePointer::InitializeGazeInputSource()
|
||||
{
|
||||
_gazeInputSource = GazeInputSourcePreview::GetForCurrentView();
|
||||
if (_gazeInputSource != nullptr)
|
||||
if (_gazeInputSource == nullptr && _roots->Size != 0 && _deviceCount != 0)
|
||||
{
|
||||
_gazeEnteredToken = _gazeInputSource->GazeEntered += ref new TypedEventHandler<
|
||||
GazeInputSourcePreview^, GazeEnteredPreviewEventArgs^>(this, &GazePointer::OnGazeEntered);
|
||||
_gazeMovedToken = _gazeInputSource->GazeMoved += ref new TypedEventHandler<
|
||||
GazeInputSourcePreview^, GazeMovedPreviewEventArgs^>(this, &GazePointer::OnGazeMoved);
|
||||
_gazeExitedToken = _gazeInputSource->GazeExited += ref new TypedEventHandler<
|
||||
GazeInputSourcePreview^, GazeExitedPreviewEventArgs^>(this, &GazePointer::OnGazeExited);
|
||||
_gazeInputSource = GazeInputSourcePreview::GetForCurrentView();
|
||||
if (_gazeInputSource != nullptr)
|
||||
{
|
||||
_gazeEnteredToken = _gazeInputSource->GazeEntered += ref new TypedEventHandler<
|
||||
GazeInputSourcePreview^, GazeEnteredPreviewEventArgs^>(this, &GazePointer::OnGazeEntered);
|
||||
_gazeMovedToken = _gazeInputSource->GazeMoved += ref new TypedEventHandler<
|
||||
GazeInputSourcePreview^, GazeMovedPreviewEventArgs^>(this, &GazePointer::OnGazeMoved);
|
||||
_gazeExitedToken = _gazeInputSource->GazeExited += ref new TypedEventHandler<
|
||||
GazeInputSourcePreview^, GazeExitedPreviewEventArgs^>(this, &GazePointer::OnGazeExited);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче