1. wormyrocks

    OP wormyrocks Newbie
    Newcomer

    Joined:
    Oct 10, 2017
    Messages:
    9
    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
     
    lordelan, Tumoche, matt! and 13 others like this.
  2. BlastedGuy9905

    BlastedGuy9905 where's the updated autopsy report
    Member

    Joined:
    Apr 13, 2017
    Messages:
    2,278
    Country:
    United States
    You need 10 posts.
     
    wormyrocks likes this.
  3. BORTZ

    BORTZ The Amazing
    Supervisor

    Joined:
    Dec 2, 2007
    Messages:
    12,919
    Country:
    United States
    Yeah sorry we have had some major spammer problems so when you first create a new account your privileges are limited.
     
    Masterwin likes this.
  4. wormyrocks

    OP wormyrocks Newbie
    Newcomer

    Joined:
    Oct 10, 2017
    Messages:
    9
    Country:
    United States
    Thanks so much! If you could linkify those it'd be much appreciated.
     
    TotalInsanity4 likes this.
  5. Xellar

    Xellar Member
    Newcomer

    Joined:
    Sep 24, 2017
    Messages:
    22
    Country:
    Switzerland
    Looks nice :D

    I'm going to check it out i may play with it a little.
     
  6. mfosse

    mfosse Member
    Newcomer

    Joined:
    Sep 27, 2017
    Messages:
    15
    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
     
  7. wormyrocks

    OP wormyrocks Newbie
    Newcomer

    Joined:
    Oct 10, 2017
    Messages:
    9
    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

    — Posts automatically merged - Please don't double post! —

    (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.)
     
    TotalInsanity4 and kitzuki like this.
  8. BlastedGuy9905

    BlastedGuy9905 where's the updated autopsy report
    Member

    Joined:
    Apr 13, 2017
    Messages:
    2,278
    Country:
    United States
    HOLY SHIT. That's amazing! Also, how do you make your Joy-Con's HOME Button light up?
     
  9. wormyrocks

    OP wormyrocks Newbie
    Newcomer

    Joined:
    Oct 10, 2017
    Messages:
    9
    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.
     
  10. kitzuki

    kitzuki GBAtemp Regular
    Member

    Joined:
    Jan 29, 2008
    Messages:
    128
    Country:
    United States
  11. TotalInsanity4

    TotalInsanity4 GBAtemp Supreme Overlord
    Member

    Joined:
    Dec 1, 2014
    Messages:
    10,811
    Country:
    United States
    So, out of curiosity, how much work would it require to rewrite this as a general driver?
     
  12. BlastedGuy9905

    BlastedGuy9905 where's the updated autopsy report
    Member

    Joined:
    Apr 13, 2017
    Messages:
    2,278
    Country:
    United States
    okay, downloaded the tool, dumped the spi, what to do?
     
  13. wormyrocks

    OP wormyrocks Newbie
    Newcomer

    Joined:
    Oct 10, 2017
    Messages:
    9
    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.

    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 ^^^^
     
    TotalInsanity4 likes this.
  14. TotalInsanity4

    TotalInsanity4 GBAtemp Supreme Overlord
    Member

    Joined:
    Dec 1, 2014
    Messages:
    10,811
    Country:
    United States
    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)
     
  15. epickid37

    epickid37 ( ͡° ͜ʖ ͡°)
    Member

    Joined:
    Jan 4, 2017
    Messages:
    1,246
    Country:
    United States
    this is insane! good work!
     
  16. BlastedGuy9905

    BlastedGuy9905 where's the updated autopsy report
    Member

    Joined:
    Apr 13, 2017
    Messages:
    2,278
    Country:
    United States
    it does light up, but cant i make it automatically light up as soon as it connects to my switch?
     
  17. epickid37

    epickid37 ( ͡° ͜ʖ ͡°)
    Member

    Joined:
    Jan 4, 2017
    Messages:
    1,246
    Country:
    United States
    i didn't even know it lit up until a few days ago. it's a shame that ninty doesn't make it light up anywhere
     
    BlastedGuy9905 likes this.
  18. BlastedGuy9905

    BlastedGuy9905 where's the updated autopsy report
    Member

    Joined:
    Apr 13, 2017
    Messages:
    2,278
    Country:
    United States
    they are waiting until they release the new online with usernames and then it will light up if you recieve a notification.
     
    TotalInsanity4 likes this.
  19. epickid37

    epickid37 ( ͡° ͜ʖ ͡°)
    Member

    Joined:
    Jan 4, 2017
    Messages:
    1,246
    Country:
    United States
    cool
     
    BlastedGuy9905 likes this.
  20. Manurocker95

    Manurocker95 Game Developer & Pokémon Master
    Member

    Joined:
    May 29, 2016
    Messages:
    1,329
    Country:
    Spain
    Lol, this is something I was looking for xD Gonna try this now!
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - Library, Unity,