HMD SpatialLocator in Win32 app requires UAC using Windows 10 April 2018 Update 1803

Greetings,

I have successfully gotten HMD pose from Windows.Perception.Spatial.SpatialLocator class in a Win32 app. I did this by compiling the project with C++/Cx enabled and pointing my VS project property pages to the the right #using folders:

C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\vcpackages

When I build, I can sample HMD pose using the following code on 1703 (2018 Fall Creators Update Windows 10):

`
Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);

Windows::Globalization::Calendar^ c = ref new Windows::Globalization::Calendar;
SpatialLocator ^m_locator = SpatialLocator::GetDefault();
SpatialStationaryFrameOfReference^ m_referenceFrame = m_locator->CreateStationaryFrameOfReferenceAtCurrentLocation();

while (true)
{
    if (m_locator->Locatability == SpatialLocatability::PositionalTrackingActive)
    {
        c->SetToNow();
        SpatialLocation^ head_pose = m_locator->TryLocateAtTimestamp(Windows::Perception::PerceptionTimestampHelper::FromHistoricalTargetTime(c->GetDateTime()), m_referenceFrame->CoordinateSystem);

        if (head_pose != nullptr)
        {
            std::cout << "ROT: {" << head_pose->Orientation.w << ", " << head_pose->Orientation.x << ", " << head_pose->Orientation.y << ", " << head_pose->Orientation.z << "}" << std::endl;
            std::cout << "POS: {" << head_pose->Position.x << ", " << head_pose->Position.y << ", " << head_pose->Position.z << "}" << std::endl;
        }
    }

    std::this_thread::sleep_for(std::chrono::milliseconds(1));
}

`

On version 1803, this code does not work as expected. I can see that the Locatability property changes, but every time it changes to "PositionActive" for example, it immediately changes Locatability back to "Unavailable" and TryLocateAtTimestamp() always returns null.

After trying a few things, I found out that if I launch my .exe using "Run as Administrator..." in the explorer, the code behaves as expected and I am able to get the pose of the HMD.

Is this a bug? Is there a way to grant permission to use the HMD in a win32 .exe without having to run the .exe as administrator?

Answers

Sign In or Register to comment.