Skip to content

Commit 452a465

Browse files
committed
input: add SDL_GameControllerDB
1 parent d105b0b commit 452a465

File tree

8 files changed

+43
-1
lines changed

8 files changed

+43
-1
lines changed

.ci/deploy-windows.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ ARTIFACT_DIR="$BUILD_ARTIFACTSTAGINGDIRECTORY"
77
rm -f ./bin/rpcs3.exp ./bin/rpcs3.lib ./bin/rpcs3.pdb ./bin/vc_redist.x64.exe
88
rm -rf ./bin/git
99

10-
# Prepare compatibility database for packaging, as well as
10+
# Prepare compatibility and SDL database for packaging, as well as
1111
# certificate for ssl (auto-updater)
12+
mkdir ./bin/config
13+
mkdir ./bin/config/input_configs
14+
curl -fsSL 'https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt' 1> ./bin/config/input_configs/gamecontrollerdb.txt
1215
curl -fsSL 'https://rpcs3.net/compatibility?api=v1&export' | iconv -t UTF-8 1> ./bin/GuiConfigs/compat_database.dat
1316
curl -fsSL 'https://curl.haxx.se/ca/cacert.pem' 1> ./bin/cacert.pem
1417

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@
8787
[submodule "3rdparty/rtmidi/rtmidi"]
8888
path = 3rdparty/rtmidi/rtmidi
8989
url = ../../thestk/rtmidi
90+
ignore = dirty

rpcs3/Emu/system_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ struct cfg_root : cfg::node
278278
cfg::_bool show_move_cursor{this, "Show move cursor", false, true};
279279
cfg::_bool lock_overlay_input_to_player_one{this, "Lock overlay input to player one", false, true};
280280
cfg::string midi_devices{ this, "Emulated Midi devices", "ßßß@@@ßßß@@@ßßß@@@" };
281+
cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };
281282
} io{ this };
282283

283284
struct node_sys : cfg::node

rpcs3/Input/sdl_pad_handler.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "stdafx.h"
44
#include "sdl_pad_handler.h"
5+
#include "Emu/system_utils.hpp"
6+
#include "Emu/system_config.h"
57

68
LOG_CHANNEL(sdl_log, "SDL");
79

@@ -217,6 +219,24 @@ bool sdl_pad_handler::Init()
217219
}
218220
}, nullptr);
219221

222+
if (g_cfg.io.load_sdl_mappings)
223+
{
224+
const std::string db_path = rpcs3::utils::get_input_config_root() + "gamecontrollerdb.txt";
225+
sdl_log.notice("Adding mappings from file '%s'", db_path);
226+
227+
if (fs::is_file(db_path))
228+
{
229+
if (SDL_GameControllerAddMappingsFromFile(db_path.c_str()) < 0)
230+
{
231+
sdl_log.error("Could not add mappings from file '%s'! SDL Error: %s", db_path, SDL_GetError());
232+
}
233+
}
234+
else
235+
{
236+
sdl_log.error("Could not add mappings from file '%s'! File does not exist!", db_path);
237+
}
238+
}
239+
220240
m_is_init = true;
221241
enumerate_devices();
222242

rpcs3/rpcs3qt/emu_settings_type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ enum class emu_settings_type
157157
Turntable,
158158
GHLtar,
159159
MidiDevices,
160+
SDLMappings,
160161

161162
// Misc
162163
ExitRPCS3OnFinish,
@@ -341,6 +342,7 @@ inline static const QMap<emu_settings_type, cfg_location> settings_location =
341342
{ emu_settings_type::Turntable, { "Input/Output", "Turntable emulated controller" }},
342343
{ emu_settings_type::GHLtar, { "Input/Output", "GHLtar emulated controller" }},
343344
{ emu_settings_type::MidiDevices, { "Input/Output", "Emulated Midi devices" }},
345+
{ emu_settings_type::SDLMappings, { "Input/Output", "Load SDL GameController Mappings" }},
344346

345347
// Misc
346348
{ emu_settings_type::ExitRPCS3OnFinish, { "Miscellaneous", "Exit RPCS3 when process finishes" }},

rpcs3/rpcs3qt/settings_dialog.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,13 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
12261226
m_emu_settings->EnhanceCheckBox(ui->lockOverlayInputToPlayerOne, emu_settings_type::LockOvlIptToP1);
12271227
SubscribeTooltip(ui->lockOverlayInputToPlayerOne, tooltips.settings.lock_overlay_input_to_player_one);
12281228

1229+
#if HAVE_SDL2
1230+
m_emu_settings->EnhanceCheckBox(ui->loadSdlMappings, emu_settings_type::SDLMappings);
1231+
SubscribeTooltip(ui->loadSdlMappings, tooltips.settings.sdl_mappings);
1232+
#else
1233+
ui->loadSdlMappings->setVisible(false);
1234+
#endif
1235+
12291236
// Midi
12301237
const QString midi_none = m_emu_settings->m_midi_creator.get_none();
12311238
const midi_device def_midi_device{ .type = midi_device_type::keyboard, .name = midi_none.toStdString() };

rpcs3/rpcs3qt/settings_dialog.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,13 @@
18101810
</property>
18111811
</widget>
18121812
</item>
1813+
<item>
1814+
<widget class="QCheckBox" name="loadSdlMappings">
1815+
<property name="text">
1816+
<string>Use SDL GameController Database</string>
1817+
</property>
1818+
</widget>
1819+
</item>
18131820
<item>
18141821
<spacer name="verticalSpacerIoAdditionalSettings">
18151822
<property name="orientation">

rpcs3/rpcs3qt/tooltips.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class Tooltips : public QObject
227227
const QString background_input = tr("Allows pad and keyboard input while the game window is unfocused.");
228228
const QString show_move_cursor = tr("Shows the raw position of the PS Move input.\nThis can be very helpful during calibration screens.");
229229
const QString midi_devices = tr("Select up to 3 emulated MIDI devices and their types.");
230+
const QString sdl_mappings = tr("Loads the SDL GameController database for improved gamepad compatibility. Only used in the SDL pad handler.");
230231

231232
const QString lock_overlay_input_to_player_one = tr("Locks the native overlay input to the first player.");
232233

0 commit comments

Comments
 (0)