Fix lint bugs

This commit is contained in:
iwubcode 2018-05-23 22:20:58 -05:00
parent b5db180ac4
commit 3b11066e61
11 changed files with 330 additions and 272 deletions

View File

@ -11,29 +11,43 @@ namespace Config
// WiimoteInput.Settings // WiimoteInput.Settings
const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_FAST{{System::WiiPad, "Swing", "Fast"}, 4.5}; const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_FAST{{System::WiiPad, "Swing", "Fast"}, 4.5};
const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM{ { System::WiiPad, "Swing", "Medium" }, 2.5 }; const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM{{System::WiiPad, "Swing", "Medium"},
2.5};
const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_SLOW{{System::WiiPad, "Swing", "Slow"}, 1.5}; const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_SLOW{{System::WiiPad, "Swing", "Slow"}, 1.5};
const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_HARD{{System::WiiPad, "Shake", "Hard"}, 5.0}; const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_HARD{{System::WiiPad, "Shake", "Hard"}, 5.0};
const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM{ { System::WiiPad, "Shake", "Medium" }, 3.0 }; const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM{{System::WiiPad, "Shake", "Medium"},
3.0};
const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT{{System::WiiPad, "Shake", "Soft"}, 2.0}; const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT{{System::WiiPad, "Shake", "Soft"}, 2.0};
// Dynamic settings // Dynamic settings
const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_FAST{ { System::WiiPad, "Dynamic_Swing", "FramesHeldFast" }, 100 }; const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_FAST{
const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_SLOW{ { System::WiiPad, "Dynamic_Swing", "FramesHeldSlow" }, 30 }; {System::WiiPad, "Dynamic_Swing", "FramesHeldFast"}, 100};
const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_LENGTH{ { System::WiiPad, "Dynamic_Swing", "FrameCount" }, 30 }; const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_SLOW{
{System::WiiPad, "Dynamic_Swing", "FramesHeldSlow"}, 30};
const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_LENGTH{
{System::WiiPad, "Dynamic_Swing", "FrameCount"}, 30};
const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_HARD{ { System::WiiPad, "Dynamic_Shake", "FramesHeldHard" }, 45 }; const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_HARD{
const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_SOFT{ { System::WiiPad, "Dynamic_Shake", "FramesHeldSoft" }, 15 }; {System::WiiPad, "Dynamic_Shake", "FramesHeldHard"}, 45};
const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_LENGTH{ { System::WiiPad, "Dynamic_Shake", "FrameCount" }, 30 }; const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_SOFT{
{System::WiiPad, "Dynamic_Shake", "FramesHeldSoft"}, 15};
const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_LENGTH{
{System::WiiPad, "Dynamic_Shake", "FrameCount"}, 30};
// NunchuckInput.Settings // NunchuckInput.Settings
const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_FAST{ { System::WiiPad, "Nunchuk_Swing", "Fast" }, 4.5 }; const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_FAST{
const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_MEDIUM{ { System::WiiPad, "Nunchuk_Swing", "Medium" }, 2.5 }; {System::WiiPad, "Nunchuk_Swing", "Fast"}, 4.5};
const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_SLOW{ { System::WiiPad, "Nunchuk_Swing", "Slow" }, 1.5 }; const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_MEDIUM{
{System::WiiPad, "Nunchuk_Swing", "Medium"}, 2.5};
const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_SLOW{
{System::WiiPad, "Nunchuk_Swing", "Slow"}, 1.5};
const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_HARD{ { System::WiiPad, "Nunchuk_Shake", "Hard" }, 5.0 }; const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_HARD{
const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM{ { System::WiiPad, "Nunchuk_Shake", "Medium" }, 3.0 }; {System::WiiPad, "Nunchuk_Shake", "Hard"}, 5.0};
const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT{ { System::WiiPad, "Nunchuk_Shake", "Soft" }, 2.0 }; const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM{
{System::WiiPad, "Nunchuk_Shake", "Medium"}, 3.0};
const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT{
{System::WiiPad, "Nunchuk_Shake", "Soft"}, 2.0};
} }

View File

@ -22,13 +22,19 @@ namespace Config
// Below settings are for dynamic input only (based on how long the user holds a button) // Below settings are for dynamic input only (based on how long the user holds a button)
extern const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_FAST; // How long button held constitutes a fast swing extern const ConfigInfo<int>
extern const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_SLOW; // How long button held constitutes a slow swing WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_FAST; // How long button held constitutes a fast swing
extern const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_LENGTH; // How long to execute the swing extern const ConfigInfo<int>
WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_SLOW; // How long button held constitutes a slow swing
extern const ConfigInfo<int>
WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_LENGTH; // How long to execute the swing
extern const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_HARD; // How long button held constitutes a hard shake extern const ConfigInfo<int>
extern const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_SOFT; // How long button held constitutes a soft shake WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_HARD; // How long button held constitutes a hard shake
extern const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_LENGTH; // How long to execute a shake extern const ConfigInfo<int>
WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_SOFT; // How long button held constitutes a soft shake
extern const ConfigInfo<int>
WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_LENGTH; // How long to execute a shake
// NunchuckInput.Settings // NunchuckInput.Settings

View File

@ -109,9 +109,12 @@ void Nunchuk::GetState(u8* const data)
EmulateSwing(&accel, m_swing_fast, Config::Get(Config::NUNCHUK_INPUT_SWING_INTENSITY_FAST)); EmulateSwing(&accel, m_swing_fast, Config::Get(Config::NUNCHUK_INPUT_SWING_INTENSITY_FAST));
// shake // shake
EmulateShake(&accel, m_shake, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM), m_shake_step.data()); EmulateShake(&accel, m_shake, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM),
EmulateShake(&accel, m_shake_soft, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT), m_shake_soft_step.data()); m_shake_step.data());
EmulateShake(&accel, m_shake_hard, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_HARD), m_shake_hard_step.data()); EmulateShake(&accel, m_shake_soft, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT),
m_shake_soft_step.data());
EmulateShake(&accel, m_shake_hard, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_HARD),
m_shake_hard_step.data());
// buttons // buttons
m_buttons->GetState(&nc_data.bt.hex, nunchuk_button_bitmasks.data()); m_buttons->GetState(&nc_data.bt.hex, nunchuk_button_bitmasks.data());

View File

@ -123,7 +123,8 @@ void EmulateShake(AccelData* const accel, ControllerEmu::Buttons* const buttons_
} }
} }
void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data, ControllerEmu::Buttons* const buttons_group, void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data,
ControllerEmu::Buttons* const buttons_group,
const DynamicConfiguration& config, u8* const shake_step) const DynamicConfiguration& config, u8* const shake_step)
{ {
// frame count of one up/down shake // frame count of one up/down shake
@ -232,7 +233,9 @@ void EmulateSwing(AccelData* const accel, ControllerEmu::Force* const swing_grou
} }
void EmulateDynamicSwing(AccelData* const accel, DynamicData& dynamic_data, void EmulateDynamicSwing(AccelData* const accel, DynamicData& dynamic_data,
ControllerEmu::Force* const swing_group, const DynamicConfiguration& config, const bool sideways, const bool upright) ControllerEmu::Force* const swing_group,
const DynamicConfiguration& config, const bool sideways,
const bool upright)
{ {
ControlState swing[3]; ControlState swing[3];
swing_group->GetState(swing); swing_group->GetState(swing);
@ -398,9 +401,12 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1
m_shake_hard->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z")); m_shake_hard->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z"));
groups.emplace_back(m_shake_dynamic = new ControllerEmu::Buttons("Shake Dynamic")); groups.emplace_back(m_shake_dynamic = new ControllerEmu::Buttons("Shake Dynamic"));
m_shake_dynamic->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "X")); m_shake_dynamic->controls.emplace_back(
m_shake_dynamic->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Y")); new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "X"));
m_shake_dynamic->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z")); m_shake_dynamic->controls.emplace_back(
new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Y"));
m_shake_dynamic->controls.emplace_back(
new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z"));
// extension // extension
groups.emplace_back(m_extension = new ControllerEmu::Extension(_trans("Extension"))); groups.emplace_back(m_extension = new ControllerEmu::Extension(_trans("Extension")));
@ -604,13 +610,18 @@ void Wiimote::GetAccelData(u8* const data, const ReportFeatures& rptf)
swing_config.low_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_SLOW); swing_config.low_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_SLOW);
swing_config.med_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM); swing_config.med_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM);
swing_config.high_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_FAST); swing_config.high_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_FAST);
swing_config.frames_needed_for_high_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_FAST); swing_config.frames_needed_for_high_intensity =
swing_config.frames_needed_for_low_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_SLOW); Config::Get(Config::WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_FAST);
swing_config.frames_needed_for_low_intensity =
Config::Get(Config::WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_SLOW);
swing_config.frames_to_execute = Config::Get(Config::WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_LENGTH); swing_config.frames_to_execute = Config::Get(Config::WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_LENGTH);
EmulateSwing(&m_accel, m_swing, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM), is_sideways, is_upright); EmulateSwing(&m_accel, m_swing, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM),
EmulateSwing(&m_accel, m_swing_slow, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_SLOW), is_sideways, is_upright); is_sideways, is_upright);
EmulateSwing(&m_accel, m_swing_fast, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_FAST), is_sideways, is_upright); EmulateSwing(&m_accel, m_swing_slow, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_SLOW),
is_sideways, is_upright);
EmulateSwing(&m_accel, m_swing_fast, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_FAST),
is_sideways, is_upright);
EmulateDynamicSwing(&m_accel, m_swing_dynamic_data, m_swing_dynamic, swing_config, is_sideways, EmulateDynamicSwing(&m_accel, m_swing_dynamic_data, m_swing_dynamic, swing_config, is_sideways,
is_upright); is_upright);
@ -618,17 +629,21 @@ void Wiimote::GetAccelData(u8* const data, const ReportFeatures& rptf)
shake_config.low_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT); shake_config.low_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT);
shake_config.med_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM); shake_config.med_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM);
shake_config.high_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_HARD); shake_config.high_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_HARD);
shake_config.frames_needed_for_high_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_HARD); shake_config.frames_needed_for_high_intensity =
shake_config.frames_needed_for_low_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_SOFT); Config::Get(Config::WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_HARD);
shake_config.frames_needed_for_low_intensity =
Config::Get(Config::WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_SOFT);
shake_config.frames_to_execute = Config::Get(Config::WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_LENGTH); shake_config.frames_to_execute = Config::Get(Config::WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_LENGTH);
EmulateShake(&m_accel, m_shake, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM), m_shake_step.data()); EmulateShake(&m_accel, m_shake, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM),
EmulateShake(&m_accel, m_shake_soft, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT), m_shake_soft_step.data()); m_shake_step.data());
EmulateShake(&m_accel, m_shake_hard, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_HARD), m_shake_hard_step.data()); EmulateShake(&m_accel, m_shake_soft, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT),
m_shake_soft_step.data());
EmulateShake(&m_accel, m_shake_hard, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_HARD),
m_shake_hard_step.data());
EmulateDynamicShake(&m_accel, m_shake_dynamic_data, m_shake_dynamic, shake_config, EmulateDynamicShake(&m_accel, m_shake_dynamic_data, m_shake_dynamic, shake_config,
m_shake_dynamic_step.data()); m_shake_dynamic_step.data());
wm_accel& accel = *reinterpret_cast<wm_accel*>(data + rptf.accel); wm_accel& accel = *reinterpret_cast<wm_accel*>(data + rptf.accel);
wm_buttons& core = *reinterpret_cast<wm_buttons*>(data + rptf.core); wm_buttons& core = *reinterpret_cast<wm_buttons*>(data + rptf.core);

View File

@ -186,8 +186,7 @@ void EmulateShake(AccelData* const accel_data, ControllerEmu::Buttons* const but
void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data, void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data,
ControllerEmu::Buttons* const buttons_group, ControllerEmu::Buttons* const buttons_group,
const DynamicConfiguration& config, const DynamicConfiguration& config, u8* const shake_step);
u8* const shake_step);
void EmulateTilt(AccelData* const accel, ControllerEmu::Tilt* const tilt_group, void EmulateTilt(AccelData* const accel, ControllerEmu::Tilt* const tilt_group,
const bool sideways = false, const bool upright = false); const bool sideways = false, const bool upright = false);
@ -197,8 +196,8 @@ void EmulateSwing(AccelData* const accel, ControllerEmu::Force* const tilt_group
void EmulateDynamicSwing(AccelData* const accel, DynamicData& dynamic_data, void EmulateDynamicSwing(AccelData* const accel, DynamicData& dynamic_data,
ControllerEmu::Force* const swing_group, ControllerEmu::Force* const swing_group,
const DynamicConfiguration& config, const DynamicConfiguration& config, const bool sideways = false,
const bool sideways = false, const bool upright = false); const bool upright = false);
enum enum
{ {

View File

@ -18,7 +18,8 @@ void HotkeyControllerProfile::CreateMainLayout()
{ {
m_main_layout = new QHBoxLayout(); m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(CreateGroupBox(tr("Controller Profile"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_CONTROLLER_PROFILE))); m_main_layout->addWidget(CreateGroupBox(
tr("Controller Profile"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_CONTROLLER_PROFILE)));
setLayout(m_main_layout); setLayout(m_main_layout);
} }

View File

@ -87,8 +87,8 @@ bool InputConfig::LoadConfig(bool isGC)
{ {
std::string base; std::string base;
SplitPath(profile[n], nullptr, &base, nullptr); SplitPath(profile[n], nullptr, &base, nullptr);
Core::DisplayMessage("Loading game specific input profile '" + base + Core::DisplayMessage("Loading game specific input profile '" + base + "' for device '" +
"' for device '" + controller->GetName() + "'", controller->GetName() + "'",
6000); 6000);
IniFile profile_ini; IniFile profile_ini;

View File

@ -20,7 +20,6 @@
namespace InputProfile namespace InputProfile
{ {
namespace namespace
{ {
constexpr int display_message_ms = 3000; constexpr int display_message_ms = 3000;
@ -28,11 +27,13 @@ namespace InputProfile
std::vector<std::string> ProfileCycler::GetProfilesForDevice(InputConfig* device_configuration) std::vector<std::string> ProfileCycler::GetProfilesForDevice(InputConfig* device_configuration)
{ {
const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" + device_configuration->GetProfileName()); const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" +
device_configuration->GetProfileName());
return Common::DoFileSearch({device_profile_root_location}, {".ini"}); return Common::DoFileSearch({device_profile_root_location}, {".ini"});
} }
std::string ProfileCycler::GetProfile(CycleDirection cycle_direction, int& profile_index, const std::vector<std::string>& profiles) std::string ProfileCycler::GetProfile(CycleDirection cycle_direction, int& profile_index,
const std::vector<std::string>& profiles)
{ {
// update the index and bind it to the number of available strings // update the index and bind it to the number of available strings
auto positive_modulo = [](int& i, int n) { i = (i % n + n) % n; }; auto positive_modulo = [](int& i, int n) { i = (i % n + n) % n; };
@ -42,7 +43,8 @@ namespace InputProfile
return profiles[profile_index]; return profiles[profile_index];
} }
void ProfileCycler::UpdateToProfile(const std::string& profile_filename, ControllerEmu::EmulatedController* controller) void ProfileCycler::UpdateToProfile(const std::string& profile_filename,
ControllerEmu::EmulatedController* controller)
{ {
std::string base; std::string base;
SplitPath(profile_filename, nullptr, &base, nullptr); SplitPath(profile_filename, nullptr, &base, nullptr);
@ -50,32 +52,41 @@ namespace InputProfile
IniFile ini_file; IniFile ini_file;
if (ini_file.Load(profile_filename)) if (ini_file.Load(profile_filename))
{ {
Core::DisplayMessage("Loading input profile '" + base + "' for device '" + controller->GetName() + "'", display_message_ms); Core::DisplayMessage("Loading input profile '" + base + "' for device '" +
controller->GetName() + "'",
display_message_ms);
controller->LoadConfig(ini_file.GetOrCreateSection("Profile")); controller->LoadConfig(ini_file.GetOrCreateSection("Profile"));
controller->UpdateReferences(g_controller_interface); controller->UpdateReferences(g_controller_interface);
} }
else else
{ {
Core::DisplayMessage("Unable to load input profile '" + base + "' for device '" + controller->GetName() + "'", display_message_ms); Core::DisplayMessage("Unable to load input profile '" + base + "' for device '" +
controller->GetName() + "'",
display_message_ms);
} }
} }
std::vector<std::string> ProfileCycler::GetProfilesFromSetting(const std::string& setting, InputConfig* device_configuration) std::vector<std::string> ProfileCycler::GetProfilesFromSetting(const std::string& setting,
InputConfig* device_configuration)
{ {
const auto& profiles = SplitString(setting, ','); const auto& profiles = SplitString(setting, ',');
const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" + device_configuration->GetProfileName()); const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" +
device_configuration->GetProfileName());
std::vector<std::string> result(profiles.size()); std::vector<std::string> result(profiles.size());
std::transform(profiles.begin(), profiles.end(), result.begin(), [&device_profile_root_location](const std::string& profile) std::transform(profiles.begin(), profiles.end(), result.begin(),
{ [&device_profile_root_location](const std::string& profile) {
return device_profile_root_location + "/" + StripSpaces(profile) + ".ini"; return device_profile_root_location + "/" + StripSpaces(profile) + ".ini";
}); });
return result; return result;
} }
std::vector<std::string> ProfileCycler::GetMatchingProfilesFromSetting(const std::string& setting, const std::vector<std::string>& profiles, InputConfig* device_configuration) std::vector<std::string>
ProfileCycler::GetMatchingProfilesFromSetting(const std::string& setting,
const std::vector<std::string>& profiles,
InputConfig* device_configuration)
{ {
const auto& profiles_from_setting = GetProfilesFromSetting(setting, device_configuration); const auto& profiles_from_setting = GetProfilesFromSetting(setting, device_configuration);
if (profiles_from_setting.empty()) if (profiles_from_setting.empty())
@ -89,9 +100,8 @@ namespace InputProfile
return result; return result;
} }
void ProfileCycler::CycleProfile(CycleDirection cycle_direction, void ProfileCycler::CycleProfile(CycleDirection cycle_direction, InputConfig* device_configuration,
InputConfig* device_configuration, int& profile_index, int& profile_index, int controller_index)
int controller_index)
{ {
const auto& profiles = GetProfilesForDevice(device_configuration); const auto& profiles = GetProfilesForDevice(device_configuration);
if (profiles.empty()) if (profiles.empty())
@ -108,7 +118,8 @@ namespace InputProfile
} }
else else
{ {
Core::DisplayMessage("No controller found for index: " + std::to_string(controller_index), display_message_ms); Core::DisplayMessage("No controller found for index: " + std::to_string(controller_index),
display_message_ms);
} }
} }
@ -129,8 +140,8 @@ namespace InputProfile
return; return;
} }
const auto& profiles_for_game = GetMatchingProfilesFromSetting(setting, profiles, const auto& profiles_for_game =
device_configuration); GetMatchingProfilesFromSetting(setting, profiles, device_configuration);
if (profiles_for_game.empty()) if (profiles_for_game.empty())
{ {
Core::DisplayMessage("No input profiles found for game", display_message_ms); Core::DisplayMessage("No input profiles found for game", display_message_ms);
@ -146,7 +157,8 @@ namespace InputProfile
} }
else else
{ {
Core::DisplayMessage("No controller found for index: " + std::to_string(controller_index), display_message_ms); Core::DisplayMessage("No controller found for index: " + std::to_string(controller_index),
display_message_ms);
} }
} }

View File

@ -29,14 +29,22 @@ namespace InputProfile
void PreviousWiimoteProfile(int controller_index); void PreviousWiimoteProfile(int controller_index);
void NextWiimoteProfileForGame(int controller_index); void NextWiimoteProfileForGame(int controller_index);
void PreviousWiimoteProfileForGame(int controller_index); void PreviousWiimoteProfileForGame(int controller_index);
private: private:
void CycleProfile(CycleDirection cycle_direction, InputConfig* device_configuration, int& profile_index, int controller_index); void CycleProfile(CycleDirection cycle_direction, InputConfig* device_configuration,
void CycleProfileForGame(CycleDirection cycle_direction, InputConfig* device_configuration, int& profile_index, const std::string& setting, int controller_index); int& profile_index, int controller_index);
void CycleProfileForGame(CycleDirection cycle_direction, InputConfig* device_configuration,
int& profile_index, const std::string& setting, int controller_index);
std::vector<std::string> GetProfilesForDevice(InputConfig* device_configuration); std::vector<std::string> GetProfilesForDevice(InputConfig* device_configuration);
std::vector<std::string> GetProfilesFromSetting(const std::string& setting, InputConfig* device_configuration); std::vector<std::string> GetProfilesFromSetting(const std::string& setting,
std::string GetProfile(CycleDirection cycle_direction, int& profile_index, const std::vector<std::string>& profiles); InputConfig* device_configuration);
std::vector<std::string> GetMatchingProfilesFromSetting(const std::string& setting, const std::vector<std::string>& profiles, InputConfig* device_configuration); std::string GetProfile(CycleDirection cycle_direction, int& profile_index,
void UpdateToProfile(const std::string& profile_filename, ControllerEmu::EmulatedController* controller); const std::vector<std::string>& profiles);
std::vector<std::string> GetMatchingProfilesFromSetting(const std::string& setting,
const std::vector<std::string>& profiles,
InputConfig* device_configuration);
void UpdateToProfile(const std::string& profile_filename,
ControllerEmu::EmulatedController* controller);
std::string GetWiimoteInputProfilesForGame(int controller_index); std::string GetWiimoteInputProfilesForGame(int controller_index);
int m_wiimote_profile_index = 0; int m_wiimote_profile_index = 0;