early-access version 3488

This commit is contained in:
pineappleEA 2023-03-30 04:13:07 +02:00
parent 6f18c236ae
commit e9f70b1439
14 changed files with 83 additions and 41 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3487. This is the source code for early-access 3488.
## Legal Notice ## Legal Notice

View File

@ -71,7 +71,7 @@ void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callbac
} }
} }
callback(); callback(true);
} }
} // namespace Core::Frontend } // namespace Core::Frontend

View File

@ -37,7 +37,7 @@ struct ControllerParameters {
class ControllerApplet : public Applet { class ControllerApplet : public Applet {
public: public:
using ReconfigureCallback = std::function<void()>; using ReconfigureCallback = std::function<void(bool)>;
virtual ~ControllerApplet(); virtual ~ControllerApplet();

View File

@ -224,7 +224,8 @@ void Controller::Execute() {
parameters.allow_dual_joycons, parameters.allow_left_joycon, parameters.allow_dual_joycons, parameters.allow_left_joycon,
parameters.allow_right_joycon); parameters.allow_right_joycon);
frontend.ReconfigureControllers([this] { ConfigurationComplete(); }, parameters); frontend.ReconfigureControllers(
[this](bool is_success) { ConfigurationComplete(is_success); }, parameters);
break; break;
} }
case ControllerSupportMode::ShowControllerStrapGuide: case ControllerSupportMode::ShowControllerStrapGuide:
@ -232,16 +233,16 @@ void Controller::Execute() {
case ControllerSupportMode::ShowControllerKeyRemappingForSystem: case ControllerSupportMode::ShowControllerKeyRemappingForSystem:
UNIMPLEMENTED_MSG("ControllerSupportMode={} is not implemented", UNIMPLEMENTED_MSG("ControllerSupportMode={} is not implemented",
controller_private_arg.mode); controller_private_arg.mode);
ConfigurationComplete(); ConfigurationComplete(true);
break; break;
default: { default: {
ConfigurationComplete(); ConfigurationComplete(true);
break; break;
} }
} }
} }
void Controller::ConfigurationComplete() { void Controller::ConfigurationComplete(bool is_success) {
ControllerSupportResultInfo result_info{}; ControllerSupportResultInfo result_info{};
// If enable_single_mode is enabled, player_count is 1 regardless of any other parameters. // If enable_single_mode is enabled, player_count is 1 regardless of any other parameters.
@ -250,7 +251,7 @@ void Controller::ConfigurationComplete() {
result_info.selected_id = static_cast<u32>(system.HIDCore().GetFirstNpadId()); result_info.selected_id = static_cast<u32>(system.HIDCore().GetFirstNpadId());
result_info.result = 0; result_info.result = is_success ? 0 : 2;
LOG_DEBUG(Service_HID, "Result Info: player_count={}, selected_id={}, result={}", LOG_DEBUG(Service_HID, "Result Info: player_count={}, selected_id={}, result={}",
result_info.player_count, result_info.selected_id, result_info.result); result_info.player_count, result_info.selected_id, result_info.result);

View File

@ -131,7 +131,7 @@ public:
void Execute() override; void Execute() override;
Result RequestExit() override; Result RequestExit() override;
void ConfigurationComplete(); void ConfigurationComplete(bool is_success);
private: private:
const Core::Frontend::ControllerApplet& frontend; const Core::Frontend::ControllerApplet& frontend;

View File

@ -819,12 +819,12 @@ Controller_NPad::NpadCommunicationMode Controller_NPad::GetNpadCommunicationMode
return communication_mode; return communication_mode;
} }
Result Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id, bool Controller_NPad::SetNpadMode(Core::HID::NpadIdType& new_npad_id, Core::HID::NpadIdType npad_id,
NpadJoyDeviceType npad_device_type, NpadJoyDeviceType npad_device_type,
NpadJoyAssignmentMode assignment_mode) { NpadJoyAssignmentMode assignment_mode) {
if (!IsNpadIdValid(npad_id)) { if (!IsNpadIdValid(npad_id)) {
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
return InvalidNpadId; return false;
} }
auto& controller = GetControllerFromNpadIdType(npad_id); auto& controller = GetControllerFromNpadIdType(npad_id);
@ -833,7 +833,7 @@ Result Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id,
} }
if (!controller.device->IsConnected()) { if (!controller.device->IsConnected()) {
return ResultSuccess; return false;
} }
if (assignment_mode == NpadJoyAssignmentMode::Dual) { if (assignment_mode == NpadJoyAssignmentMode::Dual) {
@ -842,52 +842,52 @@ Result Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id,
controller.is_dual_left_connected = true; controller.is_dual_left_connected = true;
controller.is_dual_right_connected = false; controller.is_dual_right_connected = false;
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id, true);
return ResultSuccess; return false;
} }
if (controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight) { if (controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight) {
DisconnectNpad(npad_id); DisconnectNpad(npad_id);
controller.is_dual_left_connected = false; controller.is_dual_left_connected = false;
controller.is_dual_right_connected = true; controller.is_dual_right_connected = true;
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id, true);
return ResultSuccess; return false;
} }
return ResultSuccess; return false;
} }
// This is for NpadJoyAssignmentMode::Single // This is for NpadJoyAssignmentMode::Single
// Only JoyconDual get affected by this function // Only JoyconDual get affected by this function
if (controller.device->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::JoyconDual) { if (controller.device->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::JoyconDual) {
return ResultSuccess; return false;
} }
if (controller.is_dual_left_connected && !controller.is_dual_right_connected) { if (controller.is_dual_left_connected && !controller.is_dual_right_connected) {
DisconnectNpad(npad_id); DisconnectNpad(npad_id);
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconLeft, npad_id, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconLeft, npad_id, true);
return ResultSuccess; return false;
} }
if (!controller.is_dual_left_connected && controller.is_dual_right_connected) { if (!controller.is_dual_left_connected && controller.is_dual_right_connected) {
DisconnectNpad(npad_id); DisconnectNpad(npad_id);
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconRight, npad_id, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconRight, npad_id, true);
return ResultSuccess; return false;
} }
// We have two controllers connected to the same npad_id we need to split them // We have two controllers connected to the same npad_id we need to split them
const auto npad_id_2 = hid_core.GetFirstDisconnectedNpadId(); new_npad_id = hid_core.GetFirstDisconnectedNpadId();
auto& controller_2 = GetControllerFromNpadIdType(npad_id_2); auto& controller_2 = GetControllerFromNpadIdType(new_npad_id);
DisconnectNpad(npad_id); DisconnectNpad(npad_id);
if (npad_device_type == NpadJoyDeviceType::Left) { if (npad_device_type == NpadJoyDeviceType::Left) {
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconLeft, npad_id, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconLeft, npad_id, true);
controller_2.is_dual_left_connected = false; controller_2.is_dual_left_connected = false;
controller_2.is_dual_right_connected = true; controller_2.is_dual_right_connected = true;
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id_2, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, new_npad_id, true);
} else { } else {
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconRight, npad_id, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconRight, npad_id, true);
controller_2.is_dual_left_connected = true; controller_2.is_dual_left_connected = true;
controller_2.is_dual_right_connected = false; controller_2.is_dual_right_connected = false;
UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id_2, true); UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, new_npad_id, true);
} }
return ResultSuccess; return true;
} }
bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id,

View File

@ -102,8 +102,8 @@ public:
void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_); void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_);
NpadCommunicationMode GetNpadCommunicationMode() const; NpadCommunicationMode GetNpadCommunicationMode() const;
Result SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type, bool SetNpadMode(Core::HID::NpadIdType& new_npad_id, Core::HID::NpadIdType npad_id,
NpadJoyAssignmentMode assignment_mode); NpadJoyDeviceType npad_device_type, NpadJoyAssignmentMode assignment_mode);
bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index, bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index,
const Core::HID::VibrationValue& vibration_value); const Core::HID::VibrationValue& vibration_value);

View File

@ -302,7 +302,7 @@ Hid::Hid(Core::System& system_)
{130, &Hid::SwapNpadAssignment, "SwapNpadAssignment"}, {130, &Hid::SwapNpadAssignment, "SwapNpadAssignment"},
{131, &Hid::IsUnintendedHomeButtonInputProtectionEnabled, "IsUnintendedHomeButtonInputProtectionEnabled"}, {131, &Hid::IsUnintendedHomeButtonInputProtectionEnabled, "IsUnintendedHomeButtonInputProtectionEnabled"},
{132, &Hid::EnableUnintendedHomeButtonInputProtection, "EnableUnintendedHomeButtonInputProtection"}, {132, &Hid::EnableUnintendedHomeButtonInputProtection, "EnableUnintendedHomeButtonInputProtection"},
{133, nullptr, "SetNpadJoyAssignmentModeSingleWithDestination"}, {133, &Hid::SetNpadJoyAssignmentModeSingleWithDestination, "SetNpadJoyAssignmentModeSingleWithDestination"},
{134, &Hid::SetNpadAnalogStickUseCenterClamp, "SetNpadAnalogStickUseCenterClamp"}, {134, &Hid::SetNpadAnalogStickUseCenterClamp, "SetNpadAnalogStickUseCenterClamp"},
{135, &Hid::SetNpadCaptureButtonAssignment, "SetNpadCaptureButtonAssignment"}, {135, &Hid::SetNpadCaptureButtonAssignment, "SetNpadCaptureButtonAssignment"},
{136, &Hid::ClearNpadCaptureButtonAssignment, "ClearNpadCaptureButtonAssignment"}, {136, &Hid::ClearNpadCaptureButtonAssignment, "ClearNpadCaptureButtonAssignment"},
@ -1180,8 +1180,10 @@ void Hid::SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx) {
const auto parameters{rp.PopRaw<Parameters>()}; const auto parameters{rp.PopRaw<Parameters>()};
Core::HID::NpadIdType new_npad_id{};
auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad);
controller.SetNpadMode(parameters.npad_id, Controller_NPad::NpadJoyDeviceType::Left, controller.SetNpadMode(new_npad_id, parameters.npad_id,
Controller_NPad::NpadJoyDeviceType::Left,
Controller_NPad::NpadJoyAssignmentMode::Single); Controller_NPad::NpadJoyAssignmentMode::Single);
LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
@ -1203,8 +1205,9 @@ void Hid::SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx) {
const auto parameters{rp.PopRaw<Parameters>()}; const auto parameters{rp.PopRaw<Parameters>()};
Core::HID::NpadIdType new_npad_id{};
auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad);
controller.SetNpadMode(parameters.npad_id, parameters.npad_joy_device_type, controller.SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type,
Controller_NPad::NpadJoyAssignmentMode::Single); Controller_NPad::NpadJoyAssignmentMode::Single);
LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}",
@ -1226,8 +1229,10 @@ void Hid::SetNpadJoyAssignmentModeDual(HLERequestContext& ctx) {
const auto parameters{rp.PopRaw<Parameters>()}; const auto parameters{rp.PopRaw<Parameters>()};
Core::HID::NpadIdType new_npad_id{};
auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad);
controller.SetNpadMode(parameters.npad_id, {}, Controller_NPad::NpadJoyAssignmentMode::Dual); controller.SetNpadMode(new_npad_id, parameters.npad_id, {},
Controller_NPad::NpadJoyAssignmentMode::Dual);
LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
parameters.applet_resource_user_id); parameters.applet_resource_user_id);
@ -1369,6 +1374,34 @@ void Hid::EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx) {
rb.Push(result); rb.Push(result);
} }
void Hid::SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
struct Parameters {
Core::HID::NpadIdType npad_id;
INSERT_PADDING_WORDS_NOINIT(1);
u64 applet_resource_user_id;
Controller_NPad::NpadJoyDeviceType npad_joy_device_type;
};
static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
const auto parameters{rp.PopRaw<Parameters>()};
Core::HID::NpadIdType new_npad_id{};
auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad);
const auto is_reasigned =
controller.SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type,
Controller_NPad::NpadJoyAssignmentMode::Single);
LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}",
parameters.npad_id, parameters.applet_resource_user_id,
parameters.npad_joy_device_type);
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess);
rb.Push(is_reasigned);
rb.PushEnum(new_npad_id);
}
void Hid::SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx) { void Hid::SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
struct Parameters { struct Parameters {

View File

@ -151,6 +151,7 @@ private:
void SwapNpadAssignment(HLERequestContext& ctx); void SwapNpadAssignment(HLERequestContext& ctx);
void IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx); void IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx);
void EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx); void EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx);
void SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx);
void SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx); void SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx);
void SetNpadCaptureButtonAssignment(HLERequestContext& ctx); void SetNpadCaptureButtonAssignment(HLERequestContext& ctx);
void ClearNpadCaptureButtonAssignment(HLERequestContext& ctx); void ClearNpadCaptureButtonAssignment(HLERequestContext& ctx);

View File

@ -300,7 +300,7 @@ bool QtControllerSelectorDialog::CheckIfParametersMet() {
if (num_connected_players < min_supported_players || if (num_connected_players < min_supported_players ||
num_connected_players > max_supported_players) { num_connected_players > max_supported_players) {
parameters_met = false; parameters_met = false;
ui->buttonBox->setEnabled(parameters_met); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(parameters_met);
return parameters_met; return parameters_met;
} }
@ -327,7 +327,7 @@ bool QtControllerSelectorDialog::CheckIfParametersMet() {
}(); }();
parameters_met = all_controllers_compatible; parameters_met = all_controllers_compatible;
ui->buttonBox->setEnabled(parameters_met); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(parameters_met);
return parameters_met; return parameters_met;
} }
@ -697,8 +697,8 @@ void QtControllerSelector::ReconfigureControllers(
emit MainWindowReconfigureControllers(parameters); emit MainWindowReconfigureControllers(parameters);
} }
void QtControllerSelector::MainWindowReconfigureFinished() { void QtControllerSelector::MainWindowReconfigureFinished(bool is_success) {
if (callback) { if (callback) {
callback(); callback(is_success);
} }
} }

View File

@ -167,7 +167,7 @@ signals:
void MainWindowRequestExit() const; void MainWindowRequestExit() const;
private: private:
void MainWindowReconfigureFinished(); void MainWindowReconfigureFinished(bool is_success);
mutable ReconfigureCallback callback; mutable ReconfigureCallback callback;
}; };

View File

@ -2629,7 +2629,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -2649,5 +2649,11 @@
<receiver>QtControllerSelectorDialog</receiver> <receiver>QtControllerSelectorDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
</connection> </connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QtControllerSelectorDialog</receiver>
<slot>reject()</slot>
</connection>
</connections> </connections>
</ui> </ui>

View File

@ -634,15 +634,16 @@ void GMainWindow::ControllerSelectorReconfigureControllers(
Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowStaysOnTopHint | Qt::WindowTitleHint |
Qt::WindowSystemMenuHint); Qt::WindowSystemMenuHint);
controller_applet->setWindowModality(Qt::WindowModal); controller_applet->setWindowModality(Qt::WindowModal);
controller_applet->exec(); bool is_success = controller_applet->exec() != QDialog::Rejected;
emit ControllerSelectorReconfigureFinished();
// Don't forget to apply settings. // Don't forget to apply settings.
system->HIDCore().DisableAllControllerConfiguration();
system->ApplySettings(); system->ApplySettings();
config->Save(); config->Save();
UpdateStatusButtons(); UpdateStatusButtons();
emit ControllerSelectorReconfigureFinished(is_success);
} }
void GMainWindow::ControllerSelectorRequestExit() { void GMainWindow::ControllerSelectorRequestExit() {

View File

@ -165,7 +165,7 @@ signals:
void AmiiboSettingsFinished(bool is_success, const std::string& name); void AmiiboSettingsFinished(bool is_success, const std::string& name);
void ControllerSelectorReconfigureFinished(); void ControllerSelectorReconfigureFinished(bool is_success);
void ErrorDisplayFinished(); void ErrorDisplayFinished();