mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Input: Add cycling between game specific profiles
This commit is contained in:
parent
3969bf6d1c
commit
485285eadc
@ -27,4 +27,7 @@ namespace Config
|
||||
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 };
|
||||
|
||||
// Other Settings
|
||||
const ConfigInfo<std::string> WIIMOTE_PROFILES{ {System::WiiPad, "InputProfiles", "List"}, "" };
|
||||
}
|
||||
|
@ -30,4 +30,8 @@ namespace Config
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM;
|
||||
extern const ConfigInfo<double> NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT;
|
||||
|
||||
// Other settings
|
||||
|
||||
extern const ConfigInfo<std::string> WIIMOTE_PROFILES;
|
||||
|
||||
} // namespace Config
|
||||
|
@ -69,8 +69,10 @@ constexpr std::array<const char*, 114> s_hotkey_labels{{
|
||||
_trans("Connect Wii Remote 4"),
|
||||
_trans("Connect Balance Board"),
|
||||
|
||||
_trans("Next Wii Remote Profile"),
|
||||
_trans("Previous Wii Remote Profile"),
|
||||
_trans("Next Wii Remote Profile"),
|
||||
_trans("Previous Wii Remote Profile"),
|
||||
_trans("Next Wii Remote Profile For Current Game"),
|
||||
_trans("Previous Wii Remote Profile For Current Game"),
|
||||
|
||||
_trans("Toggle Crop"),
|
||||
_trans("Toggle Aspect Ratio"),
|
||||
@ -258,7 +260,7 @@ constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
|
||||
{_trans("Program Counter"), HK_SHOW_PC, HK_SET_PC},
|
||||
{_trans("Breakpoint"), HK_BP_TOGGLE, HK_MBP_ADD},
|
||||
{_trans("Wii"), HK_TRIGGER_SYNC_BUTTON, HK_BALANCEBOARD_CONNECT},
|
||||
{_trans("Controller Profile"), HK_NEXT_WIIMOTE_PROFILE, HK_PREV_WIIMOTE_PROFILE},
|
||||
{_trans("Controller Profile"), HK_NEXT_WIIMOTE_PROFILE, HK_PREV_GAME_WIIMOTE_PROFILE},
|
||||
{_trans("Graphics Toggles"), HK_TOGGLE_CROP, HK_TOGGLE_TEXTURES},
|
||||
{_trans("Internal Resolution"), HK_INCREASE_IR, HK_DECREASE_IR},
|
||||
{_trans("Freelook"), HK_FREELOOK_DECREASE_SPEED, HK_FREELOOK_RESET},
|
||||
|
@ -69,6 +69,8 @@ enum Hotkey
|
||||
|
||||
HK_NEXT_WIIMOTE_PROFILE,
|
||||
HK_PREV_WIIMOTE_PROFILE,
|
||||
HK_NEXT_GAME_WIIMOTE_PROFILE,
|
||||
HK_PREV_GAME_WIIMOTE_PROFILE,
|
||||
|
||||
HK_TOGGLE_CROP,
|
||||
HK_TOGGLE_AR,
|
||||
|
@ -245,6 +245,11 @@ void HotkeyScheduler::Run()
|
||||
else if (IsHotkey(HK_NEXT_WIIMOTE_PROFILE))
|
||||
m_profile_cycler.NextWiimoteProfile();
|
||||
|
||||
if (IsHotkey(HK_PREV_GAME_WIIMOTE_PROFILE))
|
||||
m_profile_cycler.PreviousWiimoteProfileForGame();
|
||||
else if (IsHotkey(HK_NEXT_GAME_WIIMOTE_PROFILE))
|
||||
m_profile_cycler.NextWiimoteProfileForGame();
|
||||
|
||||
const auto show_msg = [](OSDMessage message) {
|
||||
if (g_renderer)
|
||||
g_renderer->ShowOSDMessage(message);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "Common/FileSearch.h"
|
||||
#include "Common/FileUtil.h"
|
||||
|
||||
#include "Core/Config/WiimoteInputSettings.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/Wiimote.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
@ -13,6 +14,9 @@
|
||||
#include "InputCommon/InputConfig.h"
|
||||
#include "InputCommon/InputProfile.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
namespace InputProfile
|
||||
{
|
||||
|
||||
@ -73,6 +77,35 @@ namespace InputProfile
|
||||
return result;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
std::vector<std::string> result(profiles.size());
|
||||
std::transform(profiles.begin(), profiles.end(), result.begin(), [&device_profile_root_location](const std::string& profile)
|
||||
{
|
||||
return device_profile_root_location + "/" + profile;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<std::string> result;
|
||||
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)
|
||||
{
|
||||
@ -88,6 +121,44 @@ namespace InputProfile
|
||||
UpdateToProfile(profile, controllers);
|
||||
}
|
||||
|
||||
void ProfileCycler::CycleProfileForGame(CycleDirection cycle_direction,
|
||||
InputConfig* device_configuration, int& profile_index,
|
||||
const std::string& setting)
|
||||
{
|
||||
const auto& profiles = GetProfilesForDevice(device_configuration);
|
||||
if (profiles.empty())
|
||||
{
|
||||
Core::DisplayMessage("No input profiles found", display_message_ms);
|
||||
return;
|
||||
}
|
||||
|
||||
if (setting.empty())
|
||||
{
|
||||
Core::DisplayMessage("No setting found for game", display_message_ms);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string profile = GetProfile(cycle_direction, profile_index, profiles_for_game);
|
||||
|
||||
auto* controller = device_configuration->GetController(controller_index);
|
||||
if (controller)
|
||||
{
|
||||
UpdateToProfile(profile, controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
Core::DisplayMessage("No controller found for index: " + std::to_string(controller_index), display_message_ms);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileCycler::NextWiimoteProfile()
|
||||
{
|
||||
CycleProfile(CycleDirection::Forward, Wiimote::GetConfig(), m_wiimote_profile_index);
|
||||
@ -97,4 +168,16 @@ namespace InputProfile
|
||||
{
|
||||
CycleProfile(CycleDirection::Backward, Wiimote::GetConfig(), m_wiimote_profile_index);
|
||||
}
|
||||
|
||||
void ProfileCycler::NextWiimoteProfileForGame()
|
||||
{
|
||||
CycleProfileForGame(CycleDirection::Forward, Wiimote::GetConfig(), m_wiimote_profile_index,
|
||||
Config::Get(Config::WIIMOTE_PROFILES));
|
||||
}
|
||||
|
||||
void ProfileCycler::PreviousWiimoteProfileForGame()
|
||||
{
|
||||
CycleProfileForGame(CycleDirection::Backward, Wiimote::GetConfig(), m_wiimote_profile_index,
|
||||
Config::Get(Config::WIIMOTE_PROFILES));
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,15 @@ namespace InputProfile
|
||||
public:
|
||||
void NextWiimoteProfile();
|
||||
void PreviousWiimoteProfile();
|
||||
void NextWiimoteProfileForGame();
|
||||
void PreviousWiimoteProfileForGame();
|
||||
private:
|
||||
void CycleProfile(CycleDirection cycle_direction, InputConfig* device_configuration, int& profile_index);
|
||||
void CycleProfileForGame(CycleDirection cycle_direction, InputConfig* device_configuration, int& profile_index, const std::string& setting);
|
||||
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, const std::vector<ControllerEmu::EmulatedController*>& controllers);
|
||||
std::vector<ControllerEmu::EmulatedController*> GetControllersForDevice(InputConfig* device_configuration);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user