input: add SDL_GameControllerDB

This commit is contained in:
Megamouse 2023-08-26 12:24:47 +02:00
parent d105b0bd9f
commit 452a4654da
8 changed files with 43 additions and 1 deletions

View File

@ -7,8 +7,11 @@ ARTIFACT_DIR="$BUILD_ARTIFACTSTAGINGDIRECTORY"
rm -f ./bin/rpcs3.exp ./bin/rpcs3.lib ./bin/rpcs3.pdb ./bin/vc_redist.x64.exe
rm -rf ./bin/git
# Prepare compatibility database for packaging, as well as
# Prepare compatibility and SDL database for packaging, as well as
# certificate for ssl (auto-updater)
mkdir ./bin/config
mkdir ./bin/config/input_configs
curl -fsSL 'https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt' 1> ./bin/config/input_configs/gamecontrollerdb.txt
curl -fsSL 'https://rpcs3.net/compatibility?api=v1&export' | iconv -t UTF-8 1> ./bin/GuiConfigs/compat_database.dat
curl -fsSL 'https://curl.haxx.se/ca/cacert.pem' 1> ./bin/cacert.pem

1
.gitmodules vendored
View File

@ -87,3 +87,4 @@
[submodule "3rdparty/rtmidi/rtmidi"]
path = 3rdparty/rtmidi/rtmidi
url = ../../thestk/rtmidi
ignore = dirty

View File

@ -278,6 +278,7 @@ struct cfg_root : cfg::node
cfg::_bool show_move_cursor{this, "Show move cursor", false, true};
cfg::_bool lock_overlay_input_to_player_one{this, "Lock overlay input to player one", false, true};
cfg::string midi_devices{ this, "Emulated Midi devices", "ßßß@@@ßßß@@@ßßß@@@" };
cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };
} io{ this };
struct node_sys : cfg::node

View File

@ -2,6 +2,8 @@
#include "stdafx.h"
#include "sdl_pad_handler.h"
#include "Emu/system_utils.hpp"
#include "Emu/system_config.h"
LOG_CHANNEL(sdl_log, "SDL");
@ -217,6 +219,24 @@ bool sdl_pad_handler::Init()
}
}, nullptr);
if (g_cfg.io.load_sdl_mappings)
{
const std::string db_path = rpcs3::utils::get_input_config_root() + "gamecontrollerdb.txt";
sdl_log.notice("Adding mappings from file '%s'", db_path);
if (fs::is_file(db_path))
{
if (SDL_GameControllerAddMappingsFromFile(db_path.c_str()) < 0)
{
sdl_log.error("Could not add mappings from file '%s'! SDL Error: %s", db_path, SDL_GetError());
}
}
else
{
sdl_log.error("Could not add mappings from file '%s'! File does not exist!", db_path);
}
}
m_is_init = true;
enumerate_devices();

View File

@ -157,6 +157,7 @@ enum class emu_settings_type
Turntable,
GHLtar,
MidiDevices,
SDLMappings,
// Misc
ExitRPCS3OnFinish,
@ -341,6 +342,7 @@ inline static const QMap<emu_settings_type, cfg_location> settings_location =
{ emu_settings_type::Turntable, { "Input/Output", "Turntable emulated controller" }},
{ emu_settings_type::GHLtar, { "Input/Output", "GHLtar emulated controller" }},
{ emu_settings_type::MidiDevices, { "Input/Output", "Emulated Midi devices" }},
{ emu_settings_type::SDLMappings, { "Input/Output", "Load SDL GameController Mappings" }},
// Misc
{ emu_settings_type::ExitRPCS3OnFinish, { "Miscellaneous", "Exit RPCS3 when process finishes" }},

View File

@ -1226,6 +1226,13 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
m_emu_settings->EnhanceCheckBox(ui->lockOverlayInputToPlayerOne, emu_settings_type::LockOvlIptToP1);
SubscribeTooltip(ui->lockOverlayInputToPlayerOne, tooltips.settings.lock_overlay_input_to_player_one);
#if HAVE_SDL2
m_emu_settings->EnhanceCheckBox(ui->loadSdlMappings, emu_settings_type::SDLMappings);
SubscribeTooltip(ui->loadSdlMappings, tooltips.settings.sdl_mappings);
#else
ui->loadSdlMappings->setVisible(false);
#endif
// Midi
const QString midi_none = m_emu_settings->m_midi_creator.get_none();
const midi_device def_midi_device{ .type = midi_device_type::keyboard, .name = midi_none.toStdString() };

View File

@ -1810,6 +1810,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="loadSdlMappings">
<property name="text">
<string>Use SDL GameController Database</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacerIoAdditionalSettings">
<property name="orientation">

View File

@ -227,6 +227,7 @@ public:
const QString background_input = tr("Allows pad and keyboard input while the game window is unfocused.");
const QString show_move_cursor = tr("Shows the raw position of the PS Move input.\nThis can be very helpful during calibration screens.");
const QString midi_devices = tr("Select up to 3 emulated MIDI devices and their types.");
const QString sdl_mappings = tr("Loads the SDL GameController database for improved gamepad compatibility. Only used in the SDL pad handler.");
const QString lock_overlay_input_to_player_one = tr("Locks the native overlay input to the first player.");