early-access version 3320

This commit is contained in:
pineappleEA 2023-01-20 20:19:57 +01:00
parent e3c75c4723
commit 2bbc4de26b
13 changed files with 181 additions and 144 deletions

View file

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

View file

@ -11,6 +11,7 @@
#include "common/hex_util.h" #include "common/hex_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "common/settings.h"
#include "core/arm/arm_interface.h" #include "core/arm/arm_interface.h"
#include "core/core.h" #include "core/core.h"
#include "core/debugger/gdbstub.h" #include "core/debugger/gdbstub.h"
@ -731,7 +732,25 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
auto* process = system.CurrentProcess(); auto* process = system.CurrentProcess();
auto& page_table = process->PageTable(); auto& page_table = process->PageTable();
if (command_str == "get info") { const char* commands = "Commands:\n"
" get fastmem\n"
" get info\n"
" get mappings\n";
if (command_str == "get fastmem") {
if (Settings::IsFastmemEnabled()) {
const auto& impl = page_table.PageTableImpl();
const auto region = reinterpret_cast<uintptr_t>(impl.fastmem_arena);
const auto region_bits = impl.current_address_space_width_in_bits;
const auto region_size = 1ULL << region_bits;
reply = fmt::format("Region bits: {}\n"
"Host address: {:#x} - {:#x}\n",
region_bits, region, region + region_size - 1);
} else {
reply = "Fastmem is not enabled.\n";
}
} else if (command_str == "get info") {
Loader::AppLoader::Modules modules; Loader::AppLoader::Modules modules;
system.GetAppLoader().ReadNSOModules(modules); system.GetAppLoader().ReadNSOModules(modules);
@ -787,9 +806,10 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
cur_addr = next_address; cur_addr = next_address;
} }
} else if (command_str == "help") { } else if (command_str == "help") {
reply = "Commands:\n get info\n get mappings\n"; reply = commands;
} else { } else {
reply = "Unknown command.\nCommands:\n get info\n get mappings\n"; reply = "Unknown command.\n";
reply += commands;
} }
std::span<const u8> reply_span{reinterpret_cast<u8*>(&reply.front()), reply.size()}; std::span<const u8> reply_span{reinterpret_cast<u8*>(&reply.front()), reply.size()};

View file

@ -11,6 +11,7 @@
namespace Core::HID { namespace Core::HID {
constexpr s32 HID_JOYSTICK_MAX = 0x7fff; constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
constexpr s32 HID_JOYSTICK_MIN = 0x7ffe;
constexpr s32 HID_TRIGGER_MAX = 0x7fff; constexpr s32 HID_TRIGGER_MAX = 0x7fff;
// Use a common UUID for TAS and Virtual Gamepad // Use a common UUID for TAS and Virtual Gamepad
constexpr Common::UUID TAS_UUID = constexpr Common::UUID TAS_UUID =
@ -863,9 +864,16 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback,
return; return;
} }
const auto FloatToShort = [](float a) {
if (a > 0) {
return static_cast<s32>(a * HID_JOYSTICK_MAX);
}
return static_cast<s32>(a * HID_JOYSTICK_MIN);
};
const AnalogStickState stick{ const AnalogStickState stick{
.x = static_cast<s32>(controller.stick_values[index].x.value * HID_JOYSTICK_MAX), .x = FloatToShort(controller.stick_values[index].x.value),
.y = static_cast<s32>(controller.stick_values[index].y.value * HID_JOYSTICK_MAX), .y = FloatToShort(controller.stick_values[index].y.value),
}; };
switch (index) { switch (index) {

View file

@ -182,19 +182,19 @@ void Joycons::RegisterNewDevice(SDL_hid_device_info* device_info) {
std::shared_ptr<Joycon::JoyconDriver> Joycons::GetNextFreeHandle( std::shared_ptr<Joycon::JoyconDriver> Joycons::GetNextFreeHandle(
Joycon::ControllerType type) const { Joycon::ControllerType type) const {
if (type == Joycon::ControllerType::Left) { if (type == Joycon::ControllerType::Left) {
for (const auto& device : left_joycons) { const auto unconnected_device =
if (!device->IsConnected()) { std::ranges::find_if(left_joycons, [](auto& device) { return !device->IsConnected(); });
return device; if (unconnected_device != left_joycons.end()) {
} return *unconnected_device;
} }
} }
if (type == Joycon::ControllerType::Right) { if (type == Joycon::ControllerType::Right) {
for (const auto& device : right_joycons) { const auto unconnected_device = std::ranges::find_if(
if (!device->IsConnected()) { right_joycons, [](auto& device) { return !device->IsConnected(); });
return device;
} if (unconnected_device != right_joycons.end()) {
return *unconnected_device;
} }
} }
return nullptr; return nullptr;
@ -388,20 +388,25 @@ std::shared_ptr<Joycon::JoyconDriver> Joycons::GetHandle(PadIdentifier identifie
return false; return false;
}; };
const auto type = static_cast<Joycon::ControllerType>(identifier.pad); const auto type = static_cast<Joycon::ControllerType>(identifier.pad);
if (type == Joycon::ControllerType::Left) { if (type == Joycon::ControllerType::Left) {
for (const auto& device : left_joycons) { const auto matching_device = std::ranges::find_if(
if (is_handle_active(device)) { left_joycons, [is_handle_active](auto& device) { return is_handle_active(device); });
return device;
} if (matching_device != left_joycons.end()) {
return *matching_device;
} }
} }
if (type == Joycon::ControllerType::Right) { if (type == Joycon::ControllerType::Right) {
for (const auto& device : right_joycons) { const auto matching_device = std::ranges::find_if(
if (is_handle_active(device)) { right_joycons, [is_handle_active](auto& device) { return is_handle_active(device); });
return device;
} if (matching_device != right_joycons.end()) {
return *matching_device;
} }
} }
return nullptr; return nullptr;
} }

View file

@ -349,7 +349,7 @@ JoyconDriver::SupportedFeatures JoyconDriver::GetSupportedFeatures() {
} }
bool JoyconDriver::IsInputThreadValid() const { bool JoyconDriver::IsInputThreadValid() const {
if (!is_connected) { if (!is_connected.load()) {
return false; return false;
} }
if (hidapi_handle->handle == nullptr) { if (hidapi_handle->handle == nullptr) {
@ -491,7 +491,7 @@ DriverResult JoyconDriver::SetRingConMode() {
bool JoyconDriver::IsConnected() const { bool JoyconDriver::IsConnected() const {
std::scoped_lock lock{mutex}; std::scoped_lock lock{mutex};
return is_connected; return is_connected.load();
} }
bool JoyconDriver::IsVibrationEnabled() const { bool JoyconDriver::IsVibrationEnabled() const {

View file

@ -3,6 +3,7 @@
#pragma once #pragma once
#include <atomic>
#include <functional> #include <functional>
#include <mutex> #include <mutex>
#include <span> #include <span>
@ -97,7 +98,7 @@ private:
std::unique_ptr<RumbleProtocol> rumble_protocol; std::unique_ptr<RumbleProtocol> rumble_protocol;
// Connection status // Connection status
bool is_connected{}; std::atomic<bool> is_connected{};
u64 delta_time; u64 delta_time;
std::size_t error_counter{}; std::size_t error_counter{};
std::shared_ptr<JoyconHandle> hidapi_handle; std::shared_ptr<JoyconHandle> hidapi_handle;

View file

@ -273,6 +273,18 @@ enum class NFCTagType : u8 {
Ntag215 = 0x01, Ntag215 = 0x01,
}; };
enum class NFCPages {
Block0 = 0,
Block45 = 45,
Block135 = 135,
Block231 = 231,
};
enum class NFCStatus : u8 {
LastPackage = 0x04,
TagLost = 0x07,
};
enum class IrsMode : u8 { enum class IrsMode : u8 {
None = 0x02, None = 0x02,
Moment = 0x03, Moment = 0x03,
@ -347,13 +359,6 @@ enum class IrRegistersAddress : u16 {
DenoiseColor = 0x6901, DenoiseColor = 0x6901,
}; };
enum class NFCBlock {
Block0 = 0,
Block45 = 45,
Block135 = 135,
Block231 = 231,
};
enum class DriverResult { enum class DriverResult {
Success, Success,
WrongReply, WrongReply,

View file

@ -164,55 +164,53 @@ DriverResult NfcProtocol::ReadTag(const TagFoundData& data) {
LOG_INFO(Input, "Tag detected, type={}, uuid={}", data.type, uuid_string); LOG_INFO(Input, "Tag detected, type={}, uuid={}", data.type, uuid_string);
tries = 0; tries = 0;
std::size_t ntag_pages = 0; NFCPages ntag_pages = NFCPages::Block0;
// Read Tag data // Read Tag data
loop1:
while (true) { while (true) {
auto result = SendReadAmiiboRequest(output, ntag_pages); auto result = SendReadAmiiboRequest(output, ntag_pages);
const auto mcu_report = static_cast<MCUReport>(output[49]);
int attempt = 0; const auto nfc_status = static_cast<NFCStatus>(output[56]);
while (true) {
if (attempt != 0) {
result = GetMCUDataResponse(ReportMode::NFC_IR_MODE_60HZ, output);
}
if ((output[49] == 0x3a || output[49] == 0x2a) && output[56] == 0x07) {
return DriverResult::ErrorReadingData;
}
if (output[49] == 0x3a && output[51] == 0x07 && output[52] == 0x01) {
if (data.type != 2) {
goto loop1;
}
switch (output[74]) {
case 0:
ntag_pages = 135;
break;
case 3:
ntag_pages = 45;
break;
case 4:
ntag_pages = 231;
break;
default:
return DriverResult::ErrorReadingData;
}
goto loop1;
}
if (output[49] == 0x2a && output[56] == 0x04) {
// finished
SendStopPollingRequest(output);
return DriverResult::Success;
}
if (output[49] == 0x2a) {
goto loop1;
}
if (attempt++ > 6) {
goto loop1;
}
}
if (result != DriverResult::Success) { if (result != DriverResult::Success) {
return result; return result;
} }
if ((mcu_report == MCUReport::NFCReadData || mcu_report == MCUReport::NFCState) &&
nfc_status == NFCStatus::TagLost) {
return DriverResult::ErrorReadingData;
}
if (mcu_report == MCUReport::NFCReadData && output[51] == 0x07 && output[52] == 0x01) {
if (data.type != 2) {
continue;
}
switch (output[74]) {
case 0:
ntag_pages = NFCPages::Block135;
break;
case 3:
ntag_pages = NFCPages::Block45;
break;
case 4:
ntag_pages = NFCPages::Block231;
break;
default:
return DriverResult::ErrorReadingData;
}
continue;
}
if (mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::LastPackage) {
// finished
SendStopPollingRequest(output);
return DriverResult::Success;
}
// Ignore other state reports
if (mcu_report == MCUReport::NFCState) {
continue;
}
if (tries++ > timeout_limit) { if (tries++ > timeout_limit) {
return DriverResult::Timeout; return DriverResult::Timeout;
} }
@ -226,47 +224,44 @@ DriverResult NfcProtocol::GetAmiiboData(std::vector<u8>& ntag_data) {
std::vector<u8> output; std::vector<u8> output;
std::size_t tries = 0; std::size_t tries = 0;
std::size_t ntag_pages = 135; NFCPages ntag_pages = NFCPages::Block135;
std::size_t ntag_buffer_pos = 0; std::size_t ntag_buffer_pos = 0;
// Read Tag data // Read Tag data
loop1:
while (true) { while (true) {
auto result = SendReadAmiiboRequest(output, ntag_pages); auto result = SendReadAmiiboRequest(output, ntag_pages);
const auto mcu_report = static_cast<MCUReport>(output[49]);
int attempt = 0; const auto nfc_status = static_cast<NFCStatus>(output[56]);
while (1) {
if (attempt != 0) {
result = GetMCUDataResponse(ReportMode::NFC_IR_MODE_60HZ, output);
}
if ((output[49] == 0x3a || output[49] == 0x2a) && output[56] == 0x07) {
return DriverResult::ErrorReadingData;
}
if (output[49] == 0x3a && output[51] == 0x07) {
std::size_t payload_size = (output[54] << 8 | output[55]) & 0x7FF;
if (output[52] == 0x01) {
memcpy(ntag_data.data() + ntag_buffer_pos, output.data() + 116,
payload_size - 60);
ntag_buffer_pos += payload_size - 60;
} else {
memcpy(ntag_data.data() + ntag_buffer_pos, output.data() + 56, payload_size);
}
goto loop1;
}
if (output[49] == 0x2a && output[56] == 0x04) {
LOG_INFO(Input, "Finished reading amiibo");
return DriverResult::Success;
}
if (output[49] == 0x2a) {
goto loop1;
}
if (attempt++ > 4) {
goto loop1;
}
}
if (result != DriverResult::Success) { if (result != DriverResult::Success) {
return result; return result;
} }
if ((mcu_report == MCUReport::NFCReadData || mcu_report == MCUReport::NFCState) &&
nfc_status == NFCStatus::TagLost) {
return DriverResult::ErrorReadingData;
}
if (mcu_report == MCUReport::NFCReadData && output[51] == 0x07) {
std::size_t payload_size = (output[54] << 8 | output[55]) & 0x7FF;
if (output[52] == 0x01) {
memcpy(ntag_data.data() + ntag_buffer_pos, output.data() + 116, payload_size - 60);
ntag_buffer_pos += payload_size - 60;
} else {
memcpy(ntag_data.data() + ntag_buffer_pos, output.data() + 56, payload_size);
}
continue;
}
if (mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::LastPackage) {
LOG_INFO(Input, "Finished reading amiibo");
return DriverResult::Success;
}
// Ignore other state reports
if (mcu_report == MCUReport::NFCState) {
continue;
}
if (tries++ > timeout_limit) { if (tries++ > timeout_limit) {
return DriverResult::Timeout; return DriverResult::Timeout;
} }
@ -333,7 +328,7 @@ DriverResult NfcProtocol::SendStartWaitingRecieveRequest(std::vector<u8>& output
return SendMCUData(ReportMode::NFC_IR_MODE_60HZ, SubCommand::STATE, request_data, output); return SendMCUData(ReportMode::NFC_IR_MODE_60HZ, SubCommand::STATE, request_data, output);
} }
DriverResult NfcProtocol::SendReadAmiiboRequest(std::vector<u8>& output, std::size_t ntag_pages) { DriverResult NfcProtocol::SendReadAmiiboRequest(std::vector<u8>& output, NFCPages ntag_pages) {
NFCRequestState request{ NFCRequestState request{
.sub_command = MCUSubCommand::ReadDeviceMode, .sub_command = MCUSubCommand::ReadDeviceMode,
.command_argument = NFCReadCommand::Ntag, .command_argument = NFCReadCommand::Ntag,
@ -358,13 +353,13 @@ DriverResult NfcProtocol::SendReadAmiiboRequest(std::vector<u8>& output, std::si
return SendMCUData(ReportMode::NFC_IR_MODE_60HZ, SubCommand::STATE, request_data, output); return SendMCUData(ReportMode::NFC_IR_MODE_60HZ, SubCommand::STATE, request_data, output);
} }
NFCReadBlockCommand NfcProtocol::GetReadBlockCommand(std::size_t pages) const { NFCReadBlockCommand NfcProtocol::GetReadBlockCommand(NFCPages pages) const {
switch (static_cast<NFCBlock>(pages)) { switch (pages) {
case NFCBlock::Block0: case NFCPages::Block0:
return { return {
.block_count = 1, .block_count = 1,
}; };
case NFCBlock::Block45: case NFCPages::Block45:
return { return {
.block_count = 1, .block_count = 1,
.blocks = .blocks =
@ -372,7 +367,7 @@ NFCReadBlockCommand NfcProtocol::GetReadBlockCommand(std::size_t pages) const {
NFCReadBlock{0x00, 0x2C}, NFCReadBlock{0x00, 0x2C},
}, },
}; };
case NFCBlock::Block135: case NFCPages::Block135:
return { return {
.block_count = 3, .block_count = 3,
.blocks = .blocks =
@ -382,7 +377,7 @@ NFCReadBlockCommand NfcProtocol::GetReadBlockCommand(std::size_t pages) const {
{0x78, 0x86}, {0x78, 0x86},
}, },
}; };
case NFCBlock::Block231: case NFCPages::Block231:
return { return {
.block_count = 4, .block_count = 4,
.blocks = .blocks =

View file

@ -51,9 +51,9 @@ private:
DriverResult SendStartWaitingRecieveRequest(std::vector<u8>& output); DriverResult SendStartWaitingRecieveRequest(std::vector<u8>& output);
DriverResult SendReadAmiiboRequest(std::vector<u8>& output, std::size_t ntag_pages); DriverResult SendReadAmiiboRequest(std::vector<u8>& output, NFCPages ntag_pages);
NFCReadBlockCommand GetReadBlockCommand(std::size_t pages) const; NFCReadBlockCommand GetReadBlockCommand(NFCPages pages) const;
bool is_enabled{}; bool is_enabled{};
}; };

View file

@ -70,28 +70,28 @@ const std::array<int, 2> Config::default_ringcon_analogs{{
// UISetting::values.shortcuts, which is alphabetically ordered. // UISetting::values.shortcuts, which is alphabetically ordered.
// clang-format off // clang-format off
const std::array<UISettings::Shortcut, 22> Config::default_hotkeys{{ const std::array<UISettings::Shortcut, 22> Config::default_hotkeys{{
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Mute/Unmute")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Mute/Unmute")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Down")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Down")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut, true}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Up")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("="), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Up")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("="), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut, true}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Capture Screenshot")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Capture Screenshot")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Adapting Filter")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F8"), QStringLiteral("Home+L"), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Adapting Filter")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F8"), QStringLiteral("Home+L"), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Docked Mode")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Docked Mode")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change GPU Accuracy")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F9"), QStringLiteral("Home+R"), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change GPU Accuracy")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F9"), QStringLiteral("Home+R"), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Continue/Pause Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Continue/Pause Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit Fullscreen")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit Fullscreen")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit yuzu")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit yuzu")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Fullscreen")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F11"), QStringLiteral("Home+B"), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Fullscreen")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F11"), QStringLiteral("Home+B"), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load File")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load File")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load/Remove Amiibo")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load/Remove Amiibo")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F5"), QStringLiteral(""), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F5"), QStringLiteral(""), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Record")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F7"), QStringLiteral(""), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Record")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F7"), QStringLiteral(""), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Reset")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F6"), QStringLiteral(""), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Reset")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F6"), QStringLiteral(""), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Start/Stop")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F5"), QStringLiteral(""), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Start/Stop")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F5"), QStringLiteral(""), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Filter Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Filter Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Framerate Limit")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Framerate Limit")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Mouse Panning")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Mouse Panning")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut, false}},
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Status Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Status Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut, false}},
}}; }};
// clang-format on // clang-format on
@ -748,7 +748,7 @@ void Config::ReadShortcutValues() {
for (const auto& [name, group, shortcut] : default_hotkeys) { for (const auto& [name, group, shortcut] : default_hotkeys) {
qt_config->beginGroup(group); qt_config->beginGroup(group);
qt_config->beginGroup(name); qt_config->beginGroup(name);
// No longer using ReadSetting for shortcut.second as it innacurately returns a value of 1 // No longer using ReadSetting for shortcut.second as it inaccurately returns a value of 1
// for WidgetWithChildrenShortcut which is a value of 3. Needed to fix shortcuts the open // for WidgetWithChildrenShortcut which is a value of 3. Needed to fix shortcuts the open
// a file dialog in windowed mode // a file dialog in windowed mode
UISettings::values.shortcuts.push_back( UISettings::values.shortcuts.push_back(
@ -757,7 +757,7 @@ void Config::ReadShortcutValues() {
{ReadSetting(QStringLiteral("KeySeq"), shortcut.keyseq).toString(), {ReadSetting(QStringLiteral("KeySeq"), shortcut.keyseq).toString(),
ReadSetting(QStringLiteral("Controller_KeySeq"), shortcut.controller_keyseq) ReadSetting(QStringLiteral("Controller_KeySeq"), shortcut.controller_keyseq)
.toString(), .toString(),
shortcut.context}}); shortcut.context, ReadSetting(QStringLiteral("Repeat"), shortcut.repeat).toBool()}});
qt_config->endGroup(); qt_config->endGroup();
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1395,6 +1395,7 @@ void Config::SaveShortcutValues() {
WriteSetting(QStringLiteral("Controller_KeySeq"), shortcut.controller_keyseq, WriteSetting(QStringLiteral("Controller_KeySeq"), shortcut.controller_keyseq,
default_hotkey.controller_keyseq); default_hotkey.controller_keyseq);
WriteSetting(QStringLiteral("Context"), shortcut.context, default_hotkey.context); WriteSetting(QStringLiteral("Context"), shortcut.context, default_hotkey.context);
WriteSetting(QStringLiteral("Repeat"), shortcut.repeat, default_hotkey.repeat);
qt_config->endGroup(); qt_config->endGroup();
qt_config->endGroup(); qt_config->endGroup();
} }

View file

@ -21,7 +21,7 @@ void HotkeyRegistry::SaveHotkeys() {
{hotkey.first, group.first, {hotkey.first, group.first,
UISettings::ContextualShortcut({hotkey.second.keyseq.toString(), UISettings::ContextualShortcut({hotkey.second.keyseq.toString(),
hotkey.second.controller_keyseq, hotkey.second.controller_keyseq,
hotkey.second.context})}); hotkey.second.context, hotkey.second.repeat})});
} }
} }
} }
@ -47,6 +47,7 @@ void HotkeyRegistry::LoadHotkeys() {
hk.controller_shortcut->disconnect(); hk.controller_shortcut->disconnect();
hk.controller_shortcut->SetKey(hk.controller_keyseq); hk.controller_shortcut->SetKey(hk.controller_keyseq);
} }
hk.repeat = shortcut.shortcut.repeat;
} }
} }
@ -57,8 +58,7 @@ QShortcut* HotkeyRegistry::GetHotkey(const QString& group, const QString& action
hk.shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context); hk.shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context);
} }
hk.shortcut->setAutoRepeat(false); hk.shortcut->setAutoRepeat(hk.repeat);
return hk.shortcut; return hk.shortcut;
} }

View file

@ -115,6 +115,7 @@ private:
QShortcut* shortcut = nullptr; QShortcut* shortcut = nullptr;
ControllerShortcut* controller_shortcut = nullptr; ControllerShortcut* controller_shortcut = nullptr;
Qt::ShortcutContext context = Qt::WindowShortcut; Qt::ShortcutContext context = Qt::WindowShortcut;
bool repeat;
}; };
using HotkeyMap = std::map<QString, Hotkey>; using HotkeyMap = std::map<QString, Hotkey>;

View file

@ -22,6 +22,7 @@ struct ContextualShortcut {
QString keyseq; QString keyseq;
QString controller_keyseq; QString controller_keyseq;
int context; int context;
bool repeat;
}; };
struct Shortcut { struct Shortcut {