fix: dpad controls en emscripten
This commit is contained in:
@@ -17,6 +17,14 @@
|
||||
// garantiza el layout estándar cuando el navegador reporta mapping=="standard",
|
||||
// inyectamos un mapping SDL con ese layout para el GUID del joystick antes
|
||||
// de abrirlo como gamepad. Fuera de Emscripten es un no-op.
|
||||
//
|
||||
// OJO: el layout W3C "standard" NO se expone tal cual al joystick SDL. El
|
||||
// driver de SDL3 (src/joystick/emscripten/SDL_sysjoystick.c) reempaqueta el
|
||||
// gamepad W3C antes de entregarlo: los 4 botones del d-pad (W3C b12-b15) se
|
||||
// convierten en un hat (hat 0), los 2 botones de triggers (W3C b6-b7) se
|
||||
// convierten en ejes analógicos (a4-a5 si el mando tenía 4 ejes) y los
|
||||
// botones restantes se renumeran compactándose. Por eso el mapping tiene que
|
||||
// referirse a la numeración *después* del remap, no a la del W3C.
|
||||
static void installWebStandardMapping(SDL_JoystickID jid) {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
SDL_GUID guid = SDL_GetJoystickGUIDForID(jid);
|
||||
@@ -30,12 +38,11 @@ static void installWebStandardMapping(SDL_JoystickID jid) {
|
||||
"%s,%s,"
|
||||
"a:b0,b:b1,x:b2,y:b3,"
|
||||
"leftshoulder:b4,rightshoulder:b5,"
|
||||
"lefttrigger:b6,righttrigger:b7,"
|
||||
"back:b8,start:b9,"
|
||||
"leftstick:b10,rightstick:b11,"
|
||||
"dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,"
|
||||
"guide:b16,"
|
||||
"back:b6,start:b7,"
|
||||
"leftstick:b8,rightstick:b9,"
|
||||
"dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,"
|
||||
"leftx:a0,lefty:a1,rightx:a2,righty:a3,"
|
||||
"lefttrigger:a4,righttrigger:a5,"
|
||||
"platform:Emscripten",
|
||||
guidStr, name);
|
||||
SDL_AddGamepadMapping(mapping);
|
||||
|
||||
Reference in New Issue
Block a user