Compare commits
33 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bf422d58c | ||
|
|
4fa3511a63 | ||
|
|
7139f05fc5 | ||
|
|
b9829a05be | ||
|
|
7ed8565978 | ||
|
|
6576bc8927 | ||
|
|
2d57cbaec1 | ||
|
|
3242e7c164 | ||
|
|
c707240685 | ||
|
|
573a66c23d | ||
|
|
97c6f984dc | ||
|
|
07595987ac | ||
|
|
b09c4f45c7 | ||
|
|
bc6d91a103 | ||
|
|
c392650e21 | ||
|
|
8f73f41824 | ||
|
|
c4397ec77e | ||
|
|
438d9aa407 | ||
|
|
3e81c09094 | ||
|
|
d3f64785d1 | ||
|
|
300ab211e8 | ||
|
|
fa8017295b | ||
|
|
e40b0cf437 | ||
|
|
7e49881b7f | ||
|
|
0f5c4615ae | ||
|
|
890e543304 | ||
|
|
20c976ff2a | ||
|
|
45bc449ff9 | ||
|
|
c8f6754417 | ||
|
|
0db0e4c8f3 | ||
|
|
da2f00ab7d | ||
|
|
e3321c2e00 | ||
|
|
2cc962e171 |
4
externals/CMakeLists.txt
vendored
4
externals/CMakeLists.txt
vendored
@@ -36,7 +36,7 @@ add_subdirectory(lz4/contrib/cmake_unofficial)
|
||||
target_include_directories(lz4_static INTERFACE ./lz4/lib)
|
||||
|
||||
# mbedtls
|
||||
add_subdirectory(mbedtls)
|
||||
add_subdirectory(mbedtls EXCLUDE_FROM_ALL)
|
||||
target_include_directories(mbedtls PUBLIC ./mbedtls/include)
|
||||
|
||||
# MicroProfile
|
||||
@@ -62,5 +62,5 @@ target_include_directories(opus INTERFACE ./opus/include)
|
||||
# Cubeb
|
||||
if(ENABLE_CUBEB)
|
||||
set(BUILD_TESTS OFF CACHE BOOL "")
|
||||
add_subdirectory(cubeb)
|
||||
add_subdirectory(cubeb EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
23
externals/glad/include/glad/glad.h
vendored
23
externals/glad/include/glad/glad.h
vendored
File diff suppressed because one or more lines are too long
6385
externals/glad/src/glad.c
vendored
6385
externals/glad/src/glad.c
vendored
File diff suppressed because one or more lines are too long
2
externals/mbedtls
vendored
2
externals/mbedtls
vendored
Submodule externals/mbedtls updated: 06442b840e...06b1b55434
@@ -4,8 +4,6 @@ add_library(audio_core STATIC
|
||||
audio_renderer.cpp
|
||||
audio_renderer.h
|
||||
buffer.h
|
||||
cubeb_sink.cpp
|
||||
cubeb_sink.h
|
||||
codec.cpp
|
||||
codec.h
|
||||
null_sink.h
|
||||
@@ -15,6 +13,8 @@ add_library(audio_core STATIC
|
||||
sink_details.cpp
|
||||
sink_details.h
|
||||
sink_stream.h
|
||||
|
||||
$<$<BOOL:${ENABLE_CUBEB}>:cubeb_sink.cpp cubeb_sink.h>
|
||||
)
|
||||
|
||||
create_target_directory_groups(audio_core)
|
||||
|
||||
@@ -200,6 +200,7 @@ void FileBackend::Write(const Entry& entry) {
|
||||
SUB(Service, SPL) \
|
||||
SUB(Service, SSL) \
|
||||
SUB(Service, Time) \
|
||||
SUB(Service, USB) \
|
||||
SUB(Service, VI) \
|
||||
SUB(Service, WLAN) \
|
||||
CLS(HW) \
|
||||
|
||||
@@ -87,6 +87,7 @@ enum class Class : ClassType {
|
||||
Service_SPL, ///< The SPL service
|
||||
Service_SSL, ///< The SSL service
|
||||
Service_Time, ///< The time service
|
||||
Service_USB, ///< The USB (Universal Serial Bus) service
|
||||
Service_VI, ///< The VI (Video interface) service
|
||||
Service_WLAN, ///< The WLAN (Wireless local area network) service
|
||||
HW, ///< Low-level hardware emulation
|
||||
|
||||
@@ -315,6 +315,8 @@ add_library(core STATIC
|
||||
hle/service/time/interface.h
|
||||
hle/service/time/time.cpp
|
||||
hle/service/time/time.h
|
||||
hle/service/usb/usb.cpp
|
||||
hle/service/usb/usb.h
|
||||
hle/service/vi/vi.cpp
|
||||
hle/service/vi/vi.h
|
||||
hle/service/vi/vi_m.cpp
|
||||
|
||||
@@ -76,12 +76,17 @@ bool IsValidNCA(const NCAHeader& header) {
|
||||
return header.magic == Common::MakeMagic('N', 'C', 'A', '3');
|
||||
}
|
||||
|
||||
boost::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType type) const {
|
||||
u8 NCA::GetCryptoRevision() const {
|
||||
u8 master_key_id = header.crypto_type;
|
||||
if (header.crypto_type_2 > master_key_id)
|
||||
master_key_id = header.crypto_type_2;
|
||||
if (master_key_id > 0)
|
||||
--master_key_id;
|
||||
return master_key_id;
|
||||
}
|
||||
|
||||
boost::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType type) const {
|
||||
const auto master_key_id = GetCryptoRevision();
|
||||
|
||||
if (!keys.HasKey(Core::Crypto::S128KeyType::KeyArea, master_key_id, header.key_index))
|
||||
return boost::none;
|
||||
@@ -108,33 +113,58 @@ boost::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType ty
|
||||
return out;
|
||||
}
|
||||
|
||||
VirtualFile NCA::Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) const {
|
||||
boost::optional<Core::Crypto::Key128> NCA::GetTitlekey() const {
|
||||
const auto master_key_id = GetCryptoRevision();
|
||||
|
||||
u128 rights_id{};
|
||||
memcpy(rights_id.data(), header.rights_id.data(), 16);
|
||||
if (rights_id == u128{})
|
||||
return boost::none;
|
||||
|
||||
auto titlekey = keys.GetKey(Core::Crypto::S128KeyType::Titlekey, rights_id[1], rights_id[0]);
|
||||
if (titlekey == Core::Crypto::Key128{})
|
||||
return boost::none;
|
||||
Core::Crypto::AESCipher<Core::Crypto::Key128> cipher(
|
||||
keys.GetKey(Core::Crypto::S128KeyType::Titlekek, master_key_id), Core::Crypto::Mode::ECB);
|
||||
cipher.Transcode(titlekey.data(), titlekey.size(), titlekey.data(), Core::Crypto::Op::Decrypt);
|
||||
|
||||
return titlekey;
|
||||
}
|
||||
|
||||
VirtualFile NCA::Decrypt(NCASectionHeader s_header, VirtualFile in, u64 starting_offset) const {
|
||||
if (!encrypted)
|
||||
return in;
|
||||
|
||||
switch (header.raw.header.crypto_type) {
|
||||
switch (s_header.raw.header.crypto_type) {
|
||||
case NCASectionCryptoType::NONE:
|
||||
LOG_DEBUG(Crypto, "called with mode=NONE");
|
||||
return in;
|
||||
case NCASectionCryptoType::CTR:
|
||||
LOG_DEBUG(Crypto, "called with mode=CTR, starting_offset={:016X}", starting_offset);
|
||||
{
|
||||
const auto key = GetKeyAreaKey(NCASectionCryptoType::CTR);
|
||||
boost::optional<Core::Crypto::Key128> key = boost::none;
|
||||
if (std::find_if_not(header.rights_id.begin(), header.rights_id.end(),
|
||||
[](char c) { return c == 0; }) == header.rights_id.end()) {
|
||||
key = GetKeyAreaKey(NCASectionCryptoType::CTR);
|
||||
} else {
|
||||
key = GetTitlekey();
|
||||
}
|
||||
|
||||
if (key == boost::none)
|
||||
return nullptr;
|
||||
auto out = std::make_shared<Core::Crypto::CTREncryptionLayer>(
|
||||
std::move(in), key.value(), starting_offset);
|
||||
std::vector<u8> iv(16);
|
||||
for (u8 i = 0; i < 8; ++i)
|
||||
iv[i] = header.raw.section_ctr[0x8 - i - 1];
|
||||
iv[i] = s_header.raw.section_ctr[0x8 - i - 1];
|
||||
out->SetIV(iv);
|
||||
return std::static_pointer_cast<VfsFile>(out);
|
||||
}
|
||||
case NCASectionCryptoType::XTS:
|
||||
// TODO(DarkLordZach): Implement XTSEncryptionLayer and title key encryption.
|
||||
// TODO(DarkLordZach): Implement XTSEncryptionLayer.
|
||||
default:
|
||||
LOG_ERROR(Crypto, "called with unhandled crypto type={:02X}",
|
||||
static_cast<u8>(header.raw.header.crypto_type));
|
||||
static_cast<u8>(s_header.raw.header.crypto_type));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,9 @@ protected:
|
||||
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
|
||||
|
||||
private:
|
||||
u8 GetCryptoRevision() const;
|
||||
boost::optional<Core::Crypto::Key128> GetKeyAreaKey(NCASectionCryptoType type) const;
|
||||
boost::optional<Core::Crypto::Key128> GetTitlekey() const;
|
||||
VirtualFile Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) const;
|
||||
|
||||
std::vector<VirtualDir> dirs;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
ClientPort::ClientPort() {}
|
||||
ClientPort::~ClientPort() {}
|
||||
ClientPort::ClientPort() = default;
|
||||
ClientPort::~ClientPort() = default;
|
||||
|
||||
ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
|
||||
// Note: Threads do not wait for the server endpoint to call
|
||||
@@ -40,4 +40,12 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
|
||||
return MakeResult(std::get<SharedPtr<ClientSession>>(sessions));
|
||||
}
|
||||
|
||||
void ClientPort::ConnectionClosed() {
|
||||
if (active_sessions == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
--active_sessions;
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
||||
@@ -37,14 +37,20 @@ public:
|
||||
*/
|
||||
ResultVal<SharedPtr<ClientSession>> Connect();
|
||||
|
||||
SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
|
||||
u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have
|
||||
u32 active_sessions; ///< Number of currently open sessions to this port
|
||||
std::string name; ///< Name of client port (optional)
|
||||
/**
|
||||
* Signifies that a previously active connection has been closed,
|
||||
* decreasing the total number of active connections to this port.
|
||||
*/
|
||||
void ConnectionClosed();
|
||||
|
||||
private:
|
||||
ClientPort();
|
||||
~ClientPort() override;
|
||||
|
||||
SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
|
||||
u32 max_sessions = 0; ///< Maximum number of simultaneous sessions the port can have
|
||||
u32 active_sessions = 0; ///< Number of currently open sessions to this port
|
||||
std::string name; ///< Name of client port (optional)
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
||||
@@ -27,7 +27,7 @@ ServerSession::~ServerSession() {
|
||||
|
||||
// Decrease the port's connection count.
|
||||
if (parent->port)
|
||||
parent->port->active_sessions--;
|
||||
parent->port->ConnectionClosed();
|
||||
|
||||
// TODO(Subv): Wake up all the ClientSession's waiting threads and set
|
||||
// the SendSyncRequest result to 0xC920181A.
|
||||
|
||||
@@ -337,6 +337,7 @@ public:
|
||||
"AcquireNpadStyleSetUpdateEventHandle"},
|
||||
{107, nullptr, "DisconnectNpad"},
|
||||
{108, &Hid::GetPlayerLedPattern, "GetPlayerLedPattern"},
|
||||
{109, nullptr, "ActivateNpadWithRevision"},
|
||||
{120, &Hid::SetNpadJoyHoldType, "SetNpadJoyHoldType"},
|
||||
{121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
|
||||
{122, &Hid::SetNpadJoyAssignmentModeSingleByDefault,
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvmap.h"
|
||||
#include "video_core/gpu.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace Service::Nvidia::Devices {
|
||||
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvmap.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace Service::Nvidia::Devices {
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_ctrl.h"
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h"
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cinttypes>
|
||||
#include <map>
|
||||
#include <cstring>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_gpu.h"
|
||||
#include "core/memory.h"
|
||||
#include "video_core/gpu.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
|
||||
namespace Service::Nvidia::Devices {
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_nvdec.h"
|
||||
|
||||
@@ -4,11 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
|
||||
namespace Service::Nvidia::Devices {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
@@ -54,7 +54,7 @@ u32 Module::Open(const std::string& device_name) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
u32 Module::Ioctl(u32 fd, u32_le command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
u32 Module::Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
auto itr = open_files.find(fd);
|
||||
ASSERT_MSG(itr != open_files.end(), "Tried to talk to an invalid device");
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||
#include "core/hle/service/nvdrv/nvmemp.h"
|
||||
|
||||
namespace Service::Nvidia {
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "common/alignment.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
@@ -31,7 +34,7 @@ NVFlinger::NVFlinger() {
|
||||
|
||||
// Schedule the screen composition events
|
||||
composition_event =
|
||||
CoreTiming::RegisterEvent("ScreenCompositioin", [this](u64 userdata, int cycles_late) {
|
||||
CoreTiming::RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) {
|
||||
Compose();
|
||||
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, composition_event);
|
||||
});
|
||||
@@ -43,7 +46,7 @@ NVFlinger::~NVFlinger() {
|
||||
CoreTiming::UnscheduleEvent(composition_event, 0);
|
||||
}
|
||||
|
||||
u64 NVFlinger::OpenDisplay(const std::string& name) {
|
||||
u64 NVFlinger::OpenDisplay(std::string_view name) {
|
||||
LOG_WARNING(Service, "Opening display {}", name);
|
||||
|
||||
// TODO(Subv): Currently we only support the Default display.
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <boost/optional.hpp>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
|
||||
namespace CoreTiming {
|
||||
@@ -41,7 +45,7 @@ public:
|
||||
~NVFlinger();
|
||||
|
||||
/// Opens the specified display and returns the id.
|
||||
u64 OpenDisplay(const std::string& name);
|
||||
u64 OpenDisplay(std::string_view name);
|
||||
|
||||
/// Creates a layer on the specified display and returns the layer id.
|
||||
u64 CreateLayer(u64 display_id);
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "core/hle/service/spl/module.h"
|
||||
#include "core/hle/service/ssl/ssl.h"
|
||||
#include "core/hle/service/time/time.h"
|
||||
#include "core/hle/service/usb/usb.h"
|
||||
#include "core/hle/service/vi/vi.h"
|
||||
#include "core/hle/service/wlan/wlan.h"
|
||||
|
||||
@@ -249,6 +250,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {
|
||||
SPL::InstallInterfaces(*sm);
|
||||
SSL::InstallInterfaces(*sm);
|
||||
Time::InstallInterfaces(*sm);
|
||||
USB::InstallInterfaces(*sm);
|
||||
VI::InstallInterfaces(*sm, nv_flinger);
|
||||
WLAN::InstallInterfaces(*sm);
|
||||
|
||||
|
||||
@@ -80,8 +80,8 @@ public:
|
||||
{5, nullptr, "GetTimeZoneRuleVersion"},
|
||||
{100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"},
|
||||
{101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
|
||||
{200, nullptr, "ToPosixTime"},
|
||||
{201, nullptr, "ToPosixTimeWithMyRule"},
|
||||
{201, nullptr, "ToPosixTime"},
|
||||
{202, nullptr, "ToPosixTimeWithMyRule"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
238
src/core/hle/service/usb/usb.cpp
Normal file
238
src/core/hle/service/usb/usb.cpp
Normal file
@@ -0,0 +1,238 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/hle_ipc.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
#include "core/hle/service/usb/usb.h"
|
||||
|
||||
namespace Service::USB {
|
||||
|
||||
class IDsInterface final : public ServiceFramework<IDsInterface> {
|
||||
public:
|
||||
explicit IDsInterface() : ServiceFramework{"IDsInterface"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetDsEndpoint"},
|
||||
{1, nullptr, "GetSetupEvent"},
|
||||
{2, nullptr, "Unknown"},
|
||||
{3, nullptr, "EnableInterface"},
|
||||
{4, nullptr, "DisableInterface"},
|
||||
{5, nullptr, "CtrlInPostBufferAsync"},
|
||||
{6, nullptr, "CtrlOutPostBufferAsync"},
|
||||
{7, nullptr, "GetCtrlInCompletionEvent"},
|
||||
{8, nullptr, "GetCtrlInReportData"},
|
||||
{9, nullptr, "GetCtrlOutCompletionEvent"},
|
||||
{10, nullptr, "GetCtrlOutReportData"},
|
||||
{11, nullptr, "StallCtrl"},
|
||||
{12, nullptr, "AppendConfigurationData"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
class USB_DS final : public ServiceFramework<USB_DS> {
|
||||
public:
|
||||
explicit USB_DS() : ServiceFramework{"usb:ds"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "BindDevice"},
|
||||
{1, nullptr, "BindClientProcess"},
|
||||
{2, nullptr, "GetDsInterface"},
|
||||
{3, nullptr, "GetStateChangeEvent"},
|
||||
{4, nullptr, "GetState"},
|
||||
{5, nullptr, "ClearDeviceData"},
|
||||
{6, nullptr, "AddUsbStringDescriptor"},
|
||||
{7, nullptr, "DeleteUsbStringDescriptor"},
|
||||
{8, nullptr, "SetUsbDeviceDescriptor"},
|
||||
{9, nullptr, "SetBinaryObjectStore"},
|
||||
{10, nullptr, "Enable"},
|
||||
{11, nullptr, "Disable"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
class IClientEpSession final : public ServiceFramework<IClientEpSession> {
|
||||
public:
|
||||
explicit IClientEpSession() : ServiceFramework{"IClientEpSession"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "Unknown1"},
|
||||
{1, nullptr, "Unknown2"},
|
||||
{2, nullptr, "Unknown3"},
|
||||
{3, nullptr, "Unknown4"},
|
||||
{4, nullptr, "PostBufferAsync"},
|
||||
{5, nullptr, "Unknown5"},
|
||||
{6, nullptr, "Unknown6"},
|
||||
{7, nullptr, "Unknown7"},
|
||||
{8, nullptr, "Unknown8"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
class IClientIfSession final : public ServiceFramework<IClientIfSession> {
|
||||
public:
|
||||
explicit IClientIfSession() : ServiceFramework{"IClientIfSession"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "Unknown1"},
|
||||
{1, nullptr, "Unknown2"},
|
||||
{2, nullptr, "Unknown3"},
|
||||
{3, nullptr, "Unknown4"},
|
||||
{4, nullptr, "Unknown5"},
|
||||
{5, nullptr, "CtrlXferAsync"},
|
||||
{6, nullptr, "Unknown6"},
|
||||
{7, nullptr, "GetCtrlXferReport"},
|
||||
{8, nullptr, "Unknown7"},
|
||||
{9, nullptr, "GetClientEpSession"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
class USB_HS final : public ServiceFramework<USB_HS> {
|
||||
public:
|
||||
explicit USB_HS() : ServiceFramework{"usb:hs"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "BindClientProcess"},
|
||||
{1, nullptr, "Unknown1"},
|
||||
{2, nullptr, "Unknown2"},
|
||||
{3, nullptr, "Unknown3"},
|
||||
{4, nullptr, "Unknown4"},
|
||||
{5, nullptr, "Unknown5"},
|
||||
{6, nullptr, "GetInterfaceStateChangeEvent"},
|
||||
{7, nullptr, "GetClientIfSession"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
class IPdSession final : public ServiceFramework<IPdSession> {
|
||||
public:
|
||||
explicit IPdSession() : ServiceFramework{"IPdSession"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "BindNoticeEvent"},
|
||||
{1, nullptr, "Unknown1"},
|
||||
{2, nullptr, "GetStatus"},
|
||||
{3, nullptr, "GetNotice"},
|
||||
{4, nullptr, "Unknown2"},
|
||||
{5, nullptr, "Unknown3"},
|
||||
{6, nullptr, "ReplyPowerRequest"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
class USB_PD final : public ServiceFramework<USB_PD> {
|
||||
public:
|
||||
explicit USB_PD() : ServiceFramework{"usb:pd"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &USB_PD::GetPdSession, "GetPdSession"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void GetPdSession(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IPdSession>();
|
||||
|
||||
LOG_DEBUG(Service_USB, "called");
|
||||
}
|
||||
};
|
||||
|
||||
class IPdCradleSession final : public ServiceFramework<IPdCradleSession> {
|
||||
public:
|
||||
explicit IPdCradleSession() : ServiceFramework{"IPdCradleSession"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "VdmUserWrite"},
|
||||
{1, nullptr, "VdmUserRead"},
|
||||
{2, nullptr, "Vdm20Init"},
|
||||
{3, nullptr, "GetFwType"},
|
||||
{4, nullptr, "GetFwRevision"},
|
||||
{5, nullptr, "GetManufacturerId"},
|
||||
{6, nullptr, "GetDeviceId"},
|
||||
{7, nullptr, "Unknown1"},
|
||||
{8, nullptr, "Unknown2"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
class USB_PD_C final : public ServiceFramework<USB_PD_C> {
|
||||
public:
|
||||
explicit USB_PD_C() : ServiceFramework{"usb:pd:c"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &USB_PD_C::GetPdCradleSession, "GetPdCradleSession"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void GetPdCradleSession(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IPdCradleSession>();
|
||||
|
||||
LOG_DEBUG(Service_USB, "called");
|
||||
}
|
||||
};
|
||||
|
||||
class USB_PM final : public ServiceFramework<USB_PM> {
|
||||
public:
|
||||
explicit USB_PM() : ServiceFramework{"usb:pm"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "Unknown1"},
|
||||
{1, nullptr, "Unknown2"},
|
||||
{2, nullptr, "Unknown3"},
|
||||
{3, nullptr, "Unknown4"},
|
||||
{4, nullptr, "Unknown5"},
|
||||
{5, nullptr, "Unknown6"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
};
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& sm) {
|
||||
std::make_shared<USB_DS>()->InstallAsService(sm);
|
||||
std::make_shared<USB_HS>()->InstallAsService(sm);
|
||||
std::make_shared<USB_PD>()->InstallAsService(sm);
|
||||
std::make_shared<USB_PD_C>()->InstallAsService(sm);
|
||||
std::make_shared<USB_PM>()->InstallAsService(sm);
|
||||
}
|
||||
|
||||
} // namespace Service::USB
|
||||
15
src/core/hle/service/usb/usb.h
Normal file
15
src/core/hle/service/usb/usb.h
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Service::SM {
|
||||
class ServiceManager;
|
||||
}
|
||||
|
||||
namespace Service::USB {
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& sm);
|
||||
|
||||
} // namespace Service::USB
|
||||
@@ -41,7 +41,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
|
||||
if (dir == nullptr) {
|
||||
if (file == nullptr)
|
||||
return ResultStatus::ErrorInvalidFormat;
|
||||
const FileSys::VirtualDir dir = file->GetContainingDirectory();
|
||||
dir = file->GetContainingDirectory();
|
||||
}
|
||||
|
||||
const FileSys::VirtualFile npdm = dir->GetFile("main.npdm");
|
||||
|
||||
@@ -29,10 +29,10 @@ enum class BufferMethods {
|
||||
};
|
||||
|
||||
void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) {
|
||||
LOG_WARNING(HW_GPU,
|
||||
"Processing method {:08X} on subchannel {} value "
|
||||
"{:08X} remaining params {}",
|
||||
method, subchannel, value, remaining_params);
|
||||
LOG_TRACE(HW_GPU,
|
||||
"Processing method {:08X} on subchannel {} value "
|
||||
"{:08X} remaining params {}",
|
||||
method, subchannel, value, remaining_params);
|
||||
|
||||
if (method == static_cast<u32>(BufferMethods::BindObject)) {
|
||||
// Bind the current subchannel to the desired engine id.
|
||||
|
||||
@@ -42,6 +42,7 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
|
||||
case RenderTargetFormat::RGB10_A2_UNORM:
|
||||
case RenderTargetFormat::BGRA8_UNORM:
|
||||
case RenderTargetFormat::R32_FLOAT:
|
||||
case RenderTargetFormat::R11G11B10_FLOAT:
|
||||
return 4;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format));
|
||||
|
||||
@@ -204,8 +204,9 @@ struct SurfaceParams {
|
||||
|
||||
static PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) {
|
||||
switch (format) {
|
||||
// TODO (Hexagon12): Converting SRGBA to RGBA is a hack and doesn't completely correct the
|
||||
// gamma.
|
||||
case Tegra::RenderTargetFormat::RGBA8_SRGB:
|
||||
return PixelFormat::SRGBA8;
|
||||
case Tegra::RenderTargetFormat::RGBA8_UNORM:
|
||||
return PixelFormat::ABGR8;
|
||||
case Tegra::RenderTargetFormat::BGRA8_UNORM:
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
#include "ui_configure.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
#include "yuzu/configuration/configure_dialog.h"
|
||||
#include "yuzu/hotkeys.h"
|
||||
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ConfigureDialog) {
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, const HotkeyRegistry& registry)
|
||||
: QDialog(parent), ui(new Ui::ConfigureDialog) {
|
||||
ui->setupUi(this);
|
||||
ui->generalTab->PopulateHotkeyList(registry);
|
||||
this->setConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
|
||||
class HotkeyRegistry;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureDialog;
|
||||
}
|
||||
@@ -15,7 +17,7 @@ class ConfigureDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureDialog(QWidget* parent);
|
||||
explicit ConfigureDialog(QWidget* parent, const HotkeyRegistry& registry);
|
||||
~ConfigureDialog();
|
||||
|
||||
void applyConfiguration();
|
||||
|
||||
@@ -35,6 +35,10 @@ void ConfigureGeneral::setConfiguration() {
|
||||
ui->use_docked_mode->setChecked(Settings::values.use_docked_mode);
|
||||
}
|
||||
|
||||
void ConfigureGeneral::PopulateHotkeyList(const HotkeyRegistry& registry) {
|
||||
ui->widget->Populate(registry);
|
||||
}
|
||||
|
||||
void ConfigureGeneral::applyConfiguration() {
|
||||
UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked();
|
||||
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
|
||||
class HotkeyRegistry;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureGeneral;
|
||||
}
|
||||
@@ -18,11 +20,11 @@ public:
|
||||
explicit ConfigureGeneral(QWidget* parent = nullptr);
|
||||
~ConfigureGeneral();
|
||||
|
||||
void PopulateHotkeyList(const HotkeyRegistry& registry);
|
||||
void applyConfiguration();
|
||||
|
||||
private:
|
||||
void setConfiguration();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::ConfigureGeneral> ui;
|
||||
};
|
||||
|
||||
@@ -10,58 +10,53 @@
|
||||
#include "yuzu/hotkeys.h"
|
||||
#include "yuzu/ui_settings.h"
|
||||
|
||||
struct Hotkey {
|
||||
Hotkey() : shortcut(nullptr), context(Qt::WindowShortcut) {}
|
||||
HotkeyRegistry::HotkeyRegistry() = default;
|
||||
HotkeyRegistry::~HotkeyRegistry() = default;
|
||||
|
||||
QKeySequence keyseq;
|
||||
QShortcut* shortcut;
|
||||
Qt::ShortcutContext context;
|
||||
};
|
||||
|
||||
typedef std::map<QString, Hotkey> HotkeyMap;
|
||||
typedef std::map<QString, HotkeyMap> HotkeyGroupMap;
|
||||
|
||||
HotkeyGroupMap hotkey_groups;
|
||||
|
||||
void SaveHotkeys() {
|
||||
UISettings::values.shortcuts.clear();
|
||||
for (auto group : hotkey_groups) {
|
||||
for (auto hotkey : group.second) {
|
||||
UISettings::values.shortcuts.emplace_back(
|
||||
UISettings::Shortcut(group.first + "/" + hotkey.first,
|
||||
UISettings::ContextualShortcut(hotkey.second.keyseq.toString(),
|
||||
hotkey.second.context)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoadHotkeys() {
|
||||
void HotkeyRegistry::LoadHotkeys() {
|
||||
// Make sure NOT to use a reference here because it would become invalid once we call
|
||||
// beginGroup()
|
||||
for (auto shortcut : UISettings::values.shortcuts) {
|
||||
QStringList cat = shortcut.first.split("/");
|
||||
const QStringList cat = shortcut.first.split('/');
|
||||
Q_ASSERT(cat.size() >= 2);
|
||||
|
||||
// RegisterHotkey assigns default keybindings, so use old values as default parameters
|
||||
Hotkey& hk = hotkey_groups[cat[0]][cat[1]];
|
||||
if (!shortcut.second.first.isEmpty()) {
|
||||
hk.keyseq = QKeySequence::fromString(shortcut.second.first);
|
||||
hk.context = (Qt::ShortcutContext)shortcut.second.second;
|
||||
hk.context = static_cast<Qt::ShortcutContext>(shortcut.second.second);
|
||||
}
|
||||
if (hk.shortcut)
|
||||
hk.shortcut->setKey(hk.keyseq);
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq,
|
||||
Qt::ShortcutContext default_context) {
|
||||
if (hotkey_groups[group].find(action) == hotkey_groups[group].end()) {
|
||||
hotkey_groups[group][action].keyseq = default_keyseq;
|
||||
hotkey_groups[group][action].context = default_context;
|
||||
void HotkeyRegistry::SaveHotkeys() {
|
||||
UISettings::values.shortcuts.clear();
|
||||
for (const auto& group : hotkey_groups) {
|
||||
for (const auto& hotkey : group.second) {
|
||||
UISettings::values.shortcuts.emplace_back(
|
||||
UISettings::Shortcut(group.first + '/' + hotkey.first,
|
||||
UISettings::ContextualShortcut(hotkey.second.keyseq.toString(),
|
||||
hotkey.second.context)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget) {
|
||||
void HotkeyRegistry::RegisterHotkey(const QString& group, const QString& action,
|
||||
const QKeySequence& default_keyseq,
|
||||
Qt::ShortcutContext default_context) {
|
||||
auto& hotkey_group = hotkey_groups[group];
|
||||
if (hotkey_group.find(action) != hotkey_group.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& hotkey_action = hotkey_groups[group][action];
|
||||
hotkey_action.keyseq = default_keyseq;
|
||||
hotkey_action.context = default_context;
|
||||
}
|
||||
|
||||
QShortcut* HotkeyRegistry::GetHotkey(const QString& group, const QString& action, QWidget* widget) {
|
||||
Hotkey& hk = hotkey_groups[group][action];
|
||||
|
||||
if (!hk.shortcut)
|
||||
@@ -72,10 +67,12 @@ QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widge
|
||||
|
||||
GHotkeysDialog::GHotkeysDialog(QWidget* parent) : QWidget(parent) {
|
||||
ui.setupUi(this);
|
||||
}
|
||||
|
||||
for (auto group : hotkey_groups) {
|
||||
void GHotkeysDialog::Populate(const HotkeyRegistry& registry) {
|
||||
for (const auto& group : registry.hotkey_groups) {
|
||||
QTreeWidgetItem* toplevel_item = new QTreeWidgetItem(QStringList(group.first));
|
||||
for (auto hotkey : group.second) {
|
||||
for (const auto& hotkey : group.second) {
|
||||
QStringList columns;
|
||||
columns << hotkey.first << hotkey.second.keyseq.toString();
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(columns);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include "ui_hotkeys.h"
|
||||
|
||||
class QDialog;
|
||||
@@ -11,47 +12,69 @@ class QKeySequence;
|
||||
class QSettings;
|
||||
class QShortcut;
|
||||
|
||||
/**
|
||||
* Register a hotkey.
|
||||
*
|
||||
* @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger")
|
||||
* @param action Name of the action (e.g. "Start Emulation", "Load Image")
|
||||
* @param default_keyseq Default key sequence to assign if the hotkey wasn't present in the settings
|
||||
* file before
|
||||
* @param default_context Default context to assign if the hotkey wasn't present in the settings
|
||||
* file before
|
||||
* @warning Both the group and action strings will be displayed in the hotkey settings dialog
|
||||
*/
|
||||
void RegisterHotkey(const QString& group, const QString& action,
|
||||
const QKeySequence& default_keyseq = QKeySequence(),
|
||||
Qt::ShortcutContext default_context = Qt::WindowShortcut);
|
||||
class HotkeyRegistry final {
|
||||
public:
|
||||
friend class GHotkeysDialog;
|
||||
|
||||
/**
|
||||
* Returns a QShortcut object whose activated() signal can be connected to other QObjects' slots.
|
||||
*
|
||||
* @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger").
|
||||
* @param action Name of the action (e.g. "Start Emulation", "Load Image").
|
||||
* @param widget Parent widget of the returned QShortcut.
|
||||
* @warning If multiple QWidgets' call this function for the same action, the returned QShortcut
|
||||
* will be the same. Thus, you shouldn't rely on the caller really being the QShortcut's parent.
|
||||
*/
|
||||
QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget);
|
||||
explicit HotkeyRegistry();
|
||||
~HotkeyRegistry();
|
||||
|
||||
/**
|
||||
* Saves all registered hotkeys to the settings file.
|
||||
*
|
||||
* @note Each hotkey group will be stored a settings group; For each hotkey inside that group, a
|
||||
* settings group will be created to store the key sequence and the hotkey context.
|
||||
*/
|
||||
void SaveHotkeys();
|
||||
/**
|
||||
* Loads hotkeys from the settings file.
|
||||
*
|
||||
* @note Yet unregistered hotkeys which are present in the settings will automatically be
|
||||
* registered.
|
||||
*/
|
||||
void LoadHotkeys();
|
||||
|
||||
/**
|
||||
* Loads hotkeys from the settings file.
|
||||
*
|
||||
* @note Yet unregistered hotkeys which are present in the settings will automatically be
|
||||
* registered.
|
||||
*/
|
||||
void LoadHotkeys();
|
||||
/**
|
||||
* Saves all registered hotkeys to the settings file.
|
||||
*
|
||||
* @note Each hotkey group will be stored a settings group; For each hotkey inside that group, a
|
||||
* settings group will be created to store the key sequence and the hotkey context.
|
||||
*/
|
||||
void SaveHotkeys();
|
||||
|
||||
/**
|
||||
* Returns a QShortcut object whose activated() signal can be connected to other QObjects'
|
||||
* slots.
|
||||
*
|
||||
* @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger").
|
||||
* @param action Name of the action (e.g. "Start Emulation", "Load Image").
|
||||
* @param widget Parent widget of the returned QShortcut.
|
||||
* @warning If multiple QWidgets' call this function for the same action, the returned QShortcut
|
||||
* will be the same. Thus, you shouldn't rely on the caller really being the
|
||||
* QShortcut's parent.
|
||||
*/
|
||||
QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget);
|
||||
|
||||
/**
|
||||
* Register a hotkey.
|
||||
*
|
||||
* @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger")
|
||||
* @param action Name of the action (e.g. "Start Emulation", "Load Image")
|
||||
* @param default_keyseq Default key sequence to assign if the hotkey wasn't present in the
|
||||
* settings file before
|
||||
* @param default_context Default context to assign if the hotkey wasn't present in the settings
|
||||
* file before
|
||||
* @warning Both the group and action strings will be displayed in the hotkey settings dialog
|
||||
*/
|
||||
void RegisterHotkey(const QString& group, const QString& action,
|
||||
const QKeySequence& default_keyseq = {},
|
||||
Qt::ShortcutContext default_context = Qt::WindowShortcut);
|
||||
|
||||
private:
|
||||
struct Hotkey {
|
||||
QKeySequence keyseq;
|
||||
QShortcut* shortcut = nullptr;
|
||||
Qt::ShortcutContext context = Qt::WindowShortcut;
|
||||
};
|
||||
|
||||
using HotkeyMap = std::map<QString, Hotkey>;
|
||||
using HotkeyGroupMap = std::map<QString, HotkeyMap>;
|
||||
|
||||
HotkeyGroupMap hotkey_groups;
|
||||
};
|
||||
|
||||
class GHotkeysDialog : public QWidget {
|
||||
Q_OBJECT
|
||||
@@ -59,6 +82,8 @@ class GHotkeysDialog : public QWidget {
|
||||
public:
|
||||
explicit GHotkeysDialog(QWidget* parent = nullptr);
|
||||
|
||||
void Populate(const HotkeyRegistry& registry);
|
||||
|
||||
private:
|
||||
Ui::hotkeys ui;
|
||||
};
|
||||
|
||||
@@ -208,43 +208,46 @@ void GMainWindow::InitializeRecentFileMenuActions() {
|
||||
}
|
||||
|
||||
void GMainWindow::InitializeHotkeys() {
|
||||
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
|
||||
RegisterHotkey("Main Window", "Start Emulation");
|
||||
RegisterHotkey("Main Window", "Continue/Pause", QKeySequence(Qt::Key_F4));
|
||||
RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen);
|
||||
RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence(Qt::Key_Escape),
|
||||
Qt::ApplicationShortcut);
|
||||
RegisterHotkey("Main Window", "Toggle Speed Limit", QKeySequence("CTRL+Z"),
|
||||
Qt::ApplicationShortcut);
|
||||
LoadHotkeys();
|
||||
hotkey_registry.RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
|
||||
hotkey_registry.RegisterHotkey("Main Window", "Start Emulation");
|
||||
hotkey_registry.RegisterHotkey("Main Window", "Continue/Pause", QKeySequence(Qt::Key_F4));
|
||||
hotkey_registry.RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen);
|
||||
hotkey_registry.RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence(Qt::Key_Escape),
|
||||
Qt::ApplicationShortcut);
|
||||
hotkey_registry.RegisterHotkey("Main Window", "Toggle Speed Limit", QKeySequence("CTRL+Z"),
|
||||
Qt::ApplicationShortcut);
|
||||
hotkey_registry.LoadHotkeys();
|
||||
|
||||
connect(GetHotkey("Main Window", "Load File", this), &QShortcut::activated, this,
|
||||
&GMainWindow::OnMenuLoadFile);
|
||||
connect(GetHotkey("Main Window", "Start Emulation", this), &QShortcut::activated, this,
|
||||
&GMainWindow::OnStartGame);
|
||||
connect(GetHotkey("Main Window", "Continue/Pause", this), &QShortcut::activated, this, [&] {
|
||||
if (emulation_running) {
|
||||
if (emu_thread->IsRunning()) {
|
||||
OnPauseGame();
|
||||
} else {
|
||||
OnStartGame();
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activated,
|
||||
ui.action_Fullscreen, &QAction::trigger);
|
||||
connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activatedAmbiguously,
|
||||
ui.action_Fullscreen, &QAction::trigger);
|
||||
connect(GetHotkey("Main Window", "Exit Fullscreen", this), &QShortcut::activated, this, [&] {
|
||||
if (emulation_running) {
|
||||
ui.action_Fullscreen->setChecked(false);
|
||||
ToggleFullscreen();
|
||||
}
|
||||
});
|
||||
connect(GetHotkey("Main Window", "Toggle Speed Limit", this), &QShortcut::activated, this, [&] {
|
||||
Settings::values.toggle_framelimit = !Settings::values.toggle_framelimit;
|
||||
UpdateStatusBar();
|
||||
});
|
||||
connect(hotkey_registry.GetHotkey("Main Window", "Load File", this), &QShortcut::activated,
|
||||
this, &GMainWindow::OnMenuLoadFile);
|
||||
connect(hotkey_registry.GetHotkey("Main Window", "Start Emulation", this),
|
||||
&QShortcut::activated, this, &GMainWindow::OnStartGame);
|
||||
connect(hotkey_registry.GetHotkey("Main Window", "Continue/Pause", this), &QShortcut::activated,
|
||||
this, [&] {
|
||||
if (emulation_running) {
|
||||
if (emu_thread->IsRunning()) {
|
||||
OnPauseGame();
|
||||
} else {
|
||||
OnStartGame();
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(hotkey_registry.GetHotkey("Main Window", "Fullscreen", render_window),
|
||||
&QShortcut::activated, ui.action_Fullscreen, &QAction::trigger);
|
||||
connect(hotkey_registry.GetHotkey("Main Window", "Fullscreen", render_window),
|
||||
&QShortcut::activatedAmbiguously, ui.action_Fullscreen, &QAction::trigger);
|
||||
connect(hotkey_registry.GetHotkey("Main Window", "Exit Fullscreen", this),
|
||||
&QShortcut::activated, this, [&] {
|
||||
if (emulation_running) {
|
||||
ui.action_Fullscreen->setChecked(false);
|
||||
ToggleFullscreen();
|
||||
}
|
||||
});
|
||||
connect(hotkey_registry.GetHotkey("Main Window", "Toggle Speed Limit", this),
|
||||
&QShortcut::activated, this, [&] {
|
||||
Settings::values.toggle_framelimit = !Settings::values.toggle_framelimit;
|
||||
UpdateStatusBar();
|
||||
});
|
||||
}
|
||||
|
||||
void GMainWindow::SetDefaultUIGeometry() {
|
||||
@@ -323,7 +326,8 @@ void GMainWindow::ConnectMenuEvents() {
|
||||
connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible);
|
||||
|
||||
// Fullscreen
|
||||
ui.action_Fullscreen->setShortcut(GetHotkey("Main Window", "Fullscreen", this)->key());
|
||||
ui.action_Fullscreen->setShortcut(
|
||||
hotkey_registry.GetHotkey("Main Window", "Fullscreen", this)->key());
|
||||
connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen);
|
||||
|
||||
// Help
|
||||
@@ -757,7 +761,7 @@ void GMainWindow::ToggleWindowMode() {
|
||||
}
|
||||
|
||||
void GMainWindow::OnConfigure() {
|
||||
ConfigureDialog configureDialog(this);
|
||||
ConfigureDialog configureDialog(this, hotkey_registry);
|
||||
auto old_theme = UISettings::values.theme;
|
||||
auto result = configureDialog.exec();
|
||||
if (result == QDialog::Accepted) {
|
||||
@@ -896,7 +900,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
|
||||
UISettings::values.first_start = false;
|
||||
|
||||
game_list->SaveInterfaceLayout();
|
||||
SaveHotkeys();
|
||||
hotkey_registry.SaveHotkeys();
|
||||
|
||||
// Shutdown session if the emu thread is active...
|
||||
if (emu_thread != nullptr)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <QTimer>
|
||||
#include "core/core.h"
|
||||
#include "ui_main.h"
|
||||
#include "yuzu/hotkeys.h"
|
||||
|
||||
class Config;
|
||||
class EmuThread;
|
||||
@@ -172,6 +173,8 @@ private:
|
||||
// stores default icon theme search paths for the platform
|
||||
QStringList default_theme_paths;
|
||||
|
||||
HotkeyRegistry hotkey_registry;
|
||||
|
||||
protected:
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
|
||||
Reference in New Issue
Block a user