Giter VIP home page Giter VIP logo

joycon's Introduction

joycon

Joy-Con input driver for Linux

The current main code, written in Go, lives in the prog4/jcdriver folder, as it was the fourth attempt at making this program.

Compiling

sudo apt install libudev-dev go git

go get -u github.com/riking/joycon/prog4/jcdriver # Download and build the program
cp $(go env GOBIN)/jcdriver ./jcdriver # Copy the binary out of where Go drops it
sudo ./jcdriver # Run the driver

If an old Go version is installed and it complains about GOPATH not set, run:

export GOPATH=$HOME/go

and try again.

Basic Instructions

After starting the program as root, connect the Joy-Cons over Bluetooth. Once the program has picked them up, the player lights will begin flashing. Press L+R on the joycons to "pair" them up as a single controller device, which is then available to the rest of the system.

If you want the joycons to function as a pair of controllers with analog sticks, press the SL + SR buttons to pair as a single controller.

If your game needs a stick axis to be inverted, specify --invert LV (or LH, RV, RH) when running jcdriver.

TODO: Interface to switch between the modes / drop controllers for re-pairing

Limitations

The code will not actively scan and connect to the joycons. When the code is run on Mac, the "press button to reconnect" works due to the OS bluetooth driver (though the code cannot provide the device to other programs, as that requires a kext).

TODO: Scan and reconnect mode for bluez.

TODO List

PRs and help for any of this is appreciated! If I neglect your contributions, try pinging me on Twitter (@riking27); I may have missed the notification.

  • Output codes for "Held down HOME" and "Held down CAPTURE", and possibly "Pressed HOME" / "Pressed CAPTURE"
  • Graphical controller management interface
    • Programmatic interface, so someone else can build the graphical interface
    • custom Capture button handling, possibly?
  • Linux: accept reconnect requests from the controllers
  • "Active scanning" mode to pick up new controllers without holding down SYNC button
  • Configuration storage - save calibration data so it doesn't need to be pulled on every connection
  • Button remapping
  • Motion control support
    • Figure out how to work the insane system Linux has of delivering gyro data. Consider requiring use of a custom protocol.
  • Implement as a C++ library
    • Implement as a C library
    • Linux kernel driver to remove the suppressed devices so games don't try to use them
    • Mac kernel driver to present the combined controller to other programs
    • Windows kernel driver to do anything at all with the controllers

joycon's People

Contributors

dbaumgarten avatar drew-wallace avatar nickell-andrew avatar riking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

joycon's Issues

Extra config needed to use it with Steam?

Hi! I can connect the joycons but Steam big picture (and games) don't recognize them properly.
A and X are recognized as A and B, but left stick or buttons don't work in big picture.

Running Ubuntu 18.04

Documentation?

I would like to use this program but I don't know how to compile it. Could you please make some documentation on that?

Spaces

cp $(go env GOBIN)/jcdriver ./jcdriver contains spaces in the first path, so it cant be run

Build issues on OSX 10.14.1

Trying to run the code on OSX, I get the following error when downloading and building from GitHub:

$ go get -u github.com/riking/joycon/prog4/jcdriver
# github.com/riking/joycon/prog4/jcdriver
go/src/github.com/riking/joycon/prog4/jcdriver/output_generic.go:11:54: undefined: InputRemappingOptions

When I try to manually build the file, I get the same error:

$ go build 'github.com'/riking/joycon/prog4/jcdriver
# github.com/riking/joycon/prog4/jcdriver
jcdriver/output_generic.go:11:54: undefined: InputRemappingOptions

Brand new to Golang, and I can't find any information through google on this error; what am I missing?

Any ideas? Thanks!

Unity games crash when controller is connected

There is a strange issue I've come across that I can't really nail down. It could be a Unity(game engine), Steam, Linux or JCdriver issue.

Using Steam on Arch Linux, If I have the joycons paired and in single controller mode, setup through Steam as a Switch Pro controller and launch a Unity game it will crash. Disconnect the controller and it launches no problem. Controller works great with Steam and seems to be detected as an Xbox controller in non-Unity games.

Happy to provide some outputs to stuff if anyone has some ideas of where to start.

The program crashes on start when another non joycon nintendo device exists

I installed the aur package, entered the command sudo jcdriver and I get this:

[console]> panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb8 pc=0x503a2c]

goroutine 1 [running]:
github.com/riking/joycon/prog4/consoleiface.(*Manager).SearchDevices(0xc000086640, 0x0, 0x0)
	/tmp/yaourt-tmp-aldelaro5/aur-joycon-git/src/joycon/prog4/jcdriver/src/github.com/riking/joycon/prog4/consoleiface/Manager.go:448 +0x31c
github.com/riking/joycon/prog4/consoleiface.(*Manager).Run(0xc000086640)
	/tmp/yaourt-tmp-aldelaro5/aur-joycon-git/src/joycon/prog4/jcdriver/src/github.com/riking/joycon/prog4/consoleiface/Manager.go:77 +0x41e
main.main()
	/tmp/yaourt-tmp-aldelaro5/aur-joycon-git/src/joycon/prog4/jcdriver/main.go:49 +0x2c4

Is this expected or have I done something wrong?

EDIT: I have found the cause, it is because the program will try to consider ANY nintendo device as joycons. The reason this was appearing was because I had a wiiu pro paired and it was detecting it as joycons, but didn't get the joycons info so it crash because it tries to print these info which doesn't exist.

Windows support

Windows is preventing the program from opening the bluetooth device in read-write mode.

  • Userspace reading does not work
  • Kernel driver

May need to go straight to a kernel driver.

Sync and get data without root

Hey man! Great job with your tool :)

Is it possible to get it working without having to run it with sudo? I would love to implement this on my "Powerpoint" like presentations app Spice-Up ๐Ÿ˜„

Support for Windows?

I'm able to get hidapi_demo.c working without much effort but the main program is a bit beyond me. In particular I can't seem to read any joystick data. Any help would be appreciated.

[Question]SPI max read

Is the maximum reported SPI data different between joy-cons and Pro controller?

I found out that 0x1D is the maximum from my joy-cons.
Unfortunately, I don't own a pro controller to test

I implemented a async dump of both joy cons for https://github.com/shinyquagsire23/HID-Joy-Con-Whispering and fixed the extra bytes in dumps. Now I'm cleaning up stuff and would be good to know if this is the real maximum value for all devices, before I make a pull request.

Compilation keeps failing

Every time I try to run go get -u github.com/riking/joycon/prog4/jcdriver it shows this:
screenshot

and then exits.
Do I need to remove the comment on the command for it to work?
edit: replaced text with picture

cant find package

Hello.

I don't know anything in golang. When I try to build the package I have a

prog4/jcdriver/main.go:8:2: cannot find package "github.com/riking/joycon/prog4/consoleiface" in any of:
	/usr/lib/go-1.6/src/github.com/riking/joycon/prog4/consoleiface (from $GOROOT)
	($GOPATH not set)
prog4/jcdriver/factory_uinput.go:8:2: cannot find package "github.com/riking/joycon/prog4/jcpc" in any of:
	/usr/lib/go-1.6/src/github.com/riking/joycon/prog4/jcpc (from $GOROOT)
	($GOPATH not set)
prog4/jcdriver/factory_uinput.go:9:2: cannot find package "github.com/riking/joycon/prog4/output" in any of:
	/usr/lib/go-1.6/src/github.com/riking/joycon/prog4/output (from $GOROOT)
	($GOPATH not set)
Makefile:34: recipe for target 'jcdriver' failed
make: *** [jcdriver] Error 1

Thank for any help

Thank you!

I just wanted to say thank you to @riking for making this project.

I am using it to play Pokemon on the Citra 3DS emulator and I am really enjoying it. And that I can use my joycons makes it even better, mainly because the analog stick is a lot more confortable than the keyboard. (And my friends now think that I am a wizard :)

[!] Joy-Con #0 needs calibration!

Hi!

I receive these messages when I connect the joy-cons to my computer (Debian 9), and indeed the controller needs calibration because it's a mess in game, but how do I do it?

Thank you for your attention!

go get gives error

doing the 'go get' thing from the readme returns

package github.com/riking/joycon: no buildable Go source files in /home/frot/go/src/github.com/riking/joycon

running the makefile contained therein returns some missing packages errors.
Might be due to me having no idea about go though!

Wrong URL in Readme.md

Your readme states

go get -u github.com/riking/jcdriver || true

when it should be

go get -u github.com/riking/joycon || true

[RFC] Retrieve analog sticks factory and user calibration

Hey,

check the latest 5 commits:
https://github.com/CTCaer/jc_toolkit/commits/master

It's preliminary proof of concept on how to parse the calibration for the analog sticks.
The data includes center position and x/y distance from center.

Lastly, I found out, that the factory calibration is used by switch, if no user calibration.
I changed the center position and the position on screen was wrong.

EDIT:
The calibration documentation is now on https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering

Status update or documentation?

I'm really curious about getting the controllers to work as 1 on my Pi. Any updates or documentation would be appreciated!

[Question] Is this usable without Switch?

You said calibrated JoyCons were needed, however my JoyCons are fresh out of the box and as far as I know have not been connected to a switch.

Do I just connect the joycons via Bluetooth? Do they work together as 1 single controller?

Error on compile: file not recognized: file format not recognized

go get -u github.com/riking/joycon/prog4/jcdriver
# github.com/riking/joycon/prog4/jcdriver
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/sbin/ld: /tmp/go-link-428780761/000006.o: unable to initialize decompress status for section .debug_info
/usr/sbin/ld: /tmp/go-link-428780761/000006.o: unable to initialize decompress status for section .debug_info
/usr/sbin/ld: /tmp/go-link-428780761/000006.o: unable to initialize decompress status for section .debug_info
/usr/sbin/ld: /tmp/go-link-428780761/000006.o: unable to initialize decompress status for section .debug_info
/tmp/go-link-428780761/000006.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status

Running Antergos here.

Linux: Stop games from attempting to use grabbed devices

  • Userspace input reading works fine as root
  • uinput allows presenting a device to other programs
  • EVIOCGRAB prevents events on old device nodes
    • Games still detect and try to use the grabbed device node

Looks like... a kernel driver?

Controller bindings

Hi!

I'm playing Steam games with the paired Joy-Cons controller, but I have a problem with the controller bindings. Steam thinks the controller is an XBox controller, and thus swaps buttons A <-> B & Y <-> X. Moreover, the X and Y axis on both joysticks are inverted, for instance giving the top right direction on the controller will make the character go down left.

Is there a handy way to edit those bindings?

Thank you for your time!

EDIT: In some games, joysticks don't work, I don't know if it is a recognition problem, or a binding one

Retropie

Can someone please explain how I can set this up on Retropie.
I'm new and can't figure it out.
Thanks!

Only 1 connects

Hey, I am trying to set this up and when connecting only 1 works perfectly but when trying to connect the second one it doesn't pick it up, my bluethoot connects it but the program doesnt show anything,

Am I doing something wrong?

It works independenly of the controles, so no matter if L or R only the first one is picked up

Add remappable controls (ie control stick axis)

Recently found this project and got it setup to work in a few programs. While setting up my JoyCons in antimicro, I noticed that left=right, up=down, etc. This wasn't an issue in most programs I tried as they let me specify which direction should be positive/negative (ie retroarch, which has you setup control sticks by pressing up, down, left, and right). However, Steam only detects which axises are up/down and left/right, meaning all directions are inverted in Steam games, and I've found no option in Steam to fix this. Any help fixing this would be greatly appreciated ๐Ÿ˜„
EDIT: OS is Ubuntu MATE 17.10 x64 in case it helps!

panic: runtime error: integer divide by zero

When I'm trying to push L+R I have this issue

plonk
plonk
pairing double
panic: runtime error: integer divide by zero

goroutine 19 [running]:
github.com/riking/joycon/prog4/joycon.(*calibrationData).Adjust(0x105fa1bc, 0x8e00763, 0x0)
	/home/pi/go/src/github.com/riking/joycon/prog4/joycon/common.go:98 +0x3b8
github.com/riking/joycon/prog4/joycon.(*joyconBluetooth).ReadInto(0x105fa180, 0x10612b10, 0x1d9200)
	/home/pi/go/src/github.com/riking/joycon/prog4/joycon/bluetooth.go:153 +0x228
github.com/riking/joycon/prog4/controller.(*two).JoyConUpdate(0x10612b00, 0x1d92a0, 0x105fa180, 0x1)
	/home/pi/go/src/github.com/riking/joycon/prog4/controller/two.go:47 +0x120
github.com/riking/joycon/prog4/joycon.notify(0x1d92a0, 0x105fa180, 0x1, 0x1052efd4, 0x2, 0x2)
	/home/pi/go/src/github.com/riking/joycon/prog4/joycon/common.go:15 +0x6c
github.com/riking/joycon/prog4/joycon.(*joyconBluetooth).reader(0x105fa180)
	/home/pi/go/src/github.com/riking/joycon/prog4/joycon/bluetooth.go:570 +0x410
created by github.com/riking/joycon/prog4/joycon.NewBluetooth
	/home/pi/go/src/github.com/riking/joycon/prog4/joycon/bluetooth.go:71 +0xdc

Mac support

  • Userspace input reading works fine
  • Cannot create a new input device without a signed kernel driver (or SIP off)

Steam inverts vertical axis of left joystick

When attempting to use the joy-cons with steam input through big-picture mode as a single controller, the resulting controller mapping's left vertical axis is inverted. Changing the mapping through js-test does not seem to do affect the resulting configuration.

Need Help!

make
go install -v ./prog4/jcdriver
make: go: Command not found
Makefile:34: recipe for target 'jcdriver' failed
make: *** [jcdriver] Error 127

Any Solutions Anyone?

How do you plan on switching between modes?

Hey @riking,

I was able to compile this on my Pi and it's working like a champ. I see you're re-writting this in Go. I'm hoping I will still be able to compile this on my pi once you're through. Currently, I'm using this driver for a pi project that basically mimics a Switch. I have a 7" screen, 3D printed case with built in Joy-Con rails on the sides, WiFi dongle, Bluetooth dongle, and soon it will be powered by a battery. It will primarily run a program called Parsec which is a super low latency desktop streaming solution for gaming. The goal is to be able to play full PC games on the go with as little latency as possible.

I am curious of your goals for this driver. Assuming it was left in it's current state, as a program that needs to be run, are you going to be adding any interesting features? Mainly, are you going to build in some button combination to allow for the coupling/decoupling of Joy-Cons? Or, is the program just for testing purposes as you write a native driver to be installed and never need to run anything?

Finally, thanks for making this. You are enabling one of my long time dreams of a homemade handheld console.

Controller not recognized by games

I can connect both Joy-Cons just fine, so that both of them have one steady light. But after this I don't know how to proceed, it wasn't working in any game I've tried so far, though some games (i.e. Enter the Gungeon) showed that there was a controller connected.

Am I missing something?

unable to compile: "cannot use func literal"

jcdriver/output_generic.go:11:9: cannot use func literal (type func(jcpc.JoyConType, int) (jcpc.Output, error)) as type jcpc.OutputFactory in return argument

I get the error above when I attempt to run go get ./... or go get ./jcdriver from the prog4 directory.

I'm running OSX 10.13

Full disclosure: I'm brand new to go and am mostly fiddling to see if I can effectively use joycon with my macbook pro

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.