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.
To setup the Joycons you first must create a Joystick in SDL and then later handle the events:
Hope this helps anyone trying to use Joycon input with SDL
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
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;
}
}
Last edited by 00Cancer,