-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using your device object as your hardware detect functor #13
Comments
The
...matches the
Is there a different example available that shows the correct way to do this? |
I'm seeing that some examples (like |
Syntactically, yes, those lines are similar, but the HardwareDetection object actually performs detection then creates a device object. The step is highly recommended, since it keeps devices from being created in the path tree (and having their automatic aliases populate, etc) unless there's actual hardware backing them. |
(The reason some examples don't use it is because I tried to make the examples each show exactly one thing, as much as possible - too many "examples" for SDKs cram every feature in so you can't see the forest for the trees.) |
…its own objects. Removed "new" usage in the Analog class.
Please see the commit referenced above. I have added a How does this solution look? Is it possible to test for the "clean up in case of device failure" scenario at this point? |
@rpavlik wrote:
I have added this condition to Leap::Controller controller;
if ( !controller.isConnected() ) {
mFound = false;
return OSVR_RETURN_FAILURE;
} If I return |
So far, the above approach seems to work. I'm not sure whether setting In my tests with the test Unity client, while keeing the OSVR Server running, I'm connecting/disconnecting the device and then stopping/starting the Unity scene. Whenever the scene is started, OSVR Server reports "Performing hardware auto-detection" and then runs the plugin's This is working as expected, except that the Unity scene sometimes shows the most recent images (the last "camera" and "distortion" frames before device disconnection) while the device is disconnected. I can also reproduce this via |
Returning failure from a hardware detect callback does not presently change anything. Returning failure from a device update callback signals that the device is disconnected/no longer active, but there's currently not lifecycle code to dispose of devices returning failure there. (as you noted, a plain
|
I suppose it's not strictly forbidden, but it's not how the API was designed: https://github.com/OSVR/OSVR-Leap-Motion/blob/master/com_osvr_LeapMotion.cpp#L6
You're creating a device object unconditionally, passing it as the hardware detect callback functor, then finishing initializing it when the function-call operator (hardware detect) is called, rather than providing actual "detection of hardware" functionality in a functor that then creates a device object if needed.
The current structure will also make it difficult for the server to clean up in case of device failure (in future API extensions), since the hardware detection functor registration method is taking ownership of the device object at registration.
The text was updated successfully, but these errors were encountered: