Hacking Joy-Con Unity Library

wormyrocks

Member
OP
Newcomer
Joined
Oct 10, 2017
Messages
9
Trophies
0
Age
29
XP
102
Country
United States
Hi all,

If you're a game developer and you want to build a Mac or PC game that uses the Joy-Con, I wrote a Unity library that lets you do that.

It parses accel/gyro data, lets you control HD Rumble, and of course reads the buttons and stick.

For now it only supports one Joy-Con at a time, as I have been working on the Joy-Con as a potential future control scheme for the HoloPlayer One by Looking Glass, where I work. Yep, I actually got paid to do this, it's awesome.

It should be noted that my sensor fusion code, which handles Joy-Con position estimation, is basically hot garbage right now. The Joy-Con doesn't have a magnetometer, so full 6dof position estimation is impossible. I'm aiming to get position estimation accuracy on par with that treasure chest game in 1-2-Switch. The Unity package comes by default with position estimation disabled, but will still return raw IMU data converted to Gs (accelerometer) and dps (gyroscope). I use the calibration values stored in the Joy-Con SPI flash, so the gyro values are actually pretty accurate.

If you want to help improve my position estimation, I'd welcome pull requests. The code I have right now is currently built on top of this guide.

Thanks a lot to CTCaer for all the help.

Um, I'm a new user, so I had to scrub this post of links before the forum would let me put it up. If someone can tell me how many posts I have to have before I can add links that'd be great.

Here is a link to the library:
github.
com/Looking-Glass/JoyconLib

Here is the guide I used for sensor fusion code:
starlino.
com/imu_guide.html
 

mfosse

Member
Newcomer
Joined
Sep 27, 2017
Messages
15
Trophies
0
Age
25
XP
311
Country
United States
My sensor fusion code is also hot garbage, but feel free to look at it in my driver on github (mfosse) it uses a basic complementary filter, I didn't bother with the kalman filter and it doesn't work properly past 90° pitch for whatever reason
 

wormyrocks

Member
OP
Newcomer
Joined
Oct 10, 2017
Messages
9
Trophies
0
Age
29
XP
102
Country
United States
Hi friends - my sensor fusion code is now better!
i. imgur.co m/Ye5qp1n.gif
Get the new version here: g ithub.c om/Looking-Glass/JoyconLib/releases

--------------------- MERGED ---------------------------

Hi friends - my sensor fusion code is now better!
i. imgur.co m/Ye5qp1n.gif
Get the new version here: g ithub.c om/Looking-Glass/JoyconLib/releases
(I would really appreciate it if a mod could image-ify and link-ify those. Seriously, I can't overstate how much the position tracking is improved in this version.)
 

BlastedGuy9905

where's the updated autopsy report
Member
Joined
Apr 13, 2017
Messages
2,334
Trophies
1
Age
33
Location
under your desk
XP
4,043
Country
United States
Hi friends - my sensor fusion code is now better!
i. imgur.co m/Ye5qp1n.gif
Get the new version here: g ithub.c om/Looking-Glass/JoyconLib/releases

--------------------- MERGED ---------------------------


(I would really appreciate it if a mod could image-ify and link-ify those. Seriously, I can't overstate how much the position tracking is improved in this version.)
HOLY SHIT. That's amazing! Also, how do you make your Joy-Con's HOME Button light up?
 

wormyrocks

Member
OP
Newcomer
Joined
Oct 10, 2017
Messages
9
Trophies
0
Age
29
XP
102
Country
United States
lol, I was using CTCaer's Joycon Utility to test out the output of some raw values and I think he put in some functionality to make it light up.
 

TotalInsanity4

GBAtemp Supreme Overlord
Member
Joined
Dec 1, 2014
Messages
10,800
Trophies
0
Location
Under a rock
XP
9,814
Country
United States
Hi friends - my sensor fusion code is now better!
i. imgur.co m/Ye5qp1n.gif
Get the new version here: g ithub.c om/Looking-Glass/JoyconLib/releases

--------------------- MERGED ---------------------------


(I would really appreciate it if a mod could image-ify and link-ify those. Seriously, I can't overstate how much the position tracking is improved in this version.)
So, out of curiosity, how much work would it require to rewrite this as a general driver?
 

wormyrocks

Member
OP
Newcomer
Joined
Oct 10, 2017
Messages
9
Trophies
0
Age
29
XP
102
Country
United States
okay, downloaded the tool, dumped the spi, what to do?

Um, mine just lights up as soon as I connect it to JC Toolkit. I assumed that was an Easter egg or something. If it doesn't work for you, you can always use JC Toolkit to send subcommand 0x38 as described on (this page)*, but... it's a light, it's really not that interesting.

So, out of curiosity, how much work would it require to rewrite this as a general driver?

How do you mean? The Joy-Con already shows up natively as a controller on Windows. There already is a (vJoy driver)** and (C driver)***, both in progress, on which I based the bulk of my work. To my knowledge, the only new/unique thing I did with this library was the position estimation. I also read and process input packets in separate threads - this approach, or something like it, is pretty vital if you want to avoid serious input lag, as the Joy-Con pushes packets every 15 milliseconds and will build up an enormous backlog if they are read any slower than that.

If you are just wondering how portable this code is - (it is quite straightforward)**** and you are welcome to look through it (and I'm happy to answer questions).

* github (dot) com (slash) dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md
** github (dot) com (slash) mfosse/JoyCon-Driver
*** github (dot) com (slash) riking/joycon
**** github (dot) com (slash) Looking-Glass/JoyconLib/blob/master/Assets/JoyconLib_scripts/Joycon.cs

P.S. I freakin hate this ^^^^
 
  • Like
Reactions: TotalInsanity4

TotalInsanity4

GBAtemp Supreme Overlord
Member
Joined
Dec 1, 2014
Messages
10,800
Trophies
0
Location
Under a rock
XP
9,814
Country
United States
How do you mean? The Joy-Con already shows up natively as a controller on Windows. There already is a (vJoy driver)** and (C driver)***, both in progress, on which I based the bulk of my work. To my knowledge, the only new/unique thing I did with this library was the position estimation. I also read and process input packets in separate threads - this approach, or something like it, is pretty vital if you want to avoid serious input lag, as the Joy-Con pushes packets every 15 milliseconds and will build up an enormous backlog if they are read any slower than that.

If you are just wondering how portable this code is - (it is quite straightforward)**** and you are welcome to look through it (and I'm happy to answer questions).

* github (dot) com (slash) dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md
** github (dot) com (slash) mfosse/JoyCon-Driver
*** github (dot) com (slash) riking/joycon
**** github (dot) com (slash) Looking-Glass/JoyconLib/blob/master/Assets/JoyconLib_scripts/Joycon.cs

P.S. I freakin hate this ^^^^
I was wondering specifically about the gyroscopic stuff (and HD rumble, should you choose to pursue that later). I might peruse your code, but I'm not particularly advanced and probably wouldn't know what I'm looking at half the time lol

(Also if you put "www." in front of the address it'll automatically link-ify it)
 

BlastedGuy9905

where's the updated autopsy report
Member
Joined
Apr 13, 2017
Messages
2,334
Trophies
1
Age
33
Location
under your desk
XP
4,043
Country
United States
Um, mine just lights up as soon as I connect it to JC Toolkit. I assumed that was an Easter egg or something. If it doesn't work for you, you can always use JC Toolkit to send subcommand 0x38 as described on (this page)*, but... it's a light, it's really not that interesting.
it does light up, but cant i make it automatically light up as soon as it connects to my switch?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • RedColoredStars @ RedColoredStars:
    Fucking lame. Thread viewed 1000 times and only one reply that doesnt even answer what I asked.
  • SylverReZ @ SylverReZ:
    You could say the same for a couple or so threads that used to be popular, I guess.
  • RedColoredStars @ RedColoredStars:
    I mean. All I ask was for people to see if ONE, SINGLE website is working properly in edge. 1000 people see it but cant be bothered at all
  • RedColoredStars @ RedColoredStars:
    Ready to just leave this place anyway. The amount of shit talking and bullying behavior that goes unchecked is crazy. No where else do I see this shit towards me and others. Not even on reddit have I been talked to like I have here by other members
  • SylverReZ @ SylverReZ:
    @RedColoredStars, I did read the last sentence in your post by the way. Maybe try changing the privacy settings in your browser to standard if that works.
  • SylverReZ @ SylverReZ:
    I've also heard that Chromium-based browsers will stop working with ad-blockers.
  • K3Nv2 @ K3Nv2:
    Please dont go we need you.
  • K3Nv2 @ K3Nv2:
    I really learned not to give a fuck what others do online it's helped ease my mind try it sometime.
  • RedColoredStars @ RedColoredStars:
    @SylverReZ That reply to you was when we werent on good terms. lol. I tried everything. Changing privacy settings etc.
  • Veho @ Veho:
    Fuck Chromium. Firefox 4evar.
    +1
  • Veho @ Veho:
    (Firefox 4 now, anyway. Let's see if they pull some crap too.)
    +1
  • DinohScene @ DinohScene:
    Netscape ftw
    +1
  • K3Nv2 @ K3Nv2:
    Funny enough went to download chrome Bing gave error installed Firefox fine
    +1
  • RedColoredStars @ RedColoredStars:
    Thing is , the videos work fine in the Edge Dev and Canary builds. But whatever the fix they made was, has never been pushed to Beta or Stable builds. Its been that way for as far back as I tested. Which was Edge 84. They are on 125 now.
    +1
  • SylverReZ @ SylverReZ:
    @RedColoredStars, Yeah, and I was in quite a mood at that time. I would consider choosing Firefox or Opera instead, been using Firefox for over 7 years now than Chrome.
  • RedColoredStars @ RedColoredStars:
    Tried contacting Nintendo to see if they can reach out to MS about it. But Nintendo said the videos are working fine. Without enough people saying no, they don't work fine, it will never get fixed.
  • RedColoredStars @ RedColoredStars:
    I have Firefox and used it for many years. But Edge runs noticible faster on my pc at both opening and loading pages.
  • SylverReZ @ SylverReZ:
    I don't think Nintendo will know anything about troubleshooting Edge. They mostly do technical support regarding their console family.
  • K3Nv2 @ K3Nv2:
    Tell them you downloaded their trailer without permission
    +2
  • SylverReZ @ SylverReZ:
    Good one, Ken.
  • RedColoredStars @ RedColoredStars:
    Right. But they could create a ticket that gets forwarded to the proper team. I think Nintendo would care that their videos aren't working on a major browser
  • RedColoredStars @ RedColoredStars:
    LOL K3N. HAHAH!
  • K3Nv2 @ K3Nv2:
    My left eyes hitting random pain for whatever reason allergy cold bring it on
    K3Nv2 @ K3Nv2: My left eyes hitting random pain for whatever reason allergy cold bring it on