Skip to content

Link Nintendo Switch Joy-Cons to VRChat using the new OSC API (haptics only for now)

Notifications You must be signed in to change notification settings

Python1320/vrcjoycon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OSC-based JoyCon (Haptics) for ChilloutVR/VRChat

Link Nintendo Switch Joy-Cons to Chillout VR/VRChat! Uses OSC Mod in ChilloutVR and the OSC system in VRChat.

For now, only simple on/off rumble haptics are supported!

Requirements

HELP WANTED

Only tested with knockoff joycons. Does it work with real joycons? Apparently not. We need to fix this!

Linux

1. Installation

Only tested on Debian 12 (bookworm) and python 3.11

Steps

# Our dependencies
sudo apt install libhidapi-dev

# https://innovativeinnovation.github.io/ubuntu-setup/python/pyenv.html
# Pyenv dependencies
sudo apt install make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev \
xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# Get pyenv so we can get python 3.11 exactly
curl https://pyenv.run | bash

# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^ Follow comments above to install pyenv lines in .bashrc ^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

pyenv install 3.11 # build 3.11 python
pyenv virtualenv 3.11 joycon # create joycon virtualenv

. .bashrc # reload .bashrc (or restart shell here)

git clone "https://github.com/Python1320/vrcjoycon.git" && \
cd vrcjoycon && \
pyenv local joycon

# Make sure you see (joycon) prefix on your shell now

 # install poetry dependency manager
pip install poetry # OR: curl -sSL https://install.python-poetry.org | python3

poetry install # install python dependencies with poetry

####### Do steps 2 and 3 below and (*) ##########

cd src
./main.py

# Start controllers for discovery

# Modify config

${EDITOR:-nano} config.ini

(*) you may need to try poetry add hid and poetry add hidapi to find a working one (remove the other one).

2. hid_nintendo kernel module must not be loaded

echo "blacklist hid_nintendo" > /etc/modprobe.d/blacklist_hid_nintendo.conf
rmmod hid_nintendo

3. Install udev rules

See: https://www.reddit.com/r/Stadia/comments/egcvpq/comment/fc5s7qm/

cat << 'EOF' > /etc/udev/rules.d/50-nintendo-switch.rules
# Switch Joy-con (L) (Bluetooth only)
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", KERNELS=="0005:057E:2006.*", MODE="0666"

# Switch Joy-con (R) (Bluetooth only)
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", KERNELS=="0005:057E:2007.*", MODE="0666"

# Switch Pro controller (USB and Bluetooth)
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0666"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", KERNELS=="0005:057E:2009.*", MODE="0666"

EOF

Run udevadm control --reload-rules

TODO

  • Example haptics avatar + world (please submit in PR!)
  • Button input possibility
  • Gyroscope?
  • Switch joy-con to poll only to reduce wireless interference (partially done)

Haptics: Setting Up / Usage

Unity (For Chillout VR)

Rather simple. Just add a few components with right parameter name and it should just work.

  1. Add joyconrumble1 to avatar parameters

    Add joyconrumble1 to avatar parameters

  2. Add CVR Advanced Avatar Trigger to your head

    Add CVR Advanced Avatar Trigger

  3. Add CVR Pointer on at least one finger

    Add CVR Pointer

Unity (for VRCHat)

  1. Position one or multiple Contact Receivers components to your chosen avatar bone
    1. Choose at least some collision tags or you will receive no contacts

    2. Haptics can be set to local only. Allow Self is recommended for testing.

    3. Select Proximity from Receiver Type.

    4. Set target parameter to joyconrumble1. For right controller choose joyconrumble2.

      componentdetails

    5. Add the above parameters to your animator parameters with default float value of 0.0. This is used by OSC to relay the status to VRCJoyCon.

      animator

VRChat

  1. Put controllers into pairing mode by pressing the pairing button.
  2. Pair controllers manually over Bluetooth with Windows.
  3. Launch vrcjoycon.exe
  4. When pairing is successful, the controller should vibrate. You may need to press the pair button in the controllers a few times before Windows notices the controllers. They should say "connected" in the windows settings when this is so.
  5. In case of trouble, test with other joycon software first
  6. Launch VRChat if not already launched
    1. From the VRChat's circular menu, inside settings, inside OSC, choose Enable OSC. Additional help here. (If the haptics do not work, try reset configuration option in the same menu ATTN. The OSC Debug menu does not help you with debugging haptics, only output)

Relay

If you have no bluetooth on your VR PC or are experiencing interference it should also be possible to use vrcjoycon.exe on a different Windows Laptop, for example.

  1. You will need to configure VRChat to relay the OSC output data to your target computer: https://docs.vrchat.com/docs/osc-overview#vrchat-ports
  2. Start vrcjoycon with command line arguments vrcjoycon.exe --listen=any --port=9001
    • You can replace any with an IP address. Any is an alias for 0.0.0.0
    • The default port is 9001
    • Make sure your firewall allows listening on UDP protocol port 9001 for vrcjoycon.exe

Troubleshooting

Test with OSC receiver to see if your avatar is transmitting. Try transmitting 1 to /avatar/parameters/joyconrumble1 with OSC sender to see if vrcjoycon.exe works.

Credits / components used

License

PENDING MISSING LICENSE ON: https://github.com/tocoteron/joycon-python