Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
EisernSchild's avatar
EisernSchild
Explorer
12 years ago

Win 8 Metro App compatible libOVR

Currently, the "libOVR" cannot be used in a Win8 Metro App since it fails the "Windows App Cert Kit"-Test due to calls to InitializeCriticalSection and LoadLibrary.

So we need to use InitializeCriticalSectionEx in Windows 8 without loading the function in runtime.

Heres my Code:
(ovr_atomic.h)
// Include System thread functionality.
#if defined(OVR_OS_WIN32)
#include <windows.h>
#else
#include <pthread.h>
#endif

// Include Windows 8-Metro compatible Synchronization API
#if (NTDDI_VERSION >= NTDDI_WIN8)
#include <synchapi.h>
#endif

(ovr_atomic.cpp)
// ***** Standard Win32 Lock implementation
#if (NTDDI_VERSION < NTDDI_WIN8)
// Spin count init critical section function prototype for Window NT
typedef BOOL (WINAPI *Function_InitializeCriticalSectionAndSpinCount)
(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount);
#endif

// Constructors
Lock::Lock(unsigned spinCount)
{
#if ((defined OVR_BUILD_DEBUG) && (NTDDI_VERSION >= NTDDI_WIN8))
// On Windows 8 we use InitializeCriticalSectionEx due to Metro-Compatibility
InitializeCriticalSectionEx(&cs, spinCount, NULL);
#elif (NTDDI_VERSION >= NTDDI_WIN8)
// On Windows 8 we use InitializeCriticalSectionEx due to Metro-Compatibility
InitializeCriticalSectionEx(&cs, spinCount, CRITICAL_SECTION_NO_DEBUG_INFO);
#else
// Try to load function dynamically so that we don't require NT
// On Windows NT we will use InitializeCriticalSectionAndSpinCount
static bool initTried = 0;
static Function_InitializeCriticalSectionAndSpinCount pInitFn = 0;

if (!initTried)
{
HMODULE hmodule = ::LoadLibrary(OVR_STR("kernel32.dll"));
pInitFn = (Function_InitializeCriticalSectionAndSpinCount)
::GetProcAddress(hmodule, "InitializeCriticalSectionAndSpinCount");
initTried = 1;
}

// Initialize the critical section
if (pInitFn)
pInitFn(&cs, spinCount);
else
::InitializeCriticalSection(&cs);
#endif

}


Now, the app certification doesnot fail any more (release build). Would be great if the Team could add some code like that in future Oculus SDK to keep it Metro app compatible. :D

6 Replies

  • Thanks for the tip. Hopefully this patch will make it into a future OculusVR SDK. And also, it would be good if Win 8 Metro App compatibility testing could become part of the Oculus software regression testing procedure.
  • K.. i tried everything to make the lib compatible to Windows 8 apps. Most could be easily done but i definately fail when trying to use the HIDClass (HidD_Xxx and HidP_Xxx routines) in the lib. (Hidsdi.h and Hid.lib can only be used in Desktop Family Partition) LoadLibraryW, as used in the code, also Fails the app cert kit.

    So the Problem is that Windows apps are not sheduled to read HID-Raw-Data.

    This is what Microsoft says:
    "Windows 8 requires a driver in order to get access to raw HID data. "

    Will we have a Windows 8 specific Driver in future ? Any other clues ?
  • mikeant's avatar
    mikeant
    Honored Guest
    We've integrated the conditional CRITICALSECTION fix into the next build, although as you've pointed out it doesn't address interfacing with sensor HID device, which needs the HidD_* functionality. HID interface is critical for obtaining sensor data.

    We definitely plan to support building for Windows 8 App Store in the future, although if this requires writing an actual device driver it will take extra time, so it is too early to promise any time-frame. We'll start looking into it after the upcoming release (which mostly focuses on OSX).

    Thank you for the posted code suggestions!
    Michael
  • "mikeant" wrote:
    We definitely plan to support building for Windows 8 App Store in the future, although if this requires writing an actual device driver it will take extra time, so it is too early to promise any time-frame.


    Good to know, thank You !
  • I want to bring up this topic again because I get far more errors that just calls to InitializeCriticalSection and LoadLibrary. It seems to be mostly in the DeviceStatus class (OVR_Win32_DeviceStatus.cpp), which is very Metro unfriendly. Is this also going to be addressed?
  • tlopes's avatar
    tlopes
    Honored Guest
    If it's possible, I'd prefer to keep the Rift driver-less. Part of its ease of use is that you can simply plug it into any computer and use it without having to install anything off of a CD, USB key, or the Internet :) There may be Windows 8-specific workarounds for this that don't involve having to use LoadLibrary, such as Rift integration to the Windows 8 Sensors API (which is accessible from Metro apps).