mirror of
https://github.com/libretro/RetroArch
synced 2025-02-05 15:40:04 +00:00
(NSW) add default button bindings and fix right joystick
This commit is contained in:
parent
6732afa608
commit
7cc614263a
@ -41,13 +41,8 @@ static int16_t switch_input_state(void *data,
|
||||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
#if 0
|
||||
return input_joypad_pressed(sw->joypad,
|
||||
joypad_info, port, binds[port], id);
|
||||
#else
|
||||
if (sw->joypad)
|
||||
return sw->joypad->button(port, id);
|
||||
#endif
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
|
@ -134,26 +134,11 @@ static void switch_joypad_poll(void)
|
||||
hid_controller_t *controllers = hid_get_shared_memory()->controllers;
|
||||
hid_controller_t *cont = &controllers[0];
|
||||
hid_controller_state_entry_t ent = cont->main.entries[cont->main.latest_idx];
|
||||
pad_state[0] = 0;
|
||||
pad_state[0] |= (ent.button_state & 0x1000) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x8000) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x4000) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x2000) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0400) ? (1 << RETRO_DEVICE_ID_JOYPAD_START) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0800) ? (1 << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0004) ? (1 << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0008) ? (1 << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0002) ? (1 << RETRO_DEVICE_ID_JOYPAD_B) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0001) ? (1 << RETRO_DEVICE_ID_JOYPAD_A) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0080) ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0040) ? (1 << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0200) ? (1 << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
|
||||
pad_state[0] |= (ent.button_state & 0x0100) ? (1 << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
|
||||
|
||||
pad_state[0] = ent.button_state;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = ent.left_stick_x / 0x20000;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = ent.left_stick_y / 0x20000;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = ent.left_stick_x / 0x20000;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = ent.left_stick_y / 0x20000;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = ent.right_stick_x / 0x20000;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = ent.right_stick_y / 0x20000;
|
||||
}
|
||||
|
||||
input_device_driver_t switch_joypad = {
|
||||
|
@ -502,6 +502,32 @@ DECL_AXIS(r_y_plus, -3) \
|
||||
DECL_AXIS(r_y_minus, +3)
|
||||
#endif
|
||||
|
||||
#define SWITCH_DEFAULT_BINDS \
|
||||
DECL_BTN(a, 0) \
|
||||
DECL_BTN(b, 1) \
|
||||
DECL_BTN(x, 2) \
|
||||
DECL_BTN(y, 3) \
|
||||
DECL_BTN(start, 10) \
|
||||
DECL_BTN(select, 11) \
|
||||
DECL_BTN(up, 13) \
|
||||
DECL_BTN(down, 15) \
|
||||
DECL_BTN(left, 12) \
|
||||
DECL_BTN(right, 14) \
|
||||
DECL_BTN(l, 6) \
|
||||
DECL_BTN(r, 7) \
|
||||
DECL_BTN(l2, 8) \
|
||||
DECL_BTN(r2, 9) \
|
||||
DECL_BTN(l3, 4) \
|
||||
DECL_BTN(r3, 5) \
|
||||
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)
|
||||
@ -559,6 +585,9 @@ const char* const input_builtin_autoconfs[] =
|
||||
#endif
|
||||
#ifdef __CELLOS_LV2__
|
||||
DECL_AUTOCONF_DEVICE("SixAxis Controller", "ps3", PS3INPUT_DEFAULT_BINDS),
|
||||
#endif
|
||||
#ifdef __SWITCH__
|
||||
DECL_AUTOCONF_DEVICE("Switch Controller", "switch", SWITCH_DEFAULT_BINDS),
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user