Skip to content

Commit b22a00f

Browse files
committed
sdl3: Add to feature list
1 parent 788ee0e commit b22a00f

4 files changed

Lines changed: 52 additions & 16 deletions

File tree

input/drivers_joypad/sdl3_joypad.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static void sdl3_joypad_connect(SDL_JoystickID jid)
124124
{
125125
SDL_CloseGamepad(pad->gamepad);
126126
pad->gamepad = NULL;
127+
pad->joypad = NULL;
127128
}
128129
else if (pad->joypad)
129130
{
@@ -218,8 +219,8 @@ static void sdl3_joypad_destroy(void)
218219

219220
static void *sdl3_joypad_init(void *data)
220221
{
221-
int i, count = 0;
222-
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
222+
int i, count = 0;
223+
SDL_InitFlags sdl_subsystem_flags = SDL_WasInit(0);
223224

224225
if (sdl_subsystem_flags == 0)
225226
{
@@ -412,18 +413,12 @@ static void sdl3_joypad_poll(void)
412413
static bool sdl3_joypad_set_rumble(unsigned pad,
413414
enum retro_rumble_effect effect, uint16_t strength)
414415
{
415-
sdl3_joypad_t *joypad;
416416
uint16_t low = 0;
417417
uint16_t high = 0;
418418

419419
if (pad >= MAX_USERS)
420420
return false;
421421

422-
joypad = (sdl3_joypad_t*)&sdl3_joypads[pad];
423-
424-
if (!joypad->joypad)
425-
return false;
426-
427422
switch (effect)
428423
{
429424
case RETRO_RUMBLE_STRONG:
@@ -436,9 +431,12 @@ static bool sdl3_joypad_set_rumble(unsigned pad,
436431
return false;
437432
}
438433

439-
if (joypad->gamepad)
440-
return SDL_RumbleGamepad(joypad->gamepad, low, high, 5000);
441-
return SDL_RumbleJoystick(joypad->joypad, low, high, 5000);
434+
if (sdl3_joypads[pad].gamepad)
435+
return SDL_RumbleGamepad(sdl3_joypads[pad].gamepad, low, high, 5000);
436+
else if (sdl3_joypads[pad].joypad)
437+
return SDL_RumbleJoystick(sdl3_joypads[pad].joypad, low, high, 5000);
438+
439+
return false;
442440
}
443441

444442
/**

input/input_autodetect_builtin.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@
3232
#include <wiiu/pad_strings.h>
3333
#endif
3434

35+
#ifdef HAVE_SDL3
36+
#include <SDL3/SDL.h>
37+
#endif
38+
3539
#define DECL_BTN(btn, bind) "input_" #btn "_btn = " #bind "\n"
3640
#define DECL_BTN_EX(btn, bind, name) "input_" #btn "_btn = " #bind "\ninput_" #btn "_btn_label = \"" name "\"\n"
3741
#define DECL_AXIS(axis, bind) "input_" #axis "_axis = " #bind "\n"
3842
#define DECL_AXIS_EX(axis, bind, name) "input_" #axis "_axis = " #bind "\ninput_" #axis "_axis_label = \"" name "\"\n"
3943
#define DECL_MENU(btn) "input_menu_toggle_btn = " #btn "\n"
44+
#define DECL_MENU_EX(btn, name) "input_menu_toggle_btn = " #btn "\ninput_menu_toggle_btn_label = \"" name "\"\n"
4045
#define DECL_AUTOCONF_DEVICE(device, driver, binds) "input_device = \"" device "\"\ninput_driver = \"" driver "\"\n" binds
4146
#define DECL_AUTOCONF_PID(pid, vid, driver, binds) "input_product_id = " #pid "\ninput_vendor_id = " #vid "\ninput_driver = \"" driver "\"\n" binds
4247

@@ -66,6 +71,33 @@ DECL_AXIS(r_x_minus, -2) \
6671
DECL_AXIS(r_y_plus, -3) \
6772
DECL_AXIS(r_y_minus, +3)
6873

74+
#define SDL3_DEFAULT_BINDS \
75+
DECL_BTN_EX(a, SDL_GAMEPAD_BUTTON_EAST, "Right Face Button") \
76+
DECL_BTN_EX(b, SDL_GAMEPAD_BUTTON_SOUTH, "Bottom Face Button") \
77+
DECL_BTN_EX(x, SDL_GAMEPAD_BUTTON_NORTH, "Top Face Button") \
78+
DECL_BTN_EX(y, SDL_GAMEPAD_BUTTON_WEST, "Left Face Button") \
79+
DECL_BTN_EX(select, SDL_GAMEPAD_BUTTON_BACK, "Back") \
80+
DECL_BTN_EX(start, SDL_GAMEPAD_BUTTON_START, "Start") \
81+
DECL_BTN_EX(up, SDL_GAMEPAD_BUTTON_DPAD_UP, "D-Pad Up") \
82+
DECL_BTN_EX(down, SDL_GAMEPAD_BUTTON_DPAD_DOWN, "D-Pad Down") \
83+
DECL_BTN_EX(left, SDL_GAMEPAD_BUTTON_DPAD_LEFT, "D-Pad Left") \
84+
DECL_BTN_EX(right, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, "D-Pad Right") \
85+
DECL_BTN_EX(l, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, "Left Shoulder") \
86+
DECL_BTN_EX(r, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, "Right Shoulder") \
87+
DECL_AXIS_EX(l2, +SDL_GAMEPAD_AXIS_LEFT_TRIGGER, "Left Trigger") \
88+
DECL_AXIS_EX(r2, +SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, "Right Trigger") \
89+
DECL_BTN_EX(l3, SDL_GAMEPAD_BUTTON_LEFT_STICK, "Left Stick") \
90+
DECL_BTN_EX(r3, SDL_GAMEPAD_BUTTON_RIGHT_STICK, "Right Stick") \
91+
DECL_AXIS_EX(l_x_plus, +SDL_GAMEPAD_AXIS_LEFTX, "Left Thumbstick X+") \
92+
DECL_AXIS_EX(l_x_minus, -SDL_GAMEPAD_AXIS_LEFTX, "Left Thumbstick X-") \
93+
DECL_AXIS_EX(l_y_plus, +SDL_GAMEPAD_AXIS_LEFTY, "Left Thumbstick Y+") \
94+
DECL_AXIS_EX(l_y_minus, -SDL_GAMEPAD_AXIS_LEFTY, "Left Thumbstick Y-") \
95+
DECL_AXIS_EX(r_x_plus, +SDL_GAMEPAD_AXIS_RIGHTX, "Right Thumbstick X+") \
96+
DECL_AXIS_EX(r_x_minus, -SDL_GAMEPAD_AXIS_RIGHTX, "Right Thumbstick X-") \
97+
DECL_AXIS_EX(r_y_plus, -SDL_GAMEPAD_AXIS_RIGHTY, "Right Thumbstick Y+") \
98+
DECL_AXIS_EX(r_y_minus, +SDL_GAMEPAD_AXIS_RIGHTY, "Right Thumbstick Y-") \
99+
DECL_MENU_EX(SDL_GAMEPAD_BUTTON_GUIDE, "Guide")
100+
69101
#if defined(DINGUX) && defined(HAVE_SDL_DINGUX)
70102
#define DINGUX_SDL_DEFAULT_BINDS \
71103
DECL_BTN_EX(a, 8, "A") \
@@ -721,7 +753,7 @@ const char* const input_builtin_autoconfs[] =
721753
DECL_AUTOCONF_DEVICE("Standard Gamepad", "sdl2", SDL2_DEFAULT_BINDS),
722754
#endif
723755
#ifdef HAVE_SDL3
724-
DECL_AUTOCONF_DEVICE("Standard Gamepad", "sdl3", SDL2_DEFAULT_BINDS),
756+
DECL_AUTOCONF_DEVICE("Gamepad", "sdl3", SDL3_DEFAULT_BINDS),
725757
#endif
726758
#if defined(DINGUX) && defined(HAVE_SDL_DINGUX)
727759
DECL_AUTOCONF_DEVICE("Dingux Gamepad", "sdl_dingux", DINGUX_SDL_DEFAULT_BINDS),

menu/menu_displaylist.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static int filebrowser_parse(
408408
? FILE_TYPE_VIDEO_FONT
409409
: (enum msg_file_type)type_default;
410410

411-
if ( type == DISPLAYLIST_CORES_DETECTED
411+
if ( type == DISPLAYLIST_CORES_DETECTED
412412
&& path_is_compressed_file(file_path))
413413
file_type = FILE_TYPE_CARCHIVE;
414414
break;
@@ -631,7 +631,7 @@ static int menu_displaylist_parse_core_info(
631631
core_info = core_info_menu;
632632
}
633633

634-
if ( !core_info
634+
if ( !core_info
635635
|| !(core_info->flags & CORE_INFO_FLAG_HAS_INFO))
636636
{
637637
if (menu_entries_append(list,
@@ -2390,6 +2390,9 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
23902390
#ifdef HAVE_SDL2
23912391
{SUPPORTS_SDL2, "SDL 2"},
23922392
#endif
2393+
#ifdef HAVE_SDL3
2394+
{SUPPORTS_SDL3, "SDL 3"},
2395+
#endif
23932396
#ifdef HAVE_X11
23942397
{SUPPORTS_X11, "X11"},
23952398
#endif
@@ -5059,7 +5062,7 @@ static unsigned menu_displaylist_parse_content_information(
50595062

50605063
if (core_info_find(core_path, &core_info))
50615064
{
5062-
core_supports_no_game = (core_info->flags
5065+
core_supports_no_game = (core_info->flags
50635066
& CORE_INFO_FLAG_SUPPORTS_NO_GAME);
50645067
if (!string_is_empty(core_info->display_name))
50655068
strlcpy(core_name, core_info->display_name, sizeof(core_name));
@@ -10084,7 +10087,7 @@ unsigned menu_displaylist_build_list(
1008410087
MENU_ENUM_LABEL_VIDEO_HDR_SCANLINES,
1008510088
PARSE_ONLY_BOOL, false) == 0)
1008610089
count++;
10087-
10090+
1008810091
if(settings->bools.video_hdr_scanlines)
1008910092
{
1009010093
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,

retroarch.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6466,6 +6466,9 @@ static void retroarch_print_features(void)
64666466
#ifdef HAVE_SDL2
64676467
_len += _PSUPP_BUF(buf, _len, SUPPORTS_SDL2, "SDL2", "SDL2 input/audio/video drivers");
64686468
#endif
6469+
#ifdef HAVE_SDL3
6470+
_len += _PSUPP_BUF(buf, _len, SUPPORTS_SDL3, "SDL3", "SDL3 joypad driver");
6471+
#endif
64696472
#ifdef HAVE_X11
64706473
_len += _PSUPP_BUF(buf, _len, SUPPORTS_X11, "X11", "X11 input/video drivers");
64716474
#endif

0 commit comments

Comments
 (0)