#pragma once #include #include #include #include #include // Mock implementation of the VR driver context for testing class MockVRDriverContext : public vr::IVRDriverContext { private: std::map interfaces; std::vector propertyErrors; std::map> properties; vr::PropertyContainerHandle_t nextHandle; public: MockVRDriverContext() : nextHandle(1) {} // IVRDriverContext implementation virtual void* GetGenericInterface(const char* interfaceVersion, vr::EVRInitError* error) override { if (error) { *error = vr::VRInitError_None; } auto it = interfaces.find(interfaceVersion); if (it != interfaces.end()) { return it->second; } if (error) { *error = vr::VRInitError_Init_InterfaceNotFound; } return nullptr; } virtual vr::DriverHandle_t GetDriverHandle() override { return 1; // Mock driver handle } // This method is not part of IVRDriverContext, but is useful for testing bool IsInterfaceVersionValid(const char* version) { // For testing, assume all interface versions are valid return true; } // This method is not part of IVRDriverContext, but is useful for testing vr::PropertyContainerHandle_t TrackedDeviceToPropertyContainer(vr::TrackedDeviceIndex_t device) { // For simplicity, just return the device index as the property container handle return static_cast(device); } // Mock-specific methods for test control void RegisterInterface(const std::string& interfaceVersion, void* implementation) { interfaces[interfaceVersion] = implementation; } vr::PropertyContainerHandle_t CreatePropertyContainer() { return nextHandle++; } void SetProperty(vr::PropertyContainerHandle_t container, vr::ETrackedDeviceProperty prop, vr::PropertyContainerHandle_t value) { properties[container][prop] = value; } vr::PropertyContainerHandle_t GetProperty(vr::PropertyContainerHandle_t container, vr::ETrackedDeviceProperty prop) { auto containerIt = properties.find(container); if (containerIt != properties.end()) { auto propIt = containerIt->second.find(prop); if (propIt != containerIt->second.end()) { return propIt->second; } } return 0; } void ClearPropertyErrors() { propertyErrors.clear(); } const std::vector& GetPropertyErrors() const { return propertyErrors; } };