diff options
58 files changed, 343 insertions, 136 deletions
diff --git a/.ci/yuzu-mainline-step2.yml b/.ci/yuzu-mainline-step2.yml index 8bb0572f5..825be121a 100644 --- a/.ci/yuzu-mainline-step2.yml +++ b/.ci/yuzu-mainline-step2.yml @@ -33,7 +33,6 @@ stages: cache: 'true' version: $(DisplayVersion) - stage: build_win - dependsOn: format displayName: 'build-windows' jobs: - job: build diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index 93c8ce922..9b08f008d 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt @@ -49,7 +49,6 @@ import org.yuzu.yuzu_emu.utils.ForegroundService import org.yuzu.yuzu_emu.utils.InputHandler import org.yuzu.yuzu_emu.utils.Log import org.yuzu.yuzu_emu.utils.MemoryUtil -import org.yuzu.yuzu_emu.utils.NativeConfig import org.yuzu.yuzu_emu.utils.NfcReader import org.yuzu.yuzu_emu.utils.ThemeHelper import java.text.NumberFormat @@ -171,11 +170,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { stopMotionSensorListener() } - override fun onStop() { - super.onStop() - NativeConfig.saveGlobalConfig() - } - override fun onUserLeaveHint() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { if (BooleanSetting.PICTURE_IN_PICTURE.getBoolean() && !isInPictureInPictureMode) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 9efc1705d..47767454a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt @@ -554,6 +554,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { findItem(R.id.menu_touchscreen).isChecked = BooleanSetting.TOUCHSCREEN.getBoolean() } + popup.setOnDismissListener { NativeConfig.saveGlobalConfig() } popup.setOnMenuItemClickListener { when (it.itemId) { R.id.menu_toggle_fps -> { @@ -720,7 +721,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { MaterialAlertDialogBuilder(requireContext()) .setTitle(R.string.emulation_control_adjust) .setView(adjustBinding.root) - .setPositiveButton(android.R.string.ok, null) + .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> + NativeConfig.saveGlobalConfig() + } .setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int -> setControlScale(50) setControlOpacity(100) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt index 132f002fb..b54a19c65 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt @@ -104,7 +104,7 @@ object FileUtil { /** * Reference: https://stackoverflow.com/questions/42186820/documentfile-is-very-slow - * This function will be faster than DoucmentFile.listFiles + * This function will be faster than DocumentFile.listFiles * @param uri Directory uri. * @return CheapDocument lists. */ diff --git a/src/android/app/src/main/jni/android_config.cpp b/src/android/app/src/main/jni/android_config.cpp index 08aed3216..e147560c3 100644 --- a/src/android/app/src/main/jni/android_config.cpp +++ b/src/android/app/src/main/jni/android_config.cpp @@ -21,7 +21,7 @@ void AndroidConfig::ReloadAllValues() { } void AndroidConfig::SaveAllValues() { - Save(); + SaveValues(); SaveAndroidValues(); } diff --git a/src/android/app/src/main/jni/native_config.cpp b/src/android/app/src/main/jni/native_config.cpp index 535902483..c6c3343dc 100644 --- a/src/android/app/src/main/jni/native_config.cpp +++ b/src/android/app/src/main/jni/native_config.cpp @@ -205,7 +205,7 @@ jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getIsRuntimeModifiable(JNIEn jstring jkey) { auto setting = getSetting<std::string>(env, jkey); if (setting != nullptr) { - return setting->RuntimeModfiable(); + return setting->RuntimeModifiable(); } return true; } diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index 78e855bde..4701913eb 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml @@ -29,7 +29,7 @@ <item>@string/language_dutch</item> <item>@string/language_english</item> <item>@string/language_french</item> - <item>@string/langauge_german</item> + <item>@string/language_german</item> <item>@string/language_italian</item> <item>@string/language_japanese</item> <item>@string/language_korean</item> diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 3bb92ad67..547752bda 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -410,7 +410,7 @@ <string name="language_japanese" translatable="false">日本語</string> <string name="language_english" translatable="false">English</string> <string name="language_french" translatable="false">Français</string> - <string name="langauge_german" translatable="false">Deutsch</string> + <string name="language_german" translatable="false">Deutsch</string> <string name="language_italian" translatable="false">Italiano</string> <string name="language_spanish" translatable="false">Español</string> <string name="language_chinese" translatable="false">简体中文</string> diff --git a/src/audio_core/adsp/adsp.cpp b/src/audio_core/adsp/adsp.cpp index 6c53c98fd..48f0a63d4 100644 --- a/src/audio_core/adsp/adsp.cpp +++ b/src/audio_core/adsp/adsp.cpp @@ -11,7 +11,7 @@ ADSP::ADSP(Core::System& system, Sink::Sink& sink) { opus_decoder = std::make_unique<OpusDecoder::OpusDecoder>(system); opus_decoder->Send(Direction::DSP, OpusDecoder::Message::Start); if (opus_decoder->Receive(Direction::Host) != OpusDecoder::Message::StartOK) { - LOG_ERROR(Service_Audio, "OpusDeocder failed to initialize."); + LOG_ERROR(Service_Audio, "OpusDecoder failed to initialize."); return; } } diff --git a/src/audio_core/renderer/command/command_generator.cpp b/src/audio_core/renderer/command/command_generator.cpp index ccb186209..f97db5899 100644 --- a/src/audio_core/renderer/command/command_generator.cpp +++ b/src/audio_core/renderer/command/command_generator.cpp @@ -41,7 +41,7 @@ void CommandGenerator::GenerateDataSourceCommand(VoiceInfo& voice_info, const VoiceState& voice_state, const s8 channel) { if (voice_info.mix_id == UnusedMixId) { if (voice_info.splitter_id != UnusedSplitterId) { - auto destination{splitter_context.GetDesintationData(voice_info.splitter_id, 0)}; + auto destination{splitter_context.GetDestinationData(voice_info.splitter_id, 0)}; u32 dest_id{0}; while (destination != nullptr) { if (destination->IsConfigured()) { @@ -55,7 +55,7 @@ void CommandGenerator::GenerateDataSourceCommand(VoiceInfo& voice_info, } } dest_id++; - destination = splitter_context.GetDesintationData(voice_info.splitter_id, dest_id); + destination = splitter_context.GetDestinationData(voice_info.splitter_id, dest_id); } } } else { @@ -234,7 +234,7 @@ void CommandGenerator::GenerateVoiceCommand(VoiceInfo& voice_info) { if (voice_info.mix_id == UnusedMixId) { if (voice_info.splitter_id != UnusedSplitterId) { auto i{channel}; - auto destination{splitter_context.GetDesintationData(voice_info.splitter_id, i)}; + auto destination{splitter_context.GetDestinationData(voice_info.splitter_id, i)}; while (destination != nullptr) { if (destination->IsConfigured()) { const auto mix_id{destination->GetMixId()}; @@ -249,7 +249,7 @@ void CommandGenerator::GenerateVoiceCommand(VoiceInfo& voice_info) { } } i += voice_info.channel_count; - destination = splitter_context.GetDesintationData(voice_info.splitter_id, i); + destination = splitter_context.GetDestinationData(voice_info.splitter_id, i); } } } else { @@ -591,7 +591,7 @@ void CommandGenerator::GenerateMixCommands(MixInfo& mix_info) { if (mix_info.dst_splitter_id != UnusedSplitterId) { s16 dest_id{0}; auto destination{ - splitter_context.GetDesintationData(mix_info.dst_splitter_id, dest_id)}; + splitter_context.GetDestinationData(mix_info.dst_splitter_id, dest_id)}; while (destination != nullptr) { if (destination->IsConfigured()) { auto splitter_mix_id{destination->GetMixId()}; @@ -612,7 +612,7 @@ void CommandGenerator::GenerateMixCommands(MixInfo& mix_info) { } dest_id++; destination = - splitter_context.GetDesintationData(mix_info.dst_splitter_id, dest_id); + splitter_context.GetDestinationData(mix_info.dst_splitter_id, dest_id); } } } else { diff --git a/src/audio_core/renderer/mix/mix_info.cpp b/src/audio_core/renderer/mix/mix_info.cpp index 5e44bde18..68bbe0aed 100644 --- a/src/audio_core/renderer/mix/mix_info.cpp +++ b/src/audio_core/renderer/mix/mix_info.cpp @@ -93,7 +93,7 @@ bool MixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const InParameter& in_pa for (u32 i = 0; i < destination_count; i++) { auto destination{ - splitter_context.GetDesintationData(in_params.dest_splitter_id, i)}; + splitter_context.GetDestinationData(in_params.dest_splitter_id, i)}; if (destination) { const auto destination_id{destination->GetMixId()}; diff --git a/src/audio_core/renderer/splitter/splitter_context.cpp b/src/audio_core/renderer/splitter/splitter_context.cpp index 686150ea6..d0f3b60c2 100644 --- a/src/audio_core/renderer/splitter/splitter_context.cpp +++ b/src/audio_core/renderer/splitter/splitter_context.cpp @@ -9,7 +9,7 @@ namespace AudioCore::Renderer { -SplitterDestinationData* SplitterContext::GetDesintationData(const s32 splitter_id, +SplitterDestinationData* SplitterContext::GetDestinationData(const s32 splitter_id, const s32 destination_id) { return splitter_infos[splitter_id].GetData(destination_id); } diff --git a/src/audio_core/renderer/splitter/splitter_context.h b/src/audio_core/renderer/splitter/splitter_context.h index 556e6dcc3..1c0b84671 100644 --- a/src/audio_core/renderer/splitter/splitter_context.h +++ b/src/audio_core/renderer/splitter/splitter_context.h @@ -42,7 +42,7 @@ public: * @param destination_id - Destination index within the splitter. * @return Pointer to the found destination. May be nullptr. */ - SplitterDestinationData* GetDesintationData(s32 splitter_id, s32 destination_id); + SplitterDestinationData* GetDestinationData(s32 splitter_id, s32 destination_id); /** * Get a splitter from the given index. diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 5960b78aa..b90e3509c 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -35,7 +35,7 @@ bool BasicSetting::Save() const { return save; } -bool BasicSetting::RuntimeModfiable() const { +bool BasicSetting::RuntimeModifiable() const { return runtime_modifiable; } diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 1a290ad77..987489e8a 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -186,7 +186,7 @@ public: /** * @returns true if the current setting can be changed while the guest is running. */ - [[nodiscard]] bool RuntimeModfiable() const; + [[nodiscard]] bool RuntimeModifiable() const; /** * @returns A unique number corresponding to the setting. diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp index 9eb4799a6..46277e288 100644 --- a/src/frontend_common/config.cpp +++ b/src/frontend_common/config.cpp @@ -5,6 +5,7 @@ #include <array> #include "common/fs/fs.h" #include "common/fs/path_util.h" +#include "common/logging/log.h" #include "common/settings.h" #include "common/settings_common.h" #include "common/settings_enums.h" @@ -58,6 +59,19 @@ void Config::Initialize(const std::optional<std::string> config_path) { } void Config::WriteToIni() const { + std::string config_type; + switch (type) { + case ConfigType::GlobalConfig: + config_type = "Global"; + break; + case ConfigType::PerGameConfig: + config_type = "Game Specific"; + break; + case ConfigType::InputProfile: + config_type = "Input Profile"; + break; + } + LOG_INFO(Config, "Writing {} configuration to: {}", config_type, config_loc); FILE* fp = nullptr; #ifdef _WIN32 fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb"); @@ -117,10 +131,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) { player_prefix.append("player_").append(ToString(player_index)).append("_"); } + const auto profile_name = ReadStringSetting(std::string(player_prefix).append("profile_name")); + auto& player = Settings::values.players.GetValue()[player_index]; if (IsCustomConfig()) { - const auto profile_name = - ReadStringSetting(std::string(player_prefix).append("profile_name")); if (profile_name.empty()) { // Use the global input config player = Settings::values.players.GetValue(true)[player_index]; @@ -139,6 +153,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) { player.controller_type = controller; } } else { + if (global) { + auto& player_global = Settings::values.players.GetValue(true)[player_index]; + player_global.profile_name = profile_name; + } std::string connected_key = player_prefix; player.connected = ReadBooleanSetting(connected_key.append("connected"), std::make_optional(player_index == 0)); @@ -412,6 +430,11 @@ void Config::SavePlayerValues(const std::size_t player_index) { std::make_optional(static_cast<u8>(Settings::ControllerType::ProController))); if (!player_prefix.empty() || !Settings::IsConfiguringGlobal()) { + if (global) { + const auto& player_global = Settings::values.players.GetValue(true)[player_index]; + WriteStringSetting(std::string(player_prefix).append("profile_name"), + player_global.profile_name, std::make_optional(std::string(""))); + } WriteBooleanSetting(std::string(player_prefix).append("connected"), player.connected, std::make_optional(player_index == 0)); WriteIntegerSetting(std::string(player_prefix).append("vibration_enabled"), @@ -468,12 +491,15 @@ void Config::SaveMotionTouchValues() { void Config::SaveValues() { if (global) { + LOG_DEBUG(Config, "Saving global generic configuration values"); SaveDataStorageValues(); SaveDebuggingValues(); SaveDisabledAddOnValues(); SaveNetworkValues(); SaveWebServiceValues(); SaveMiscellaneousValues(); + } else { + LOG_DEBUG(Config, "Saving only generic configuration values"); } SaveControlValues(); SaveCoreValues(); @@ -814,10 +840,6 @@ void Config::Reload() { SaveValues(); } -void Config::Save() { - SaveValues(); -} - void Config::ClearControlPlayerValues() const { // If key is an empty string, all keys in the current group() are removed. const char* section = Settings::TranslateCategory(Settings::Category::Controls); diff --git a/src/frontend_common/config.h b/src/frontend_common/config.h index b01631649..4798d6432 100644 --- a/src/frontend_common/config.h +++ b/src/frontend_common/config.h @@ -51,7 +51,6 @@ protected: [[nodiscard]] bool IsCustomConfig() const; void Reload(); - void Save(); /** * Derived config classes must implement this so they can reload all platform-specific diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp index a6a96935d..2ab93402d 100644 --- a/src/hid_core/frontend/emulated_controller.cpp +++ b/src/hid_core/frontend/emulated_controller.cpp @@ -509,11 +509,11 @@ void EmulatedController::ReloadInput() { }); } turbo_button_state = 0; - is_initalized = true; + is_initialized = true; } void EmulatedController::UnloadInput() { - is_initalized = false; + is_initialized = false; for (auto& button : button_devices) { button.reset(); } @@ -1209,7 +1209,7 @@ void EmulatedController::SetNfc(const Common::Input::CallbackStatus& callback) { } bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue vibration) { - if (!is_initalized) { + if (!is_initialized) { return false; } if (device_index >= output_devices.size()) { @@ -1247,7 +1247,7 @@ bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); const auto& player = Settings::values.players.GetValue()[player_index]; - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1270,7 +1270,7 @@ Common::Input::DriverResult EmulatedController::SetPollingMode( EmulatedDeviceIndex device_index, Common::Input::PollingMode polling_mode) { LOG_INFO(Service_HID, "Set polling mode {}, device_index={}", polling_mode, device_index); - if (!is_initalized) { + if (!is_initialized) { return Common::Input::DriverResult::InvalidHandle; } @@ -1319,7 +1319,7 @@ bool EmulatedController::SetCameraFormat( Core::IrSensor::ImageTransferProcessorFormat camera_format) { LOG_INFO(Service_HID, "Set camera format {}", camera_format); - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1347,7 +1347,7 @@ void EmulatedController::SetRingParam(Common::ParamPackage param) { bool EmulatedController::HasNfc() const { - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1388,7 +1388,7 @@ bool EmulatedController::RemoveNfcHandle() { } bool EmulatedController::StartNfcPolling() { - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1403,7 +1403,7 @@ bool EmulatedController::StartNfcPolling() { } bool EmulatedController::StopNfcPolling() { - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1418,7 +1418,7 @@ bool EmulatedController::StopNfcPolling() { } bool EmulatedController::ReadAmiiboData(std::vector<u8>& data) { - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1434,7 +1434,7 @@ bool EmulatedController::ReadAmiiboData(std::vector<u8>& data) { bool EmulatedController::ReadMifareData(const Common::Input::MifareRequest& request, Common::Input::MifareRequest& out_data) { - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1450,7 +1450,7 @@ bool EmulatedController::ReadMifareData(const Common::Input::MifareRequest& requ } bool EmulatedController::WriteMifareData(const Common::Input::MifareRequest& request) { - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1465,7 +1465,7 @@ bool EmulatedController::WriteMifareData(const Common::Input::MifareRequest& req } bool EmulatedController::WriteNfc(const std::vector<u8>& data) { - if (!is_initalized) { + if (!is_initialized) { return false; } @@ -1480,7 +1480,7 @@ bool EmulatedController::WriteNfc(const std::vector<u8>& data) { } void EmulatedController::SetLedPattern() { - if (!is_initalized) { + if (!is_initialized) { return; } @@ -1508,8 +1508,8 @@ void EmulatedController::SetGyroscopeZeroDriftMode(GyroscopeZeroDriftMode mode) motion.emulated.SetGyroThreshold(motion.emulated.ThresholdLoose); break; case GyroscopeZeroDriftMode::Tight: - motion_sensitivity = motion.emulated.IsAtRestThight; - motion.emulated.SetGyroThreshold(motion.emulated.ThresholdThight); + motion_sensitivity = motion.emulated.IsAtRestTight; + motion.emulated.SetGyroThreshold(motion.emulated.ThresholdTight); break; case GyroscopeZeroDriftMode::Standard: default: diff --git a/src/hid_core/frontend/emulated_controller.h b/src/hid_core/frontend/emulated_controller.h index 94798164d..90e536e07 100644 --- a/src/hid_core/frontend/emulated_controller.h +++ b/src/hid_core/frontend/emulated_controller.h @@ -559,7 +559,7 @@ private: NpadStyleTag supported_style_tag{NpadStyleSet::All}; bool is_connected{false}; bool is_configuring{false}; - bool is_initalized{false}; + bool is_initialized{false}; bool system_buttons_enabled{true}; f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard}; u32 turbo_button_state{0}; diff --git a/src/hid_core/frontend/motion_input.h b/src/hid_core/frontend/motion_input.h index 11678983d..c902a3a6e 100644 --- a/src/hid_core/frontend/motion_input.h +++ b/src/hid_core/frontend/motion_input.h @@ -13,12 +13,12 @@ class MotionInput { public: static constexpr float ThresholdLoose = 0.01f; static constexpr float ThresholdStandard = 0.007f; - static constexpr float ThresholdThight = 0.002f; + static constexpr float ThresholdTight = 0.002f; static constexpr float IsAtRestRelaxed = 0.05f; static constexpr float IsAtRestLoose = 0.02f; static constexpr float IsAtRestStandard = 0.01f; - static constexpr float IsAtRestThight = 0.005f; + static constexpr float IsAtRestTight = 0.005f; static constexpr float GyroMaxValue = 5.0f; static constexpr float AccelMaxValue = 7.0f; diff --git a/src/hid_core/hid_result.h b/src/hid_core/hid_result.h index bb14aa61e..df9b28c9a 100644 --- a/src/hid_core/hid_result.h +++ b/src/hid_core/hid_result.h @@ -15,7 +15,7 @@ constexpr Result ResultVibrationNotInitialized{ErrorModule::HID, 121}; constexpr Result ResultVibrationInvalidStyleIndex{ErrorModule::HID, 122}; constexpr Result ResultVibrationInvalidNpadId{ErrorModule::HID, 123}; constexpr Result ResultVibrationDeviceIndexOutOfRange{ErrorModule::HID, 124}; -constexpr Result ResultVibrationStrenghtOutOfRange{ErrorModule::HID, 126}; +constexpr Result ResultVibrationStrengthOutOfRange{ErrorModule::HID, 126}; constexpr Result ResultVibrationArraySizeMismatch{ErrorModule::HID, 131}; constexpr Result InvalidSixAxisFusionRange{ErrorModule::HID, 423}; diff --git a/src/hid_core/irsensor/irs_types.h b/src/hid_core/irsensor/irs_types.h index 017f38e6c..d7354de21 100644 --- a/src/hid_core/irsensor/irs_types.h +++ b/src/hid_core/irsensor/irs_types.h @@ -106,8 +106,8 @@ enum class HandAnalysisMode : u32 { None, Silhouette, Image, - SilhoueteAndImage, - SilhuetteOnly, + SilhouetteAndImage, + SilhouetteOnly, }; // This is nn::irsensor::IrSensorFunctionLevel diff --git a/src/hid_core/resources/hid_firmware_settings.cpp b/src/hid_core/resources/hid_firmware_settings.cpp index e76b3a016..9fa0db17e 100644 --- a/src/hid_core/resources/hid_firmware_settings.cpp +++ b/src/hid_core/resources/hid_firmware_settings.cpp @@ -14,7 +14,7 @@ void HidFirmwareSettings::Reload() { } void HidFirmwareSettings::LoadSettings(bool reload_config) { - if (is_initalized && !reload_config) { + if (is_initialized && !reload_config) { return; } @@ -33,7 +33,7 @@ void HidFirmwareSettings::LoadSettings(bool reload_config) { is_handheld_forced = true; features_per_id_disabled = {}; is_touch_firmware_auto_update_disabled = false; - is_initalized = true; + is_initialized = true; } bool HidFirmwareSettings::IsDebugPadEnabled() { diff --git a/src/hid_core/resources/hid_firmware_settings.h b/src/hid_core/resources/hid_firmware_settings.h index 6c10c440b..00201fd94 100644 --- a/src/hid_core/resources/hid_firmware_settings.h +++ b/src/hid_core/resources/hid_firmware_settings.h @@ -33,7 +33,7 @@ public: FeaturesPerId FeaturesDisabledPerId(); private: - bool is_initalized{}; + bool is_initialized{}; // Debug settings bool is_debug_pad_enabled{}; diff --git a/src/hid_core/resources/npad/npad_types.h b/src/hid_core/resources/npad/npad_types.h index 074dd40cf..fd86c8e40 100644 --- a/src/hid_core/resources/npad/npad_types.h +++ b/src/hid_core/resources/npad/npad_types.h @@ -318,7 +318,7 @@ struct InternalFlags { BitField<1, 1, u32> is_connected; BitField<2, 1, u32> is_battery_low_ovln_required; BitField<3, 1, u32> is_battery_low_ovln_delay_required; - BitField<4, 1, u32> is_sample_recieved; + BitField<4, 1, u32> is_sample_received; BitField<5, 1, u32> is_virtual_input; BitField<6, 1, u32> is_wired; BitField<8, 1, u32> use_center_clamp; diff --git a/src/hid_core/resources/npad/npad_vibration.cpp b/src/hid_core/resources/npad/npad_vibration.cpp index 3bdd55dec..7056e8eab 100644 --- a/src/hid_core/resources/npad/npad_vibration.cpp +++ b/src/hid_core/resources/npad/npad_vibration.cpp @@ -15,7 +15,7 @@ Result NpadVibration::Activate() { const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrenghtOutOfRange; + // return ResultVibrationStrengthOutOfRange; // } volume = master_volume; @@ -30,7 +30,7 @@ Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { std::scoped_lock lock{mutex}; if (master_volume < 0.0f && master_volume > 1.0f) { - return ResultVibrationStrenghtOutOfRange; + return ResultVibrationStrengthOutOfRange; } volume = master_volume; @@ -50,7 +50,7 @@ Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const { const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrenghtOutOfRange; + // return ResultVibrationStrengthOutOfRange; // } out_volume = master_volume; @@ -69,7 +69,7 @@ Result NpadVibration::EndPermitVibrationSession() { const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrenghtOutOfRange; + // return ResultVibrationStrengthOutOfRange; // } volume = master_volume; diff --git a/src/hid_core/resources/six_axis/six_axis.cpp b/src/hid_core/resources/six_axis/six_axis.cpp index da12d2d5a..abb6fd152 100644 --- a/src/hid_core/resources/six_axis/six_axis.cpp +++ b/src/hid_core/resources/six_axis/six_axis.cpp @@ -249,7 +249,7 @@ Result SixAxis::EnableSixAxisSensorUnalteredPassthrough( } auto& sixaxis = GetSixaxisState(sixaxis_handle); - sixaxis.unaltered_passtrough = is_enabled; + sixaxis.unaltered_passthrough = is_enabled; return ResultSuccess; } @@ -262,7 +262,7 @@ Result SixAxis::IsSixAxisSensorUnalteredPassthroughEnabled( } const auto& sixaxis = GetSixaxisState(sixaxis_handle); - is_enabled = sixaxis.unaltered_passtrough; + is_enabled = sixaxis.unaltered_passthrough; return ResultSuccess; } diff --git a/src/hid_core/resources/six_axis/six_axis.h b/src/hid_core/resources/six_axis/six_axis.h index 1054e1b27..b4b00a441 100644 --- a/src/hid_core/resources/six_axis/six_axis.h +++ b/src/hid_core/resources/six_axis/six_axis.h @@ -62,7 +62,7 @@ private: struct SixaxisParameters { bool is_fusion_enabled{true}; - bool unaltered_passtrough{false}; + bool unaltered_passthrough{false}; Core::HID::SixAxisSensorFusionParameters fusion{}; Core::HID::SixAxisSensorCalibrationParameter calibration{}; Core::HID::SixAxisSensorIcInformation ic_information{}; diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index d2fbea488..d0a71a15b 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -2,6 +2,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later add_library(input_common STATIC + drivers/android.cpp + drivers/android.h drivers/camera.cpp drivers/camera.h drivers/keyboard.cpp diff --git a/src/input_common/drivers/android.cpp b/src/input_common/drivers/android.cpp new file mode 100644 index 000000000..b6a03fdc0 --- /dev/null +++ b/src/input_common/drivers/android.cpp @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "input_common/drivers/android.h" + +namespace InputCommon { + +Android::Android(std::string input_engine_) : InputEngine(std::move(input_engine_)) {} + +void Android::RegisterController(std::size_t controller_number) { + PreSetController(GetIdentifier(controller_number)); +} + +void Android::SetButtonState(std::size_t controller_number, int button_id, bool value) { + const auto identifier = GetIdentifier(controller_number); + SetButton(identifier, button_id, value); +} + +void Android::SetAxisState(std::size_t controller_number, int axis_id, float value) { + const auto identifier = GetIdentifier(controller_number); + SetAxis(identifier, axis_id, value); +} + +void Android::SetMotionState(std::size_t controller_number, u64 delta_timestamp, float gyro_x, + float gyro_y, float gyro_z, float accel_x, float accel_y, + float accel_z) { + const auto identifier = GetIdentifier(controller_number); + const BasicMotion motion_data{ + .gyro_x = gyro_x, + .gyro_y = gyro_y, + .gyro_z = gyro_z, + .accel_x = accel_x, + .accel_y = accel_y, + .accel_z = accel_z, + .delta_timestamp = delta_timestamp, + }; + SetMotion(identifier, 0, motion_data); +} + +PadIdentifier Android::GetIdentifier(std::size_t controller_number) const { + return { + .guid = Common::UUID{}, + .port = controller_number, + .pad = 0, + }; +} + +} // namespace InputCommon diff --git a/src/input_common/drivers/android.h b/src/input_common/drivers/android.h new file mode 100644 index 000000000..3f01817f6 --- /dev/null +++ b/src/input_common/drivers/android.h @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "input_common/input_engine.h" + +namespace InputCommon { + +/** + * A virtual controller that is always assigned to the game input + */ +class Android final : public InputEngine { +public: + explicit Android(std::string input_engine_); + + /** + * Registers controller number to accept new inputs + * @param controller_number the controller number that will take this action + */ + void RegisterController(std::size_t controller_number); + + /** + * Sets the status of all buttons bound with the key to pressed + * @param controller_number the controller number that will take this action + * @param button_id the id of the button + * @param value indicates if the button is pressed or not + */ + void SetButtonState(std::size_t controller_number, int button_id, bool value); + + /** + * Sets the status of a analog input to a specific player index + * @param controller_number the controller number that will take this action + * @param axis_id the id of the axis to move + * @param value the analog position of the axis + */ + void SetAxisState(std::size_t controller_number, int axis_id, float value); + + /** + * Sets the status of the motion sensor to a specific player index + * @param controller_number the controller number that will take this action + * @param delta_timestamp time passed since last reading + * @param gyro_x,gyro_y,gyro_z the gyro sensor readings + * @param accel_x,accel_y,accel_z the accelerometer reading + */ + void SetMotionState(std::size_t controller_number, u64 delta_timestamp, float gyro_x, + float gyro_y, float gyro_z, float accel_x, float accel_y, float accel_z); + +private: + /// Returns the correct identifier corresponding to the player index + PadIdentifier GetIdentifier(std::size_t controller_number) const; +}; + +} // namespace InputCommon diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 1ff296af5..f1184a5fa 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp @@ -451,11 +451,11 @@ ButtonMapping GCAdapter::GetButtonMappingForDevice(const Common::ParamPackage& p std::tuple{Settings::NativeButton::ZL, PadButton::TriggerL, PadAxes::TriggerLeft}, {Settings::NativeButton::ZR, PadButton::TriggerR, PadAxes::TriggerRight}, }; - for (const auto& [switch_button, gcadapter_buton, gcadapter_axis] : switch_to_gcadapter_axis) { + for (const auto& [switch_button, gcadapter_button, gcadapter_axis] : switch_to_gcadapter_axis) { Common::ParamPackage button_params{}; button_params.Set("engine", GetEngineName()); button_params.Set("port", params.Get("port", 0)); - button_params.Set("button", static_cast<s32>(gcadapter_buton)); + button_params.Set("button", static_cast<s32>(gcadapter_button)); button_params.Set("axis", static_cast<s32>(gcadapter_axis)); button_params.Set("threshold", 0.5f); button_params.Set("range", 1.9f); diff --git a/src/input_common/helpers/joycon_protocol/irs.cpp b/src/input_common/helpers/joycon_protocol/irs.cpp index 68b0589e3..5bf72114d 100644 --- a/src/input_common/helpers/joycon_protocol/irs.cpp +++ b/src/input_common/helpers/joycon_protocol/irs.cpp @@ -236,9 +236,9 @@ Common::Input::DriverResult IrsProtocol::WriteRegistersStep2() { .number_of_registers = 0x8, .registers = { - IrsRegister{IrRegistersAddress::LedIntensitiyMSB, + IrsRegister{IrRegistersAddress::LedIntensityMSB, static_cast<u8>(led_intensity >> 8)}, - {IrRegistersAddress::LedIntensitiyLSB, static_cast<u8>(led_intensity & 0xff)}, + {IrRegistersAddress::LedIntensityLSB, static_cast<u8>(led_intensity & 0xff)}, {IrRegistersAddress::ImageFlip, static_cast<u8>(image_flip)}, {IrRegistersAddress::DenoiseSmoothing, static_cast<u8>((denoise >> 16) & 0xff)}, {IrRegistersAddress::DenoiseEdge, static_cast<u8>((denoise >> 8) & 0xff)}, diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index 77a43c67a..792f124e1 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h @@ -282,7 +282,7 @@ enum class NFCCommand : u8 { CancelAll = 0x00, StartPolling = 0x01, StopPolling = 0x02, - StartWaitingRecieve = 0x04, + StartWaitingReceive = 0x04, ReadNtag = 0x06, WriteNtag = 0x08, Mifare = 0x0F, @@ -382,8 +382,8 @@ enum class IrRegistersAddress : u16 { FinalizeConfig = 0x0700, LedFilter = 0x0e00, Leds = 0x1000, - LedIntensitiyMSB = 0x1100, - LedIntensitiyLSB = 0x1200, + LedIntensityMSB = 0x1100, + LedIntensityLSB = 0x1200, ImageFlip = 0x2d00, Resolution = 0x2e00, DigitalGainLSB = 0x2e01, diff --git a/src/input_common/helpers/joycon_protocol/nfc.cpp b/src/input_common/helpers/joycon_protocol/nfc.cpp index 09953394b..db83f9ef4 100644 --- a/src/input_common/helpers/joycon_protocol/nfc.cpp +++ b/src/input_common/helpers/joycon_protocol/nfc.cpp @@ -519,13 +519,13 @@ Common::Input::DriverResult NfcProtocol::GetMifareData( } if (output.mcu_report == MCUReport::NFCState && output.mcu_data[1] == 0x10) { - constexpr std::size_t DATA_LENGHT = 0x10 + 1; + constexpr std::size_t DATA_LENGTH = 0x10 + 1; constexpr std::size_t DATA_START = 11; const u8 number_of_elements = output.mcu_data[10]; for (std::size_t i = 0; i < number_of_elements; i++) { - out_data[i].sector = output.mcu_data[DATA_START + (i * DATA_LENGHT)]; + out_data[i].sector = output.mcu_data[DATA_START + (i * DATA_LENGTH)]; memcpy(out_data[i].data.data(), - output.mcu_data.data() + DATA_START + 1 + (i * DATA_LENGHT), + output.mcu_data.data() + DATA_START + 1 + (i * DATA_LENGTH), sizeof(MifareReadData::data)); } package_index++; @@ -659,7 +659,7 @@ Common::Input::DriverResult NfcProtocol::SendStopPollingRequest(MCUCommandRespon Common::Input::DriverResult NfcProtocol::SendNextPackageRequest(MCUCommandResponse& output, u8 packet_id) { NFCRequestState request{ - .command_argument = NFCCommand::StartWaitingRecieve, + .command_argument = NFCCommand::StartWaitingReceive, .block_id = {}, .packet_id = packet_id, .packet_flag = MCUPacketFlag::LastCommandPacket, diff --git a/src/input_common/helpers/joycon_protocol/rumble.cpp b/src/input_common/helpers/joycon_protocol/rumble.cpp index 7647f505e..9fd0b8470 100644 --- a/src/input_common/helpers/joycon_protocol/rumble.cpp +++ b/src/input_common/helpers/joycon_protocol/rumble.cpp @@ -67,7 +67,7 @@ u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const { // More information about these values can be found here: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md - static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ + static constexpr std::array<std::pair<f32, int>, 101> high_frequency_amplitude{ std::pair<f32, int>{0.0f, 0x0}, {0.01f, 0x2}, {0.012f, 0x4}, @@ -171,20 +171,20 @@ u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const { {1.003f, 0xc8}, }; - for (const auto& [amplitude_value, code] : high_fequency_amplitude) { + for (const auto& [amplitude_value, code] : high_frequency_amplitude) { if (amplitude <= amplitude_value) { return static_cast<u8>(code); } } - return static_cast<u8>(high_fequency_amplitude[high_fequency_amplitude.size() - 1].second); + return static_cast<u8>(high_frequency_amplitude[high_frequency_amplitude.size() - 1].second); } u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const { // More information about these values can be found here: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md - static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ + static constexpr std::array<std::pair<f32, int>, 101> high_frequency_amplitude{ std::pair<f32, int>{0.0f, 0x0040}, {0.01f, 0x8040}, {0.012f, 0x0041}, @@ -288,13 +288,13 @@ u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const { {1.003f, 0x0072}, }; - for (const auto& [amplitude_value, code] : high_fequency_amplitude) { + for (const auto& [amplitude_value, code] : high_frequency_amplitude) { if (amplitude <= amplitude_value) { return static_cast<u16>(code); } } - return static_cast<u16>(high_fequency_amplitude[high_fequency_amplitude.size() - 1].second); + return static_cast<u16>(high_frequency_amplitude[high_frequency_amplitude.size() - 1].second); } } // namespace InputCommon::Joycon diff --git a/src/input_common/helpers/udp_protocol.h b/src/input_common/helpers/udp_protocol.h index d9643ffe0..dba9f87d9 100644 --- a/src/input_common/helpers/udp_protocol.h +++ b/src/input_common/helpers/udp_protocol.h @@ -78,7 +78,7 @@ namespace Request { enum RegisterFlags : u8 { AllPads, PadID, - PadMACAdddress, + PadMACAddress, }; struct Version {}; diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index 8c2ee4eb3..f1a1d7398 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp @@ -210,6 +210,9 @@ bool MappingFactory::IsDriverValid(const MappingData& data) const { if (data.engine == "analog_from_button") { return false; } + if (data.engine == "virtual_gamepad") { + return false; + } return true; } diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index c77fc04ee..f8749ebbf 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -4,6 +4,7 @@ #include <memory> #include "common/input.h" #include "common/param_package.h" +#include "input_common/drivers/android.h" #include "input_common/drivers/camera.h" #include "input_common/drivers/keyboard.h" #include "input_common/drivers/mouse.h" @@ -78,6 +79,7 @@ struct InputSubsystem::Impl { RegisterEngine("cemuhookudp", udp_client); RegisterEngine("tas", tas_input); RegisterEngine("camera", camera); + RegisterEngine("android", android); RegisterEngine("virtual_amiibo", virtual_amiibo); RegisterEngine("virtual_gamepad", virtual_gamepad); #ifdef HAVE_SDL2 @@ -109,6 +111,7 @@ struct InputSubsystem::Impl { UnregisterEngine(udp_client); UnregisterEngine(tas_input); UnregisterEngine(camera); + UnregisterEngine(android); UnregisterEngine(virtual_amiibo); UnregisterEngine(virtual_gamepad); #ifdef HAVE_SDL2 @@ -129,6 +132,8 @@ struct InputSubsystem::Impl { devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end()); auto mouse_devices = mouse->GetInputDevices(); devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end()); + auto android_devices = android->GetInputDevices(); + devices.insert(devices.end(), android_devices.begin(), android_devices.end()); #ifdef HAVE_LIBUSB auto gcadapter_devices = gcadapter->GetInputDevices(); devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end()); @@ -157,6 +162,9 @@ struct InputSubsystem::Impl { if (engine == mouse->GetEngineName()) { return mouse; } + if (engine == android->GetEngineName()) { + return android; + } #ifdef HAVE_LIBUSB if (engine == gcadapter->GetEngineName()) { return gcadapter; @@ -237,6 +245,9 @@ struct InputSubsystem::Impl { if (engine == mouse->GetEngineName()) { return true; } + if (engine == android->GetEngineName()) { + return true; + } #ifdef HAVE_LIBUSB if (engine == gcadapter->GetEngineName()) { return true; @@ -265,6 +276,7 @@ struct InputSubsystem::Impl { void BeginConfiguration() { keyboard->BeginConfiguration(); mouse->BeginConfiguration(); + android->BeginConfiguration(); #ifdef HAVE_LIBUSB gcadapter->BeginConfiguration(); #endif @@ -278,6 +290,7 @@ struct InputSubsystem::Impl { void EndConfiguration() { keyboard->EndConfiguration(); mouse->EndConfiguration(); + android->EndConfiguration(); #ifdef HAVE_LIBUSB gcadapter->EndConfiguration(); #endif @@ -308,6 +321,7 @@ struct InputSubsystem::Impl { std::shared_ptr<TasInput::Tas> tas_input; std::shared_ptr<CemuhookUDP::UDPClient> udp_client; std::shared_ptr<Camera> camera; + std::shared_ptr<Android> android; std::shared_ptr<VirtualAmiibo> virtual_amiibo; std::shared_ptr<VirtualGamepad> virtual_gamepad; @@ -373,6 +387,14 @@ const Camera* InputSubsystem::GetCamera() const { return impl->camera.get(); } +Android* InputSubsystem::GetAndroid() { + return impl->android.get(); +} + +const Android* InputSubsystem::GetAndroid() const { + return impl->android.get(); +} + VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() { return impl->virtual_amiibo.get(); } diff --git a/src/input_common/main.h b/src/input_common/main.h index d64a6cb4c..1d19019ee 100644 --- a/src/input_common/main.h +++ b/src/input_common/main.h @@ -29,6 +29,7 @@ enum Values : int; } namespace InputCommon { +class Android; class Camera; class Keyboard; class Mouse; @@ -103,6 +104,12 @@ public: /// Retrieves the underlying camera input device. [[nodiscard]] const Camera* GetCamera() const; + /// Retrieves the underlying android input device. + [[nodiscard]] Android* GetAndroid(); + + /// Retrieves the underlying android input device. + [[nodiscard]] const Android* GetAndroid() const; + /// Retrieves the underlying virtual amiibo input device. [[nodiscard]] VirtualAmiibo* GetVirtualAmiibo(); diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp index b94cb24ad..a6845273c 100644 --- a/src/network/room_member.cpp +++ b/src/network/room_member.cpp @@ -724,7 +724,7 @@ RoomMember::CallbackHandle<RoomInformation> RoomMember::BindOnRoomInformationCha return room_member_impl->Bind(callback); } -RoomMember::CallbackHandle<ChatEntry> RoomMember::BindOnChatMessageRecieved( +RoomMember::CallbackHandle<ChatEntry> RoomMember::BindOnChatMessageReceived( std::function<void(const ChatEntry&)> callback) { return room_member_impl->Bind(callback); } diff --git a/src/network/room_member.h b/src/network/room_member.h index 33ac18e72..37e9ea16a 100644 --- a/src/network/room_member.h +++ b/src/network/room_member.h @@ -254,7 +254,7 @@ public: * @param callback The function to call * @return A handle used for removing the function from the registered list */ - CallbackHandle<ChatEntry> BindOnChatMessageRecieved( + CallbackHandle<ChatEntry> BindOnChatMessageReceived( std::function<void(const ChatEntry&)> callback); /** diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp index b2ceeefc4..c5ac7b8f2 100644 --- a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp @@ -608,8 +608,8 @@ std::string EmitContext::DefineGlobalMemoryFunctions() { const auto aligned_low_addr{fmt::format("{}&{}", addr_xy[0], ssbo_align_mask)}; const auto aligned_addr{fmt::format("uvec2({},{})", aligned_low_addr, addr_xy[1])}; const auto addr_pack{fmt::format("packUint2x32({})", aligned_addr)}; - const auto addr_statment{fmt::format("uint64_t {}={};", ssbo_addr, addr_pack)}; - func += addr_statment; + const auto addr_statement{fmt::format("uint64_t {}={};", ssbo_addr, addr_pack)}; + func += addr_statement; const auto size_vec{fmt::format("uvec2({},{})", size_xy[0], size_xy[1])}; const auto comp_lhs{fmt::format("(addr>={})", ssbo_addr)}; diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 800754554..64a4e0e55 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp @@ -12,6 +12,11 @@ namespace Shader::Backend::SPIRV { namespace { class ImageOperands { public: + [[maybe_unused]] static constexpr bool ImageSampleOffsetAllowed = false; + [[maybe_unused]] static constexpr bool ImageGatherOffsetAllowed = true; + [[maybe_unused]] static constexpr bool ImageFetchOffsetAllowed = false; + [[maybe_unused]] static constexpr bool ImageGradientOffsetAllowed = false; + explicit ImageOperands(EmitContext& ctx, bool has_bias, bool has_lod, bool has_lod_clamp, Id lod, const IR::Value& offset) { if (has_bias) { @@ -22,7 +27,7 @@ public: const Id lod_value{has_lod_clamp ? ctx.OpCompositeExtract(ctx.F32[1], lod, 0) : lod}; Add(spv::ImageOperandsMask::Lod, lod_value); } - AddOffset(ctx, offset); + AddOffset(ctx, offset, ImageSampleOffsetAllowed); if (has_lod_clamp) { const Id lod_clamp{has_bias ? ctx.OpCompositeExtract(ctx.F32[1], lod, 1) : lod}; Add(spv::ImageOperandsMask::MinLod, lod_clamp); @@ -55,20 +60,17 @@ public: Add(spv::ImageOperandsMask::ConstOffsets, offsets); } - explicit ImageOperands(Id offset, Id lod, Id ms) { + explicit ImageOperands(Id lod, Id ms) { if (Sirit::ValidId(lod)) { Add(spv::ImageOperandsMask::Lod, lod); } - if (Sirit::ValidId(offset)) { - Add(spv::ImageOperandsMask::Offset, offset); - } if (Sirit::ValidId(ms)) { Add(spv::ImageOperandsMask::Sample, ms); } } explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives, - u32 num_derivatives, Id offset, Id lod_clamp) { + u32 num_derivatives, const IR::Value& offset, Id lod_clamp) { if (!Sirit::ValidId(derivatives)) { throw LogicError("Derivatives must be present"); } @@ -83,16 +85,14 @@ public: const Id derivatives_Y{ctx.OpCompositeConstruct( ctx.F32[num_derivatives], std::span{deriv_y_accum.data(), deriv_y_accum.size()})}; Add(spv::ImageOperandsMask::Grad, derivatives_X, derivatives_Y); - if (Sirit::ValidId(offset)) { - Add(spv::ImageOperandsMask::Offset, offset); - } + AddOffset(ctx, offset, ImageGradientOffsetAllowed); if (has_lod_clamp) { Add(spv::ImageOperandsMask::MinLod, lod_clamp); } } explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives_1, Id derivatives_2, - Id offset, Id lod_clamp) { + const IR::Value& offset, Id lod_clamp) { if (!Sirit::ValidId(derivatives_1) || !Sirit::ValidId(derivatives_2)) { throw LogicError("Derivatives must be present"); } @@ -111,9 +111,7 @@ public: const Id derivatives_id2{ctx.OpCompositeConstruct( ctx.F32[3], std::span{deriv_2_accum.data(), deriv_2_accum.size()})}; Add(spv::ImageOperandsMask::Grad, derivatives_id1, derivatives_id2); - if (Sirit::ValidId(offset)) { - Add(spv::ImageOperandsMask::Offset, offset); - } + AddOffset(ctx, offset, ImageGradientOffsetAllowed); if (has_lod_clamp) { Add(spv::ImageOperandsMask::MinLod, lod_clamp); } @@ -132,7 +130,7 @@ public: } private: - void AddOffset(EmitContext& ctx, const IR::Value& offset) { + void AddOffset(EmitContext& ctx, const IR::Value& offset, bool runtime_offset_allowed) { if (offset.IsEmpty()) { return; } @@ -165,7 +163,9 @@ private: break; } } - Add(spv::ImageOperandsMask::Offset, ctx.Def(offset)); + if (runtime_offset_allowed) { + Add(spv::ImageOperandsMask::Offset, ctx.Def(offset)); + } } void Add(spv::ImageOperandsMask new_mask, Id value) { @@ -311,6 +311,37 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info, return coords; } } + +void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, Id& coords, + Id offset) { + if (!Sirit::ValidId(offset)) { + return; + } + + Id result_type{}; + switch (info.type) { + case TextureType::Buffer: + case TextureType::Color1D: + case TextureType::ColorArray1D: { + result_type = ctx.U32[1]; + break; + } + case TextureType::Color2D: + case TextureType::Color2DRect: + case TextureType::ColorArray2D: { + result_type = ctx.U32[2]; + break; + } + case TextureType::Color3D: { + result_type = ctx.U32[3]; + break; + } + case TextureType::ColorCube: + case TextureType::ColorArrayCube: + return; + } + coords = ctx.OpIAdd(result_type, coords, offset); +} } // Anonymous namespace Id EmitBindlessImageSampleImplicitLod(EmitContext&) { @@ -496,6 +527,7 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, Id lod, Id ms) { const auto info{inst->Flags<IR::TextureInstInfo>()}; + AddOffsetToCoordinates(ctx, info, coords, offset); if (info.type == TextureType::Buffer) { lod = Id{}; } @@ -503,7 +535,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c // This image is multisampled, lod must be implicit lod = Id{}; } - const ImageOperands operands(offset, lod, ms); + const ImageOperands operands(lod, ms); return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); } @@ -548,13 +580,13 @@ Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, I } Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, - Id derivatives, Id offset, Id lod_clamp) { + Id derivatives, const IR::Value& offset, Id lod_clamp) { const auto info{inst->Flags<IR::TextureInstInfo>()}; - const auto operands = - info.num_derivatives == 3 - ? ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, offset, {}, lod_clamp) - : ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, info.num_derivatives, offset, - lod_clamp); + const auto operands = info.num_derivatives == 3 + ? ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, + ctx.Def(offset), {}, lod_clamp) + : ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, + info.num_derivatives, offset, lod_clamp); return Emit(&EmitContext::OpImageSparseSampleExplicitLod, &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4], Texture(ctx, info, index), coords, operands.Mask(), operands.Span()); diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 7d34575c8..5c01b1012 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h @@ -543,7 +543,7 @@ Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& i const IR::Value& skip_mips); Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, - Id derivatives, Id offset, Id lod_clamp); + Id derivatives, const IR::Value& offset, Id lod_clamp); Id EmitImageRead(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color); Id EmitIsTextureScaled(EmitContext& ctx, const IR::Value& index); diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index f8d8ca80a..51e7ab1e1 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -55,7 +55,7 @@ public: /// Requests to begin a renderpass. void RequestRenderpass(const Framebuffer* framebuffer); - /// Requests the current executino context to be able to execute operations only allowed outside + /// Requests the current execution context to be able to execute operations only allowed outside /// of a renderpass. void RequestOutsideRenderPassOperationContext(); diff --git a/src/yuzu/applets/qt_amiibo_settings.cpp b/src/yuzu/applets/qt_amiibo_settings.cpp index b457a736a..b91796dde 100644 --- a/src/yuzu/applets/qt_amiibo_settings.cpp +++ b/src/yuzu/applets/qt_amiibo_settings.cpp @@ -36,7 +36,7 @@ QtAmiiboSettingsDialog::QtAmiiboSettingsDialog(QWidget* parent, QtAmiiboSettingsDialog::~QtAmiiboSettingsDialog() = default; int QtAmiiboSettingsDialog::exec() { - if (!is_initalized) { + if (!is_initialized) { return QDialog::Rejected; } return QDialog::exec(); @@ -66,7 +66,7 @@ void QtAmiiboSettingsDialog::LoadInfo() { QString::fromStdString(input_subsystem->GetVirtualAmiibo()->GetLastFilePath())); SetSettingsDescription(); - is_initalized = true; + is_initialized = true; } void QtAmiiboSettingsDialog::LoadAmiiboInfo() { diff --git a/src/yuzu/applets/qt_amiibo_settings.h b/src/yuzu/applets/qt_amiibo_settings.h index ee66a0255..3833cf6f2 100644 --- a/src/yuzu/applets/qt_amiibo_settings.h +++ b/src/yuzu/applets/qt_amiibo_settings.h @@ -58,7 +58,7 @@ private: Core::Frontend::CabinetParameters parameters; // If false amiibo settings failed to load - bool is_initalized{}; + bool is_initialized{}; }; class QtAmiiboSettings final : public QObject, public Core::Frontend::CabinetApplet { diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 60edd464c..ae12b3481 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -170,7 +170,7 @@ public: void resizeEvent(QResizeEvent* event) override; - /// Converts a Qt keybard key into NativeKeyboard key + /// Converts a Qt keyboard key into NativeKeyboard key static int QtKeyToSwitchKey(Qt::Key qt_keys); /// Converts a Qt modifier keys into NativeKeyboard modifier keys diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 5dac9f1e7..400917f9d 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -1650,9 +1650,21 @@ void ConfigureInputPlayer::SaveProfile() { void ConfigureInputPlayer::UpdateInputProfiles() { ui->comboProfiles->clear(); - for (const auto& profile_name : profiles->GetInputProfileNames()) { + // Set current profile as empty by default + int profile_index = -1; + + // Add every available profile and search the player profile to set it as current one + auto& current_profile = Settings::values.players.GetValue()[player_index].profile_name; + std::vector<std::string> profile_names = profiles->GetInputProfileNames(); + std::string profile_name; + for (size_t i = 0; i < profile_names.size(); i++) { + profile_name = profile_names[i]; ui->comboProfiles->addItem(QString::fromStdString(profile_name)); + if (current_profile == profile_name) { + profile_index = (int)i; + } } - ui->comboProfiles->setCurrentIndex(-1); + LOG_DEBUG(Frontend, "Setting the current input profile to index {}", profile_index); + ui->comboProfiles->setCurrentIndex(profile_index); } diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index 8f91f5e92..b3d9d8006 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp @@ -845,12 +845,12 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) DrawSymbol(p, face_center + QPoint(-face_distance, 1), Symbol::Y, text_size); // D-pad buttons - const QPointF dpad_postion = center + QPoint(-61, 0); - DrawArrowButton(p, dpad_postion, Direction::Up, button_values[DUp]); - DrawArrowButton(p, dpad_postion, Direction::Left, button_values[DLeft]); - DrawArrowButton(p, dpad_postion, Direction::Right, button_values[DRight]); - DrawArrowButton(p, dpad_postion, Direction::Down, button_values[DDown]); - DrawArrowButtonOutline(p, dpad_postion); + const QPointF dpad_position = center + QPoint(-61, 0); + DrawArrowButton(p, dpad_position, Direction::Up, button_values[DUp]); + DrawArrowButton(p, dpad_position, Direction::Left, button_values[DLeft]); + DrawArrowButton(p, dpad_position, Direction::Right, button_values[DRight]); + DrawArrowButton(p, dpad_position, Direction::Down, button_values[DDown]); + DrawArrowButtonOutline(p, dpad_position); // ZL and ZR buttons p.setPen(colors.outline); @@ -935,13 +935,13 @@ void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) { DrawSymbol(p, center + QPoint(100, -83), Symbol::Y, text_size); // D-pad buttons - const QPointF dpad_postion = center + QPoint(-61, 37); + const QPointF dpad_position = center + QPoint(-61, 37); const float dpad_size = 0.8f; - DrawArrowButton(p, dpad_postion, Direction::Up, button_values[DUp], dpad_size); - DrawArrowButton(p, dpad_postion, Direction::Left, button_values[DLeft], dpad_size); - DrawArrowButton(p, dpad_postion, Direction::Right, button_values[DRight], dpad_size); - DrawArrowButton(p, dpad_postion, Direction::Down, button_values[DDown], dpad_size); - DrawArrowButtonOutline(p, dpad_postion, dpad_size); + DrawArrowButton(p, dpad_position, Direction::Up, button_values[DUp], dpad_size); + DrawArrowButton(p, dpad_position, Direction::Left, button_values[DLeft], dpad_size); + DrawArrowButton(p, dpad_position, Direction::Right, button_values[DRight], dpad_size); + DrawArrowButton(p, dpad_position, Direction::Down, button_values[DDown], dpad_size); + DrawArrowButtonOutline(p, dpad_position, dpad_size); // Minus and Plus buttons p.setPen(colors.outline); diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 7cbf43775..b0b84f967 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -121,7 +121,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { } if (setting->Id() == Settings::values.region_index.Id()) { - // Keep track of the region_index (and langauge_index) combobox to validate the selected + // Keep track of the region_index (and language_index) combobox to validate the selected // settings combo_region = widget->combobox; } else if (setting->Id() == Settings::values.language_index.Id()) { diff --git a/src/yuzu/configuration/input_profiles.cpp b/src/yuzu/configuration/input_profiles.cpp index 716efbccd..ebebadc94 100644 --- a/src/yuzu/configuration/input_profiles.cpp +++ b/src/yuzu/configuration/input_profiles.cpp @@ -5,6 +5,7 @@ #include "common/fs/fs.h" #include "common/fs/path_util.h" +#include "common/logging/log.h" #include "frontend_common/config.h" #include "yuzu/configuration/input_profiles.h" @@ -113,6 +114,8 @@ bool InputProfiles::LoadProfile(const std::string& profile_name, std::size_t pla return false; } + LOG_INFO(Config, "Loading input profile `{}`", profile_name); + map_profiles[profile_name]->ReadQtControlPlayerValues(player_index); return true; } diff --git a/src/yuzu/configuration/qt_config.cpp b/src/yuzu/configuration/qt_config.cpp index 6aca71d7c..1051031f2 100644 --- a/src/yuzu/configuration/qt_config.cpp +++ b/src/yuzu/configuration/qt_config.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "common/logging/log.h" #include "input_common/main.h" #include "qt_config.h" #include "uisettings.h" @@ -65,7 +66,7 @@ void QtConfig::ReloadAllValues() { } void QtConfig::SaveAllValues() { - Save(); + SaveValues(); SaveQtValues(); } @@ -327,7 +328,10 @@ void QtConfig::ReadMultiplayerValues() { void QtConfig::SaveQtValues() { if (global) { + LOG_DEBUG(Config, "Saving global Qt configuration values"); SaveUIValues(); + } else { + LOG_DEBUG(Config, "Saving Qt configuration values"); } SaveQtControlValues(); @@ -545,6 +549,7 @@ void QtConfig::ReadQtControlPlayerValues(std::size_t player_index) { void QtConfig::SaveQtControlPlayerValues(std::size_t player_index) { BeginGroup(Settings::TranslateCategory(Settings::Category::Controls)); + LOG_DEBUG(Config, "Saving players control configuration values"); SavePlayerValues(player_index); SaveQtPlayerValues(player_index); diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index 941683a43..85f4f7655 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp @@ -750,12 +750,12 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati } apply_funcs.push_back([load_func, setting_](bool powered_on) { - if (setting_->RuntimeModfiable() || !powered_on) { + if (setting_->RuntimeModifiable() || !powered_on) { load_func(); } }); - bool enable = runtime_lock || setting.RuntimeModfiable(); + bool enable = runtime_lock || setting.RuntimeModifiable(); if (setting.Switchable() && Settings::IsConfiguringGlobal() && !runtime_lock) { enable &= setting.UsingGlobal(); } diff --git a/src/yuzu/multiplayer/chat_room.cpp b/src/yuzu/multiplayer/chat_room.cpp index dec9696c1..4463616b4 100644 --- a/src/yuzu/multiplayer/chat_room.cpp +++ b/src/yuzu/multiplayer/chat_room.cpp @@ -206,7 +206,7 @@ void ChatRoom::Initialize(Network::RoomNetwork* room_network_) { room_network = room_network_; // setup the callbacks for network updates if (auto member = room_network->GetRoomMember().lock()) { - member->BindOnChatMessageRecieved( + member->BindOnChatMessageReceived( [this](const Network::ChatEntry& chat) { emit ChatReceived(chat); }); member->BindOnStatusMessageReceived( [this](const Network::StatusMessageEntry& status_message) { diff --git a/src/yuzu_cmd/sdl_config.cpp b/src/yuzu_cmd/sdl_config.cpp index e81bf5d45..995114510 100644 --- a/src/yuzu_cmd/sdl_config.cpp +++ b/src/yuzu_cmd/sdl_config.cpp @@ -5,6 +5,7 @@ #define SDL_MAIN_HANDLED #include <SDL.h> +#include "common/logging/log.h" #include "input_common/main.h" #include "sdl_config.h" @@ -64,7 +65,7 @@ void SdlConfig::ReloadAllValues() { } void SdlConfig::SaveAllValues() { - Save(); + SaveValues(); SaveSdlValues(); } @@ -177,6 +178,7 @@ void SdlConfig::ReadHidbusValues() { } void SdlConfig::SaveSdlValues() { + LOG_DEBUG(Config, "Saving SDL configuration values"); SaveSdlControlValues(); WriteToIni(); diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index a81635fa4..c3cacf852 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -401,7 +401,7 @@ int main(int argc, char** argv) { if (use_multiplayer) { if (auto member = system.GetRoomNetwork().GetRoomMember().lock()) { - member->BindOnChatMessageRecieved(OnMessageReceived); + member->BindOnChatMessageReceived(OnMessageReceived); member->BindOnStatusMessageReceived(OnStatusMessageReceived); member->BindOnStateChanged(OnStateChanged); member->BindOnError(OnNetworkError); |