Homebrew Discussion SDL2 Joycon Bindings

00Cancer

Well-Known Member
OP
Newcomer
Joined
Feb 1, 2017
Messages
67
Trophies
0
Age
19
XP
93
Country
United States
SDL2 allows you use Joystick input and since SDL2 is available for the switch through devKitPro, I wanted to see if I could get the Joycons to work with it. It ended up working, but unfortunately I didn't know the bindings for the buttons, so I spent the time to check the value for each button and I came up with a list which contains all of the bindings.
Code:
A        = 0
B        = 1
X        = 2
Y        = 3
LSTICK   = 4
RSTICK   = 5
LBUMPER  = 6
RBUMPER  = 7
LTRIGGER = 8
RTRIGGER = 9
PLUS     = 10
MINUS    = 11
DPADL    = 12
DPADU    = 13
DPADR    = 14
DPADD    = 15
To setup the Joycons you first must create a Joystick in SDL and then later handle the events:
Code:
SDL_Joystick* joycon;
SDL_JoystickEventState(SDL_ENABLE);
joycon = SDL_JoystickOpen(0);
Code:
while (SDL_PollEvent(&e) != 0)
    {
        switch (e.type)
        {
        case SDL_JOYBUTTONDOWN:
            if (e.jbutton.button = <number on list>)
            {
                do whatever...
            }
            break;
        }
    }
Hope this helps anyone trying to use Joycon input with SDL
 
Last edited by 00Cancer,
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Skelletonike @ Skelletonike:
    1H left, such a slow week.
  • Sonic Angel Knight @ Sonic Angel Knight:
    Okay, I had spaghetti :P
  • SylverReZ @ SylverReZ:
    Hope they made lots of spaget
  • K3N1 @ K3N1:
    Chill dog
  • SylverReZ @ SylverReZ:
    Chilli dog
  • Skelletonike @ Skelletonike:
    Damn, I'm loving the new zelda.
  • xtremegamer @ xtremegamer:
    loving the new zelda, i started a game, it was so fucking good, so i
    am waiting on my friend to get home so we can start a new one together
  • Skelletonike @ Skelletonike:
    I just dislike that they don't let me choose the voices before the game starts. Happened with botw as well, had to change to japanese and restart.
  • K3N1 @ K3N1:
    But the important question is can you choose gender
  • Skelletonike @ Skelletonike:
    Same way you can choose Gerald's gender.
  • Skelletonike @ Skelletonike:
    *Geralt, damn autocorrect.
  • Psionic Roshambo @ Psionic Roshambo:
    But can he be trans? Lol
  • K3N1 @ K3N1:
    Zelda transforms into link
  • Psionic Roshambo @ Psionic Roshambo:
    Link I'm not the princess your looking for.... *Pulls a crying game*
  • K3N1 @ K3N1:
    *skirt up* it's exactly what I always wanted
  • Skelletonike @ Skelletonike:
    Just scanned all my zelda amiibos, took a while but didn't get anything that cool, did get the lon lon ranch hylian fabrics though.
  • Skelletonike @ Skelletonike:
    It was pretty funny when I scanned wolf link and got a shit load of meat.
  • K3N1 @ K3N1:
    @Skelletonike, btw I ran that custom for mgs4 on the deck I'm amazed it got that far in game
  • K3N1 @ K3N1:
    Plug in*
  • K3N1 @ K3N1:
    Your favorite activity
  • BentlyMods @ BentlyMods:
    My fav actvity is:

    mario-dancing.gif
    BentlyMods @ BentlyMods: My fav actvity is: