View Single Post
Old 06-16-2017, 09:04 AM
rdkirkden rdkirkden is offline
Join Date: May 2017
Posts: 19
Oculus Rift DK2 + gamepad controller


I’m trying to build an environment in which the subject wears an Oculus Rift DK2 headset and is additionally able to navigate using a gamepad controller (Logitech Dual Action). The controller should allow the subject to move along both horizontal axes using the left handle and also turn (i.e. rotate about the vertical axis) using the right handle.

The problem I have encountered is that when the subject turns using the controller, the horizontal axes are not re-aligned to the subject’s new orientation, with the consequence that after a 90 degree turn, the left/right handle action that previously caused movement along the x-axis now causes movement along the y-axis.

In an attempt to narrow down the cause of the problem, I started with the ‘’ example script (, which gives complete gamepad control over a view on the monitor, but does not incorporate a headset. To this, I added code from the ‘’ script (Program Files\WorldViz\Vizard5.2\examples\devices\, cited in, which incorporates an Oculus Rift DK2 headset, but has only limited keyboard controls (to move along the horizontal axes, but no turning). The problem emerged as soon as I instructed the headset sensor to link with the ‘MainView’. I attach two code listings: in the first, there is still full gamepad control but no headset control over the view because the link has not yet been made; in the second, the headset has been linked in and is working properly, but the problem with gamepad control has emerged.

You can see that in addition to adding the headset instructions, I’ve also made a few changes to the gamepad control code in the ‘UpdateJoystick’ function. This was necessary to get as much functionality as I could from the gamepad and headset, leaving just the problem with turning that I could not solve. The changes that I succeeded in making were as follows.

1) The ‘viz.MainView.move’ statement didn’t work at all after linking the Oculus sensor, so the gamepad could not be used to move along the horizontal axes. This was solved by using a ‘navigationNode.setPosition’ statement instead. I’ve noticed that the ‘’ script similarly uses ‘navigationNode.setPosition’ to get its keyboard controls working, although I don’t understand why this is necessary. (In contrast, the ‘viz.MainView.setEuler’ statement worked fine, so the gamepad could be used to rotate the view. Note that I’m using the ‘z’ variable here, not the ‘twist’ variable, because the Device Calibration Wizard got the horizontal and vertical actions of the right handle mixed up.)

2) After changing this, the gamepad could be used to move along the horizontal axes, but when the subject turned their head the horizontal axes were not re-aligned to the subject’s new orientation. To solve this, I had to incorporate the subject’s current yaw value into the ‘navigationNode.setPosition’ statement, using code that I do not understand, but copied from the keyboard controls in the ‘’ script.

To clarify my present situation, the horizontal axes are now being re-aligned when the headset turns, but not when the view is rotated using the right gamepad handle.

I’ve tried everything I can think of to get his working, but with no success. A large part of the problem is that I don’t understand all of the code, because the documentation in the Vizard 5 Reference is not very detailed.

I should add that I’m using Vizard 5.2 and Oculus SDK 0.5. Before attempting to write code and test any specific functionality, I was advised on this forum to update to the latest versions of both Vizard and Oculus; but I’m reluctant to do this unless I’m certain it is necessary, just in case it causes problems for some other hardware that I may need to use (some old NVIDIA 3D VISION 2 glasses). The two example scripts mentioned above each works perfectly on my system, it’s just that I can’t quite get them to fit together.

Any advice appreciated!

Attached Files
File Type: txt before_linking_headset.txt (853 Bytes, 574 views)
File Type: txt after_linking_headset.txt (1.2 KB, 623 views)
Reply With Quote