12-19-2016 10:38 AM - edited 12-19-2016 10:39 AM
I am currently using an XBox One controller to steer multiple elements in my application. I want to be able to connect and disconnect the joystick during runtime (mostly because it goes to energy saving when not used for a while - the wakeup should work).
I followed the guidelines in this thread, which states that one should unload the "lvinput.dll" between calls to get updated values. This is working fine but whenever I stop the program, I get an Access violation (0xC0000005) (see screenshot).
The original poster seems to have had the same problem but there is no solution and I couldn't find anything around.
The attached code has the "Query Test.vi" which actually queries the lvinput.dll and the "Reconnect Testing.vi" which calls the "Query Test.vi" in a loop. Running either of them results in a crash when exiting it.
Solved! Go to Solution.
12-21-2016 03:54 AM - edited 12-21-2016 03:56 AM
Hi,
I was seeing a similar problem a few months ago with a X-Box controller.
When unplugging and then plugging the controller in again, while the VI that opened the connection to the controller is running, it is not possible to reconnect the controller again.
Error -2000000006 appears after disconnecting the controller. When trying to reconnect, the error is not cleared.
This is a known problem as Windows only releases the controller (joystick) reference when the calling program (which is the VI here) is closed.
My workaround is to initialize and use the joystick connection in a sub vi which is called dynamically:
After disconnecting the controller error -2000000006 appears and the "Joystick Handler.vi" closes.
Then you have to call it again dynamically like I did in my "Top level.vi" above.
This worked fine for me.
12-21-2016 06:25 AM
Interesting. But the part I actually want to get around is that in your example, the user has to trigger the reconnection by clicking the button.
I would like to have a way of constantly checking in the background wether the controller is connected or not and then read it or not.
I tried your suggestion with the Query Input Devices.vi inside your Joystick Handler.vi and it also doesn't get the list of currently connected devices but rather the list of devices connected when it was run for the first time (as usual).
03-15-2017 08:08 AM
I finally managed to solve the issue of connecting and disconnecting the XBox controller at runtime. The solution is to not use the LabView internal joystick VIs but the XInput library provided by Windows.
For further see here and the attached VI for an example. As a bonus, this API also allows to use the vibration of the controller 🙂
11-09-2019 02:40 AM
Do you know if it works with other controls? or only works with the 360
11-11-2019 02:13 AM