mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
add builtin autoconf script for emscripten gamepads with "standard" mapping
This commit is contained in:
parent
b3900217da
commit
4fd750b48a
@ -32,10 +32,22 @@ static bool g_rwebpad_initialized;
|
||||
static EM_BOOL rwebpad_gamepad_cb(int event_type,
|
||||
const EmscriptenGamepadEvent *gamepad_event, void *user_data)
|
||||
{
|
||||
unsigned vid = 0;
|
||||
unsigned pid = 0;
|
||||
|
||||
(void)event_type;
|
||||
(void)gamepad_event;
|
||||
(void)user_data;
|
||||
|
||||
if (strncmp(gamepad_event->mapping, "standard",
|
||||
sizeof(gamepad_event->mapping)) == 0)
|
||||
{
|
||||
/* give a dummy vid/pid for automapping */
|
||||
vid = 1;
|
||||
pid = 1;
|
||||
}
|
||||
|
||||
|
||||
if (event_type == EMSCRIPTEN_EVENT_GAMEPADCONNECTED)
|
||||
{
|
||||
if(!input_autoconfigure_connect(
|
||||
@ -43,8 +55,8 @@ static EM_BOOL rwebpad_gamepad_cb(int event_type,
|
||||
NULL, /* display name */
|
||||
rwebpad_joypad.ident, /* driver */
|
||||
gamepad_event->index, /* idx */
|
||||
0, /* vid */
|
||||
0)) /* pid */
|
||||
vid, /* vid */
|
||||
pid)) /* pid */
|
||||
input_config_set_device_name(gamepad_event->index,
|
||||
gamepad_event->id);
|
||||
}
|
||||
|
@ -37,7 +37,8 @@
|
||||
#define DECL_AXIS(axis, bind) "input_" #axis "_axis = " #bind "\n"
|
||||
#define DECL_AXIS_EX(axis, bind, name) "input_" #axis "_axis = " #bind "\ninput_" #axis "_axis_label = \"" name "\"\n"
|
||||
#define DECL_MENU(btn) "input_menu_toggle_btn = " #btn "\n"
|
||||
#define DECL_AUTOCONF_DEVICE(device, driver, binds) "input_device = \"" device "\" \ninput_driver = \"" driver "\" \n" binds
|
||||
#define DECL_AUTOCONF_DEVICE(device, driver, binds) "input_device = \"" device "\"\ninput_driver = \"" driver "\"\n" binds
|
||||
#define DECL_AUTOCONF_PID(pid, vid, driver, binds) "input_product_id = " #pid "\ninput_vendor_id = " #vid "\ninput_driver = \"" driver "\"\n" binds
|
||||
|
||||
/* TODO/FIXME - Missing L2/R2 */
|
||||
|
||||
@ -528,6 +529,32 @@ DECL_AXIS(r_x_minus, -2) \
|
||||
DECL_AXIS(r_y_plus, +3) \
|
||||
DECL_AXIS(r_y_minus, -3)
|
||||
|
||||
#define EMSCRIPTEN_DEFAULT_BINDS \
|
||||
DECL_BTN(a, 1) \
|
||||
DECL_BTN(b, 0) \
|
||||
DECL_BTN(x, 3) \
|
||||
DECL_BTN(y, 2) \
|
||||
DECL_BTN(start, 9) \
|
||||
DECL_BTN(select, 8) \
|
||||
DECL_BTN(up, 12) \
|
||||
DECL_BTN(down, 13) \
|
||||
DECL_BTN(left, 14) \
|
||||
DECL_BTN(right, 15) \
|
||||
DECL_BTN(l, 4) \
|
||||
DECL_BTN(r, 5) \
|
||||
DECL_BTN(l2, 6) \
|
||||
DECL_BTN(r2, 7) \
|
||||
DECL_BTN(l3, 10) \
|
||||
DECL_BTN(r3, 11) \
|
||||
DECL_AXIS(l_x_plus, +0) \
|
||||
DECL_AXIS(l_x_minus, -0) \
|
||||
DECL_AXIS(l_y_plus, +1) \
|
||||
DECL_AXIS(l_y_minus, -1) \
|
||||
DECL_AXIS(r_x_plus, +2) \
|
||||
DECL_AXIS(r_x_minus, -2) \
|
||||
DECL_AXIS(r_y_plus, +3) \
|
||||
DECL_AXIS(r_y_minus, -3)
|
||||
|
||||
const char* const input_builtin_autoconfs[] =
|
||||
{
|
||||
#if defined(_WIN32) && defined(_XBOX)
|
||||
@ -588,6 +615,9 @@ const char* const input_builtin_autoconfs[] =
|
||||
#endif
|
||||
#ifdef __SWITCH__
|
||||
DECL_AUTOCONF_DEVICE("Switch Controller", "switch", SWITCH_DEFAULT_BINDS),
|
||||
#endif
|
||||
#ifdef EMSCRIPTEN
|
||||
DECL_AUTOCONF_PID(1, 1, "rwebpad", EMSCRIPTEN_DEFAULT_BINDS),
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user