Fix lint bugs
This commit is contained in:
parent
b5db180ac4
commit
3b11066e61
|
@ -6,34 +6,48 @@
|
|||
|
||||
namespace Config
|
||||
{
|
||||
// Configuration Information
|
||||
// Configuration Information
|
||||
|
||||
// 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_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_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_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_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_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_SOFT{{System::WiiPad, "Shake", "Soft"}, 2.0};
|
||||
|
||||
// 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_SLOW{ { System::WiiPad, "Dynamic_Swing", "FramesHeldSlow" }, 30 };
|
||||
const ConfigInfo<int> WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_LENGTH{ { System::WiiPad, "Dynamic_Swing", "FrameCount" }, 30 };
|
||||
// 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_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_SOFT{ { System::WiiPad, "Dynamic_Shake", "FramesHeldSoft" }, 15 };
|
||||
const ConfigInfo<int> WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_LENGTH{ { System::WiiPad, "Dynamic_Shake", "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_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_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_SWING_INTENSITY_FAST{
|
||||
{System::WiiPad, "Nunchuk_Swing", "Fast"}, 4.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_MEDIUM{ { System::WiiPad, "Nunchuk_Shake", "Medium" }, 3.0 };
|
||||
const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT{ { System::WiiPad, "Nunchuk_Shake", "Soft" }, 2.0 };
|
||||
const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_HARD{
|
||||
{System::WiiPad, "Nunchuk_Shake", "Hard"}, 5.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};
|
||||
}
|
||||
|
|
|
@ -8,36 +8,42 @@
|
|||
|
||||
namespace Config
|
||||
{
|
||||
// Configuration Information
|
||||
// Configuration Information
|
||||
|
||||
// WiimoteInput.Settings
|
||||
// WiimoteInput.Settings
|
||||
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_FAST;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_SLOW;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_FAST;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SWING_INTENSITY_SLOW;
|
||||
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_HARD;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_HARD;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT;
|
||||
|
||||
// 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> 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_SWING_DYNAMIC_FRAMES_HELD_FAST; // How long button held constitutes a fast 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> 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
|
||||
extern const ConfigInfo<int>
|
||||
WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_HARD; // How long button held constitutes a hard 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
|
||||
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_FAST;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_SLOW;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_FAST;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SWING_INTENSITY_SLOW;
|
||||
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_HARD;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_HARD;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT;
|
||||
|
||||
} // namespace Config
|
||||
|
|
|
@ -109,9 +109,12 @@ void Nunchuk::GetState(u8* const data)
|
|||
EmulateSwing(&accel, m_swing_fast, Config::Get(Config::NUNCHUK_INPUT_SWING_INTENSITY_FAST));
|
||||
|
||||
// shake
|
||||
EmulateShake(&accel, m_shake, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM), m_shake_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());
|
||||
EmulateShake(&accel, m_shake, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM),
|
||||
m_shake_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
|
||||
m_buttons->GetState(&nc_data.bt.hex, nunchuk_button_bitmasks.data());
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
// frame count of one up/down shake
|
||||
|
@ -131,7 +132,7 @@ void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data, Cont
|
|||
auto const shake_step_max = 15;
|
||||
|
||||
// shake is a bitfield of X,Y,Z shake button states
|
||||
static const unsigned int btns[] = { 0x01, 0x02, 0x04 };
|
||||
static const unsigned int btns[] = {0x01, 0x02, 0x04};
|
||||
unsigned int shake = 0;
|
||||
buttons_group->GetState(&shake, btns);
|
||||
|
||||
|
@ -232,12 +233,14 @@ void EmulateSwing(AccelData* const accel, ControllerEmu::Force* const swing_grou
|
|||
}
|
||||
|
||||
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];
|
||||
swing_group->GetState(swing);
|
||||
|
||||
s8 g_dir[3] = { -1, -1, -1 };
|
||||
s8 g_dir[3] = {-1, -1, -1};
|
||||
u8 axis_map[3];
|
||||
|
||||
// determine which axis is which direction
|
||||
|
@ -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"));
|
||||
|
||||
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(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Y"));
|
||||
m_shake_dynamic->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z"));
|
||||
m_shake_dynamic->controls.emplace_back(
|
||||
new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "X"));
|
||||
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
|
||||
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.med_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM);
|
||||
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_low_intensity = Config::Get(Config::WIIMOTE_INPUT_SWING_DYNAMIC_FRAMES_HELD_SLOW);
|
||||
swing_config.frames_needed_for_high_intensity =
|
||||
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);
|
||||
|
||||
EmulateSwing(&m_accel, m_swing, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM), 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);
|
||||
EmulateSwing(&m_accel, m_swing, Config::Get(Config::WIIMOTE_INPUT_SWING_INTENSITY_MEDIUM),
|
||||
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,
|
||||
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.med_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM);
|
||||
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_low_intensity = Config::Get(Config::WIIMOTE_INPUT_SHAKE_DYNAMIC_FRAMES_HELD_SOFT);
|
||||
shake_config.frames_needed_for_high_intensity =
|
||||
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);
|
||||
|
||||
EmulateShake(&m_accel, m_shake, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM), m_shake_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());
|
||||
EmulateShake(&m_accel, m_shake, Config::Get(Config::WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM),
|
||||
m_shake_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,
|
||||
m_shake_dynamic_step.data());
|
||||
|
||||
|
||||
wm_accel& accel = *reinterpret_cast<wm_accel*>(data + rptf.accel);
|
||||
wm_buttons& core = *reinterpret_cast<wm_buttons*>(data + rptf.core);
|
||||
|
||||
|
|
|
@ -186,8 +186,7 @@ void EmulateShake(AccelData* const accel_data, ControllerEmu::Buttons* const but
|
|||
|
||||
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);
|
||||
|
||||
void EmulateTilt(AccelData* const accel, ControllerEmu::Tilt* const tilt_group,
|
||||
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,
|
||||
ControllerEmu::Force* const swing_group,
|
||||
const DynamicConfiguration& config,
|
||||
const bool sideways = false, const bool upright = false);
|
||||
const DynamicConfiguration& config, const bool sideways = false,
|
||||
const bool upright = false);
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -18,7 +18,8 @@ void HotkeyControllerProfile::CreateMainLayout()
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -87,8 +87,8 @@ bool InputConfig::LoadConfig(bool isGC)
|
|||
{
|
||||
std::string base;
|
||||
SplitPath(profile[n], nullptr, &base, nullptr);
|
||||
Core::DisplayMessage("Loading game specific input profile '" + base +
|
||||
"' for device '" + controller->GetName() + "'",
|
||||
Core::DisplayMessage("Loading game specific input profile '" + base + "' for device '" +
|
||||
controller->GetName() + "'",
|
||||
6000);
|
||||
|
||||
IniFile profile_ini;
|
||||
|
|
|
@ -20,63 +20,74 @@
|
|||
|
||||
namespace InputProfile
|
||||
{
|
||||
namespace
|
||||
{
|
||||
constexpr int display_message_ms = 3000;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr int display_message_ms = 3000;
|
||||
}
|
||||
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());
|
||||
return Common::DoFileSearch({device_profile_root_location}, {".ini"});
|
||||
}
|
||||
|
||||
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());
|
||||
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
|
||||
auto positive_modulo = [](int& i, int n) {i = (i % n + n) % n;};
|
||||
auto positive_modulo = [](int& i, int n) { i = (i % n + n) % n; };
|
||||
profile_index += static_cast<int>(cycle_direction);
|
||||
positive_modulo(profile_index, static_cast<int>(profiles.size()));
|
||||
|
||||
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;
|
||||
SplitPath(profile_filename, nullptr, &base, nullptr);
|
||||
|
||||
IniFile ini_file;
|
||||
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->UpdateReferences(g_controller_interface);
|
||||
}
|
||||
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 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::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 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);
|
||||
if (profiles_from_setting.empty())
|
||||
{
|
||||
|
@ -87,12 +98,11 @@ namespace InputProfile
|
|||
std::set_intersection(profiles.begin(), profiles.end(), profiles_from_setting.begin(),
|
||||
profiles_from_setting.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileCycler::CycleProfile(CycleDirection cycle_direction,
|
||||
InputConfig* device_configuration, int& profile_index,
|
||||
int controller_index)
|
||||
{
|
||||
void ProfileCycler::CycleProfile(CycleDirection cycle_direction, InputConfig* device_configuration,
|
||||
int& profile_index, int controller_index)
|
||||
{
|
||||
const auto& profiles = GetProfilesForDevice(device_configuration);
|
||||
if (profiles.empty())
|
||||
{
|
||||
|
@ -108,14 +118,15 @@ namespace InputProfile
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileCycler::CycleProfileForGame(CycleDirection cycle_direction,
|
||||
void ProfileCycler::CycleProfileForGame(CycleDirection cycle_direction,
|
||||
InputConfig* device_configuration, int& profile_index,
|
||||
const std::string& setting, int controller_index)
|
||||
{
|
||||
{
|
||||
const auto& profiles = GetProfilesForDevice(device_configuration);
|
||||
if (profiles.empty())
|
||||
{
|
||||
|
@ -129,8 +140,8 @@ namespace InputProfile
|
|||
return;
|
||||
}
|
||||
|
||||
const auto& profiles_for_game = GetMatchingProfilesFromSetting(setting, profiles,
|
||||
device_configuration);
|
||||
const auto& profiles_for_game =
|
||||
GetMatchingProfilesFromSetting(setting, profiles, device_configuration);
|
||||
if (profiles_for_game.empty())
|
||||
{
|
||||
Core::DisplayMessage("No input profiles found for game", display_message_ms);
|
||||
|
@ -146,41 +157,42 @@ namespace InputProfile
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
std::string ProfileCycler::GetWiimoteInputProfilesForGame(int controller_index)
|
||||
{
|
||||
std::string ProfileCycler::GetWiimoteInputProfilesForGame(int controller_index)
|
||||
{
|
||||
IniFile game_ini = SConfig::GetInstance().LoadGameIni();
|
||||
const IniFile::Section* const control_section = game_ini.GetOrCreateSection("Controls");
|
||||
|
||||
std::string result;
|
||||
control_section->Get(StringFromFormat("WiimoteProfile%d", controller_index+1), &result);
|
||||
control_section->Get(StringFromFormat("WiimoteProfile%d", controller_index + 1), &result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileCycler::NextWiimoteProfile(int controller_index)
|
||||
{
|
||||
void ProfileCycler::NextWiimoteProfile(int controller_index)
|
||||
{
|
||||
CycleProfile(CycleDirection::Forward, Wiimote::GetConfig(), m_wiimote_profile_index,
|
||||
controller_index);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileCycler::PreviousWiimoteProfile(int controller_index)
|
||||
{
|
||||
void ProfileCycler::PreviousWiimoteProfile(int controller_index)
|
||||
{
|
||||
CycleProfile(CycleDirection::Backward, Wiimote::GetConfig(), m_wiimote_profile_index,
|
||||
controller_index);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileCycler::NextWiimoteProfileForGame(int controller_index)
|
||||
{
|
||||
void ProfileCycler::NextWiimoteProfileForGame(int controller_index)
|
||||
{
|
||||
CycleProfileForGame(CycleDirection::Forward, Wiimote::GetConfig(), m_wiimote_profile_index,
|
||||
GetWiimoteInputProfilesForGame(controller_index), controller_index);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileCycler::PreviousWiimoteProfileForGame(int controller_index)
|
||||
{
|
||||
void ProfileCycler::PreviousWiimoteProfileForGame(int controller_index)
|
||||
{
|
||||
CycleProfileForGame(CycleDirection::Backward, Wiimote::GetConfig(), m_wiimote_profile_index,
|
||||
GetWiimoteInputProfilesForGame(controller_index), controller_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ class InputConfig;
|
|||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class EmulatedController;
|
||||
class EmulatedController;
|
||||
}
|
||||
|
||||
#include <string>
|
||||
|
@ -16,29 +16,37 @@ namespace ControllerEmu
|
|||
|
||||
namespace InputProfile
|
||||
{
|
||||
enum class CycleDirection : int
|
||||
{
|
||||
enum class CycleDirection : int
|
||||
{
|
||||
Forward = 1,
|
||||
Backward = -1
|
||||
};
|
||||
};
|
||||
|
||||
class ProfileCycler
|
||||
{
|
||||
public:
|
||||
class ProfileCycler
|
||||
{
|
||||
public:
|
||||
void NextWiimoteProfile(int controller_index);
|
||||
void PreviousWiimoteProfile(int controller_index);
|
||||
void NextWiimoteProfileForGame(int controller_index);
|
||||
void PreviousWiimoteProfileForGame(int controller_index);
|
||||
private:
|
||||
void CycleProfile(CycleDirection cycle_direction, InputConfig* device_configuration, int& profile_index, int controller_index);
|
||||
void CycleProfileForGame(CycleDirection cycle_direction, InputConfig* device_configuration, int& profile_index, const std::string& setting, int controller_index);
|
||||
|
||||
private:
|
||||
void CycleProfile(CycleDirection cycle_direction, InputConfig* device_configuration,
|
||||
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> GetProfilesFromSetting(const std::string& setting, InputConfig* device_configuration);
|
||||
std::string GetProfile(CycleDirection cycle_direction, int& profile_index, 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::vector<std::string> GetProfilesFromSetting(const std::string& setting,
|
||||
InputConfig* device_configuration);
|
||||
std::string GetProfile(CycleDirection cycle_direction, int& profile_index,
|
||||
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);
|
||||
|
||||
int m_wiimote_profile_index = 0;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue