2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

service: nfp: Allow to load with a different amiibo id

This commit is contained in:
german77 2023-05-08 22:03:32 -06:00 committed by Narr the Reg
parent 7944f271dc
commit 1968cc7b10
6 changed files with 39 additions and 7 deletions

View file

@ -535,6 +535,8 @@ struct Values {
Setting<bool> enable_ir_sensor{false, "enable_ir_sensor"}; Setting<bool> enable_ir_sensor{false, "enable_ir_sensor"};
Setting<std::string> ir_sensor_device{"auto", "ir_sensor_device"}; Setting<std::string> ir_sensor_device{"auto", "ir_sensor_device"};
Setting<bool> random_amiibo_id{false, "random_amiibo_id"};
// Data Storage // Data Storage
Setting<bool> use_virtual_sd{true, "use_virtual_sd"}; Setting<bool> use_virtual_sd{true, "use_virtual_sd"};
Setting<bool> gamecard_inserted{false, "gamecard_inserted"}; Setting<bool> gamecard_inserted{false, "gamecard_inserted"};

View file

@ -227,11 +227,20 @@ Result NfcDevice::GetTagInfo(NFP::TagInfo& tag_info, bool is_mifare) const {
return ResultWrongDeviceState; return ResultWrongDeviceState;
} }
UniqueSerialNumber uuid = encrypted_tag_data.uuid.uid;
// Generate random UUID to bypass amiibo load limits
if (Settings::values.random_amiibo_id) {
Common::TinyMT rng{};
rng.GenerateRandomBytes(uuid.data(), sizeof(UniqueSerialNumber));
uuid[3] = 0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2];
}
if (is_mifare) { if (is_mifare) {
tag_info = { tag_info = {
.uuid = encrypted_tag_data.uuid.uid, .uuid = uuid,
.uuid_extension = {}, .uuid_extension = {},
.uuid_length = static_cast<u8>(encrypted_tag_data.uuid.uid.size()), .uuid_length = static_cast<u8>(uuid.size()),
.protocol = NfcProtocol::TypeA, .protocol = NfcProtocol::TypeA,
.tag_type = TagType::Type4, .tag_type = TagType::Type4,
}; };
@ -240,9 +249,9 @@ Result NfcDevice::GetTagInfo(NFP::TagInfo& tag_info, bool is_mifare) const {
// Protocol and tag type may change here // Protocol and tag type may change here
tag_info = { tag_info = {
.uuid = encrypted_tag_data.uuid.uid, .uuid = uuid,
.uuid_extension = {}, .uuid_extension = {},
.uuid_length = static_cast<u8>(encrypted_tag_data.uuid.uid.size()), .uuid_length = static_cast<u8>(uuid.size()),
.protocol = NfcProtocol::TypeA, .protocol = NfcProtocol::TypeA,
.tag_type = TagType::Type2, .tag_type = TagType::Type2,
}; };

View file

@ -443,6 +443,7 @@ void Config::ReadControlValues() {
ReadBasicSetting(Settings::values.mouse_panning_sensitivity); ReadBasicSetting(Settings::values.mouse_panning_sensitivity);
ReadBasicSetting(Settings::values.enable_joycon_driver); ReadBasicSetting(Settings::values.enable_joycon_driver);
ReadBasicSetting(Settings::values.enable_procon_driver); ReadBasicSetting(Settings::values.enable_procon_driver);
ReadBasicSetting(Settings::values.random_amiibo_id);
ReadBasicSetting(Settings::values.tas_enable); ReadBasicSetting(Settings::values.tas_enable);
ReadBasicSetting(Settings::values.tas_loop); ReadBasicSetting(Settings::values.tas_loop);
@ -1150,6 +1151,7 @@ void Config::SaveControlValues() {
WriteBasicSetting(Settings::values.enable_raw_input); WriteBasicSetting(Settings::values.enable_raw_input);
WriteBasicSetting(Settings::values.enable_joycon_driver); WriteBasicSetting(Settings::values.enable_joycon_driver);
WriteBasicSetting(Settings::values.enable_procon_driver); WriteBasicSetting(Settings::values.enable_procon_driver);
WriteBasicSetting(Settings::values.random_amiibo_id);
WriteBasicSetting(Settings::values.keyboard_enabled); WriteBasicSetting(Settings::values.keyboard_enabled);
WriteBasicSetting(Settings::values.emulate_analog_keyboard); WriteBasicSetting(Settings::values.emulate_analog_keyboard);
WriteBasicSetting(Settings::values.mouse_panning_sensitivity); WriteBasicSetting(Settings::values.mouse_panning_sensitivity);

View file

@ -140,6 +140,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked(); Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked();
Settings::values.enable_joycon_driver = ui->enable_joycon_driver->isChecked(); Settings::values.enable_joycon_driver = ui->enable_joycon_driver->isChecked();
Settings::values.enable_procon_driver = ui->enable_procon_driver->isChecked(); Settings::values.enable_procon_driver = ui->enable_procon_driver->isChecked();
Settings::values.random_amiibo_id = ui->random_amiibo_id->isChecked();
} }
void ConfigureInputAdvanced::LoadConfiguration() { void ConfigureInputAdvanced::LoadConfiguration() {
@ -176,6 +177,7 @@ void ConfigureInputAdvanced::LoadConfiguration() {
ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue()); ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue());
ui->enable_joycon_driver->setChecked(Settings::values.enable_joycon_driver.GetValue()); ui->enable_joycon_driver->setChecked(Settings::values.enable_joycon_driver.GetValue());
ui->enable_procon_driver->setChecked(Settings::values.enable_procon_driver.GetValue()); ui->enable_procon_driver->setChecked(Settings::values.enable_procon_driver.GetValue());
ui->random_amiibo_id->setChecked(Settings::values.random_amiibo_id.GetValue());
UpdateUIEnabled(); UpdateUIEnabled();
} }

View file

@ -2728,6 +2728,22 @@
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="7" column="0">
<widget class="QCheckBox" name="random_amiibo_id">
<property name="toolTip">
<string>Allows unlimited uses of the same Amiibo in games that would otherwise limit you to one use.</string>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Use random Amiibo ID</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="mouse_panning"> <widget class="QCheckBox" name="mouse_panning">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -2740,7 +2756,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="2"> <item row="8" column="2">
<widget class="QSpinBox" name="mouse_panning_sensitivity"> <widget class="QSpinBox" name="mouse_panning_sensitivity">
<property name="toolTip"> <property name="toolTip">
<string>Mouse sensitivity</string> <string>Mouse sensitivity</string>
@ -2762,14 +2778,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="9" column="0">
<widget class="QLabel" name="motion_touch"> <widget class="QLabel" name="motion_touch">
<property name="text"> <property name="text">
<string>Motion / Touch</string> <string>Motion / Touch</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="2"> <item row="9" column="2">
<widget class="QPushButton" name="buttonMotionTouch"> <widget class="QPushButton" name="buttonMotionTouch">
<property name="text"> <property name="text">
<string>Configure</string> <string>Configure</string>

View file

@ -169,6 +169,7 @@ void Config::ReadValues() {
ReadSetting("ControlsGeneral", Settings::values.enable_raw_input); ReadSetting("ControlsGeneral", Settings::values.enable_raw_input);
ReadSetting("ControlsGeneral", Settings::values.enable_joycon_driver); ReadSetting("ControlsGeneral", Settings::values.enable_joycon_driver);
ReadSetting("ControlsGeneral", Settings::values.enable_procon_driver); ReadSetting("ControlsGeneral", Settings::values.enable_procon_driver);
ReadSetting("ControlsGeneral", Settings::values.random_amiibo_id);
ReadSetting("ControlsGeneral", Settings::values.emulate_analog_keyboard); ReadSetting("ControlsGeneral", Settings::values.emulate_analog_keyboard);
ReadSetting("ControlsGeneral", Settings::values.vibration_enabled); ReadSetting("ControlsGeneral", Settings::values.vibration_enabled);
ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations); ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations);