have been checking through the examples and api, but i cant seem to find how to initialize the device and adding it to a controller.
Controller controller; //creates an invalid controller
Device device; //creates an invalid device
there seems to be no knowledge to be found past that.
if these actually are supposed to make valid devices on the spot: then there might be a device find error, however i already have leapd and leapcontrolpanel started up and working.
You don't create Device objects yourself. The Device class describes connected devices. Get a Device object from the Controller object after the controller has "connected". (Currently only one Leap Motion device can be recognized.)
Related
My end goal is to make a VRidge lightweight clone to understand the OpenVR API, but I'm struggling to understand how to get my code to display something. As a starting point, instead of my phone, I want to create a window as the HMD (SFML, SDL, you name it...) and having SteamVR rendering the VR view in it.
I understand that an object implementing IServerTrackedDeviceProvider is the handler of my driver's devices, ITrackedDeviceServerDriver is the interface of the device itself, and I suspect that my "HMD" device will have to implement IVRDisplayComponent.
Aside from setting some properties and having callbacks to activate and deactivate my device, I have no clue where to get an actual frame to display on the screen. What am I missing ?
You are almost right.
A class inheriting vr::IServerTrackedDeviceProvider(I'll call it the device parent later on) is responsible for registering and maintaining the lifetime of your devices(creating them, registering them, etc.)
Classes inheriting vr::ITrackedDeviceServerDriver after they have been registered by a device parent are considered a tracked device, device type is set by the device parent on register, also in case of the HMD device GetComponent() method needs to return display components if requested, for other devices it can just return NULL
GetComponent() receives a c string with a component name and version, for example "IVRDisplayComponent_002" stored in vr::IVRDisplayComponent_Version, and if the device has a component with a matching name version pair you need to return a pointer to it, if no match is found return NULL
Also about components, in the driver example that Valve provides its done in a very lazy and bad way, DO NOT INHERIT COMPONENTS TO YOUR DEVICE CLASSES
Segment your components into separate objects that you initialize in your device and return them in GetComponent() accordingly
Now, the only thing left for your devices to be properly identified and used by SteamVR is registering them, but there is a catch, you need to specify the device type when you register it by passing one of the values from vr::ETrackedDeviceClass enum(these should be pretty self explanatory when you look at the enum)
This is not all there is to openvr driver of course, for it all to work and for SteamVR to even acknowledge your driver's existence you need to implement an HmdDriverFactory() function, its similarly to GetComponent() except you compare the input c string to a provider name version pair and in case of a device parent its vr::IServerTrackedDeviceProvider_Version, if you get a match return a pointer to the instance of your device parent or any other provider you implemented
A few notes:
HMD needs at least one display component
HMD device is very sensitive to how you submit poses to it(dont ask why, it just is)
Be prepared for the lack of documentation, the best docs that you're gonna get are code comments in openvr_driver.h, ValveSoftware/openvr issue tracker and other people working with openvr drivers (even though there are only few...)
This is not the best explanation of how openvr drivers work, so you're always welcomed to ask for more details in the comments
I'm writing an audio player using Microsoft Media Foundation.
I wonder is it possible to change the playback device without re-creating the session?
IMFActivate *m_p_sink_activate;
...
m_p_sink_activate->SetString(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, name_device);
This doesn't take effect if the audio is already being played.
Btw, the media player provided by Microsoft.Windows.SDK.Contracts (Windows.Media.Playback.MediaPlayer) does it perfectly.
When I change m_mediaPlayer.AudioDevice, the audio stream is redirected to the assigned device immediately. So I wonder if this is also possible for MSMF.
So far I have a way could do this job,
Create a new topology which cloned from previous one.
Create new audio renderer using MFCreateAudioRendererActivate and using set string with the new audio endpoint ID add it to a topologynode;
Add the new node to new topology;
Using IMFMediaSession::SetTopology() do set new topology to play.
You could refer to MS sample TopoEdit for detail.
One side effect is that each time SetTopology cause huge memory growth.
The question is complete in itself. Adding a few more details to include the things which I have already tried:
I have searched across stackexchange platform, but was unable to get my query solved.
Through some clues which I gathered along the way, I could only count the number of connected devices.
VideoCapture class has been mentioned in some posts, but that was only so much useful.
I am working on Windows platform with C++.
I created this C++ class that allows you to enumerate the devices (including ID) that you can use in order to get the list of devices to use in OpenCV. It is hosted on GitHub
https://github.com/studiosi/OpenCVDeviceEnumerator
The idea is to use DirectShow to get all the devices that have the category with GUID CLSID_VideoInputDeviceCategory, and then, through an enumerator, you get in which order they appear on the system, which is the ID you need to open them on OpenCV by creating a VideoCapture object (by using the constructor that receives the ID, which would be the index of the device on the enumeration). Obviously, this approach only works on Windows.
I'm writing a C++ program that should check Driver Device ID.
My input is the driver name as it should appear in the Device Manager.
I tried to Google, and I figured that:
I could get the driver pointer using this sample code http://msdn.microsoft.com/en-us/library/ms682619%28VS.85%29.aspx
I should use IRP_MN_QUERY_ID function to get the device ID- http://msdn.microsoft.com/en-us/library/windows/hardware/ff551679(v=vs.85).aspx.
However, I couldn't find any examples or code snippets for how to actually do it, and how those two functions connect?
I have no experience in drivers, sample code will be very appreciated...
On windows there are no device ids (as name =) ). Device matches by hardware id and compatible ids. From this ids system generate instance id - uniquely identifies the device on specific port on bus. You can get hardware/compatible id without sending IRPs, by using IoGetDeviceProperty function (http://msdn.microsoft.com/en-us/library/windows/hardware/ff549203(v=vs.85).aspx), it`s more easy than roll up your own IRP.
I'm working on developing a WMI query for my application. It needs to find the assigned virtual COM port for a given VID/PID. Using the WMI Code Creator I have found that...
Namespace: root\CIMV2
Class: Win32_SerialPort
Property: PNPDeviceID
...returns a value of USB\VID_10C4&PID_EA60\0001. This same value can be found by going to the appropriate entry in Device Manager -> Properties -> Details tab and selecting Device Instance Id.
My question is, what does the \0001 signify? Or, can I expect my device to have a device ID of USB\VID_10C4&PID_EA60\0001 when plugged into any Windows system? Thanks.
It references the device instance. That is, devices with identical identifiers (more than one plugged in) are enumerated, so that the system can identify them.
http://forums.techguy.org/software-development/959095-solved-pnpdeviceid-format.html#3