Jump to content

How to use threading?


marcob

Recommended Posts

That is my code, I'm using example setup for clicking emulation

void MyDevice::startEmulation() {

	joystickX = 0;
	joystickY = 0;
	trackpadX = 0;
	trackpadY = 0;


	std::thread thread_object([](void* device) {
		MyDevice* myDevice = (MyDevice*)device;
		for (;;) {
			myDevice->joystickX = 0.95;
			myDevice->joystickY = 0.95;
			std::this_thread::sleep_for(std::chrono::seconds(1));
			myDevice->joystickX = 0;
			myDevice->joystickY = 0;
			std::this_thread::sleep_for(std::chrono::seconds(1));
		}

		; }, this
	);
}

That's where is it calling

EVRInitError MyDeviceProvider::Init(IVRDriverContext* pDriverContext)
{
    EVRInitError initError = InitServerDriverContext(pDriverContext);
    if (initError != EVRInitError::VRInitError_None)
    {
        return initError;
    }

    VRDriverLog()->Log("Initializing Finally Functional's VR Shoes");

    controllerDriver = new MyDevice();
    controllerDriver->startEmulation();

    VRServerDriverHost()->TrackedDeviceAdded("teensyDriver", TrackedDeviceClass_Controller, controllerDriver);

    return vr::VRInitError_None;
}

Is it good idea to use threading in openVR applications? @chengnay

screen1.PNG

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...