Homebrew Discussion SDL2 Joycon Bindings

00Cancer

Well-Known Member
OP
Newcomer
Joined
Feb 1, 2017
Messages
67
Trophies
0
Age
20
XP
103
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,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • light27 @ light27:
    it was like
  • light27 @ light27:
    "wake up dr frema. wake up and smell da ashes.."
  • Xdqwerty @ Xdqwerty:
    @light27, did you reincarnate?
  • light27 @ light27:
    yes
  • light27 @ light27:
    also another thing, why do i always open gbatemp chat at the most unfortunate times
  • light27 @ light27:
    you guys need to stay away from @AncientBoi o.o
  • Xdqwerty @ Xdqwerty:
    @light27, why is talking about my birthday something bad?
  • light27 @ light27:
    wait what? oh
  • light27 @ light27:
    my bad
  • light27 @ light27:
    happy birthday
  • light27 @ light27:
    OIP.19q3E5NK_Mdn0K35CZWrWQHaJ4
    for you bro
    +2
  • Xdqwerty @ Xdqwerty:
    @light27, it's actually tommorrow but thx
  • light27 @ light27:
    oh it’s the least I could do
    +1
  • K3Nv2 @ K3Nv2:
    yawn
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, stop stealing my phrases
  • K3Nv2 @ K3Nv2:
    why
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, it's not funny
  • K3Nv2 @ K3Nv2:
    ok
  • BigOnYa @ BigOnYa:
    Wut?
  • K3Nv2 @ K3Nv2:
    That's not funny
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    So two cannibals where eating a clown and one says to the other. Hey does this taste funny to you?
    +1
  • K3Nv2 @ K3Nv2:
    What do you call a slow car? Retired
  • Psionic Roshambo @ Psionic Roshambo:
    Did you hear about the police car that someone stole the wheels off of? The police are working tirelessly to find the thieves.
    +1
  • K3Nv2 @ K3Nv2:
    A firefighter got arrested for assault his main claim was what I was told he was on fire
  • BigOnYa @ BigOnYa:
    What do you call a hooker with a runny nose? Full
    BigOnYa @ BigOnYa: What do you call a hooker with a runny nose? Full