mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
input: fix pad defaults when config file was empty
This commit is contained in:
parent
ac986c7c61
commit
aa48bd91f4
4 changed files with 109 additions and 87 deletions
|
@ -90,7 +90,25 @@ void pad_thread::Init()
|
|||
handlers.clear();
|
||||
|
||||
g_cfg_profile.load();
|
||||
g_cfg_input.load(pad::g_title_id, g_cfg_profile.active_profiles.get_value(pad::g_title_id));
|
||||
|
||||
// Load in order to get the pad handlers
|
||||
if (!g_cfg_input.load(pad::g_title_id, g_cfg_profile.active_profiles.get_value(pad::g_title_id)))
|
||||
{
|
||||
input_log.notice("Loaded empty pad config");
|
||||
}
|
||||
|
||||
// Adjust to the different pad handlers
|
||||
for (usz i = 0; i < g_cfg_input.player.size(); i++)
|
||||
{
|
||||
std::shared_ptr<PadHandlerBase> handler;
|
||||
pad_thread::InitPadConfig(g_cfg_input.player[i]->config, g_cfg_input.player[i]->handler, handler);
|
||||
}
|
||||
|
||||
// Reload with proper defaults
|
||||
if (!g_cfg_input.load(pad::g_title_id, g_cfg_profile.active_profiles.get_value(pad::g_title_id)))
|
||||
{
|
||||
input_log.notice("Reloaded empty pad config");
|
||||
}
|
||||
|
||||
std::shared_ptr<keyboard_pad_handler> keyptr;
|
||||
|
||||
|
@ -336,3 +354,72 @@ void pad_thread::UnregisterLddPad(u32 handle)
|
|||
|
||||
num_ldd_pad--;
|
||||
}
|
||||
|
||||
std::shared_ptr<PadHandlerBase> pad_thread::GetHandler(pad_handler type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case pad_handler::null:
|
||||
return std::make_unique<NullPadHandler>();
|
||||
case pad_handler::keyboard:
|
||||
return std::make_unique<keyboard_pad_handler>();
|
||||
case pad_handler::ds3:
|
||||
return std::make_unique<ds3_pad_handler>();
|
||||
case pad_handler::ds4:
|
||||
return std::make_unique<ds4_pad_handler>();
|
||||
case pad_handler::dualsense:
|
||||
return std::make_unique<dualsense_pad_handler>();
|
||||
#ifdef _WIN32
|
||||
case pad_handler::xinput:
|
||||
return std::make_unique<xinput_pad_handler>();
|
||||
case pad_handler::mm:
|
||||
return std::make_unique<mm_joystick_handler>();
|
||||
#endif
|
||||
#ifdef HAVE_LIBEVDEV
|
||||
case pad_handler::evdev:
|
||||
return std::make_unique<evdev_joystick_handler>();
|
||||
#endif
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void pad_thread::InitPadConfig(cfg_pad& cfg, pad_handler type, std::shared_ptr<PadHandlerBase>& handler)
|
||||
{
|
||||
if (!handler)
|
||||
{
|
||||
handler = GetHandler(type);
|
||||
}
|
||||
|
||||
switch (handler->m_type)
|
||||
{
|
||||
case pad_handler::null:
|
||||
static_cast<NullPadHandler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
case pad_handler::keyboard:
|
||||
static_cast<keyboard_pad_handler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
case pad_handler::ds3:
|
||||
static_cast<ds3_pad_handler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
case pad_handler::ds4:
|
||||
static_cast<ds4_pad_handler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
case pad_handler::dualsense:
|
||||
static_cast<dualsense_pad_handler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
#ifdef _WIN32
|
||||
case pad_handler::xinput:
|
||||
static_cast<xinput_pad_handler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
case pad_handler::mm:
|
||||
static_cast<mm_joystick_handler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LIBEVDEV
|
||||
case pad_handler::evdev:
|
||||
static_cast<evdev_joystick_handler*>(handler.get())->init_config(&cfg);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue