The project had one purpose in mind: control a treadmill (with different inputs) connected to an arduino. The current supported inputs are:
- Virtual reality headset position
- Xbox controller
- Keyboard
The project located in repository https://github.com/KevinChenier/DetectVR controls a treadmill connected to an arduino with two different inputs:
- Oculus rift controllers (TreadmillControllerJoystick.cs)
- Virtual reality headset position (TreadmillControllerHeadset.cs)
The TreadmillControllerJoystick.cs script handles the Oculus controllers inputs and sends the proper signals to the arduino, which in turns controls the treadmill speed. There is another way to control the treadmill speed, and this is achieved with the script TreadmillControllerHeadset.cs. This script takes into account a hard coded position in your environment, which mimics the behaviour that tells the treadmill that you started to walk (reached a certain axis threshold), which in turns activates and controls the treadmill speed.
This script also sends UDP signal through port 9988 (to Botsimu https://github.com/KevinChenier/Botsimu), which tells python scripts what inputs to activate. For example, the vjoy.py simulates controller inputs when the threshold is reached, which will in turn activate the treadmill speed AND will make you walk in any game you want!
*The way to "hack" your own treadmill with an arduino is not explained here, you should do your own research to see how you could open up your own treadmill and connect the "speed" pin to your arduino. So the tutorial here assumes that your arduino is already connected to your treadmill.
Using DetectVR (https://github.com/KevinChenier/DetectVR) and Botsimu (https://github.com/KevinChenier/Botsimu)
*Before starting to play any game, be sure to run vJoySetup.exe, which is located in .\DetectVRSoftware\Botsimu\Package\FirstTimeSetup.
- Push Uduino.ino in your arduino (located in ./Arduino/InPCBScripts/Uduino)
- Start a DetectVR scene (Statue of liberty scene, be sure that TreadmillControllerHeadset.cs is activated)
- Put Package.zip in the same directory as your game (located in ".\DetectVRSoftware\Botsimu\Package\Package.zip").
- Extract Package.zip in the same directory as your game.
- Run x360ce_x64.exe now located in your directory game
- The app should auto-detect your game, click on "Select a game to customize:", and select your game.
- Run vjoy.py or directkeys.py
- Is your game fully controller supported ? Use vjoy.py if yes, else use directkeys.py
- If you use vjoy.py, which joystick is your walk/run? If else than a joystick, just use directkeys.py
- If keyboard, which key is your sprint and which key is walk/run ? You should change the key for forward movement in directkeys.py
- Start your game.
In this flow, Unity (DetectVR) is responsible for sending the signals to the arduino.
Only using Botsimu (https://github.com/KevinChenier/Botsimu)
- Push PWM.ino in your arduino (located in ./Arduino/InPCBScripts/)
- Open DetectVR.sln
- Start the solution
- A window will prompt you which COM is your arduino connected? You can check which COM in the Arduino IDE
- Move your xbox joystick controllers
- Start your game
In this flow, Botsimu is responsible for sending the signals to the arduino.