Giter VIP home page Giter VIP logo

vrcjoycon's Introduction

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

vrcjoycon's People

Contributors

python1320 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nyabloody

vrcjoycon's Issues

not working

everything is working except for the joycons actually giving haptic feedback, it appears in the command line thingy when I make contact with the receiver it just doesn't vibrate, and I have tried other joycon software and it gives a little vibration when it connects, vrcjoycon.exe on the other hand doesn't make them vibrate at all not even just when it connect, I have also tried my other joycons and they all work with joycontool but not with vrcjoycon

Avatars

The program only supports specific characters, and I can't seem to find any.
I can't create my own supported character because it would take forever to figure out, and would take a lot of space on my computer to install the required apps to make one.
Maybe you could try making a program version that actually translates inputs, who knows.

Support for more than 2 joycons [feature request]

Maybe saving joycons in a JSON file? So the software can keep track of the devices. It would also allow more customization to the avatar parameter per joycon. Something like rumble intensity in "Constant" mode, etc.

Large memory leak

Something is consuming a ton of memory but only in certain cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.