Compare commits
3 Commits
android-14
...
android-13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b47aa14b37 | ||
|
|
587fbed49b | ||
|
|
6d830af618 |
@@ -1,8 +1,7 @@
|
||||
| Pull Request | Commit | Title | Author | Merged? |
|
||||
|----|----|----|----|----|
|
||||
| [11535](https://github.com/yuzu-emu/yuzu//pull/11535) | [`50bcfa5fb`](https://github.com/yuzu-emu/yuzu//pull/11535/files) | renderer_vulkan: Introduce separate cmd buffer for uploads | [GPUCode](https://github.com/GPUCode/) | Yes |
|
||||
| [12074](https://github.com/yuzu-emu/yuzu//pull/12074) | [`dc726aea8`](https://github.com/yuzu-emu/yuzu//pull/12074/files) | Implement Native Code Execution (NCE) | [GPUCode](https://github.com/GPUCode/) | Yes |
|
||||
| [12110](https://github.com/yuzu-emu/yuzu//pull/12110) | [`e7878e3cf`](https://github.com/yuzu-emu/yuzu//pull/12110/files) | vk_texture_cache: add workaround for nullDescriptor on Mali | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12074](https://github.com/yuzu-emu/yuzu//pull/12074) | [`36fccd7cc`](https://github.com/yuzu-emu/yuzu//pull/12074/files) | Implement Native Code Execution (NCE) | [GPUCode](https://github.com/GPUCode/) | Yes |
|
||||
|
||||
|
||||
End of merge log. You can find the original README.md below the break.
|
||||
|
||||
5
dist/languages/.tx/config
vendored
5
dist/languages/.tx/config
vendored
@@ -6,8 +6,3 @@ file_filter = <lang>.ts
|
||||
source_file = en.ts
|
||||
source_lang = en
|
||||
type = QT
|
||||
|
||||
[o:yuzu-emulator:p:yuzu:r:yuzu-android]
|
||||
file_filter = ../../src/android/app/src/main/res/values-<lang>/strings.xml
|
||||
source_file = ../../src/android/app/src/main/res/values/strings.xml
|
||||
type = ANDROID
|
||||
|
||||
2
externals/oaknut
vendored
2
externals/oaknut
vendored
Submodule externals/oaknut updated: 918bd94f02...316d8869e8
@@ -82,8 +82,8 @@ abstract class SettingsItem(
|
||||
IntSetting.CPU_BACKEND,
|
||||
R.string.cpu_backend,
|
||||
0,
|
||||
R.array.cpuBackendArm64Names,
|
||||
R.array.cpuBackendArm64Values
|
||||
R.array.cpuBackendNames,
|
||||
R.array.cpuBackendValues
|
||||
)
|
||||
)
|
||||
put(
|
||||
|
||||
@@ -153,6 +153,10 @@ use_multi_core =
|
||||
use_unsafe_extended_memory_layout =
|
||||
|
||||
[Cpu]
|
||||
Selects the preferred CPU backend for executing ARM instructions
|
||||
# 0 (default): Dynarmic, 1: NCE
|
||||
cpu_backend =
|
||||
|
||||
# Adjusts various optimizations.
|
||||
# Auto-select mode enables choice unsafe optimizations.
|
||||
# Accurate enables only safe optimizations.
|
||||
|
||||
@@ -175,24 +175,16 @@
|
||||
<item>2</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="cpuBackendArm64Names">
|
||||
<string-array name="cpuBackendNames">
|
||||
<item>@string/cpu_backend_dynarmic</item>
|
||||
<item>@string/cpu_backend_nce</item>
|
||||
</string-array>
|
||||
|
||||
<integer-array name="cpuBackendArm64Values">
|
||||
<integer-array name="cpuBackendValues">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="cpuBackendX86Names">
|
||||
<item>@string/cpu_backend_dynarmic</item>
|
||||
</string-array>
|
||||
|
||||
<integer-array name="cpuBackendX86Values">
|
||||
<item>0</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="cpuAccuracyNames">
|
||||
<item>@string/auto</item>
|
||||
<item>@string/cpu_accuracy_accurate</item>
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
<string name="frame_limit_enable_description">Limits emulation speed to a specified percentage of normal speed.</string>
|
||||
<string name="frame_limit_slider">Limit speed percent</string>
|
||||
<string name="frame_limit_slider_description">Specifies the percentage to limit emulation speed. 100% is the normal speed. Values higher or lower will increase or decrease the speed limit.</string>
|
||||
<string name="cpu_backend">CPU backend</string>
|
||||
<string name="cpu_backend">CPU Backend</string>
|
||||
<string name="cpu_accuracy">CPU accuracy</string>
|
||||
<string name="value_with_units">%1$s%2$s</string>
|
||||
|
||||
|
||||
@@ -363,12 +363,21 @@ private:
|
||||
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
|
||||
static uint64_t GetRandomU64() {
|
||||
uint64_t ret;
|
||||
ASSERT(getrandom(&ret, sizeof(ret), 0) == 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void* ChooseVirtualBase(size_t virtual_size) {
|
||||
constexpr uintptr_t Map39BitSize = (1ULL << 39);
|
||||
constexpr uintptr_t Map36BitSize = (1ULL << 36);
|
||||
|
||||
// This is not a cryptographic application, we just want something random.
|
||||
std::mt19937_64 rng;
|
||||
// Seed the MT with some initial strong randomness.
|
||||
//
|
||||
// This is not a cryptographic application, we just want something more
|
||||
// random than the current time.
|
||||
std::mt19937_64 rng(GetRandomU64());
|
||||
|
||||
// We want to ensure we are allocating at an address aligned to the L2 block size.
|
||||
// For Qualcomm devices, we must also allocate memory above 36 bits.
|
||||
|
||||
@@ -529,7 +529,6 @@ add_library(core STATIC
|
||||
hle/service/hid/hid_server.h
|
||||
hle/service/hid/hid_system_server.cpp
|
||||
hle/service/hid/hid_system_server.h
|
||||
hle/service/hid/hid_util.h
|
||||
hle/service/hid/hidbus.cpp
|
||||
hle/service/hid/hidbus.h
|
||||
hle/service/hid/irs.cpp
|
||||
@@ -541,8 +540,8 @@ add_library(core STATIC
|
||||
hle/service/hid/xcd.cpp
|
||||
hle/service/hid/xcd.h
|
||||
hle/service/hid/errors.h
|
||||
hle/service/hid/controllers/console_six_axis.cpp
|
||||
hle/service/hid/controllers/console_six_axis.h
|
||||
hle/service/hid/controllers/console_sixaxis.cpp
|
||||
hle/service/hid/controllers/console_sixaxis.h
|
||||
hle/service/hid/controllers/controller_base.cpp
|
||||
hle/service/hid/controllers/controller_base.h
|
||||
hle/service/hid/controllers/debug_pad.cpp
|
||||
@@ -557,10 +556,6 @@ add_library(core STATIC
|
||||
hle/service/hid/controllers/npad.h
|
||||
hle/service/hid/controllers/palma.cpp
|
||||
hle/service/hid/controllers/palma.h
|
||||
hle/service/hid/controllers/seven_six_axis.cpp
|
||||
hle/service/hid/controllers/seven_six_axis.h
|
||||
hle/service/hid/controllers/six_axis.cpp
|
||||
hle/service/hid/controllers/six_axis.h
|
||||
hle/service/hid/controllers/stubbed.cpp
|
||||
hle/service/hid/controllers/stubbed.h
|
||||
hle/service/hid/controllers/touchscreen.cpp
|
||||
|
||||
@@ -116,18 +116,10 @@ bool ARM_NCE::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* ra
|
||||
return true;
|
||||
}
|
||||
|
||||
// We can't handle the access, so determine why we crashed.
|
||||
// We can't handle the access, so trigger an exception.
|
||||
const bool is_prefetch_abort = host_ctx.pc == reinterpret_cast<u64>(info->si_addr);
|
||||
|
||||
// For data aborts, skip the instruction and return to guest code.
|
||||
// This will allow games to continue in many scenarios where they would otherwise crash.
|
||||
if (!is_prefetch_abort) {
|
||||
host_ctx.pc += 4;
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is a prefetch abort.
|
||||
guest_ctx->esr_el1.fetch_or(static_cast<u64>(HaltReason::PrefetchAbort));
|
||||
guest_ctx->esr_el1.fetch_or(
|
||||
static_cast<u64>(is_prefetch_abort ? HaltReason::PrefetchAbort : HaltReason::DataAbort));
|
||||
|
||||
// Forcibly mark the context as locked. We are still running.
|
||||
// We may race with SignalInterrupt here:
|
||||
|
||||
@@ -90,10 +90,6 @@ void Patcher::PatchText(const Kernel::PhysicalMemory& program_image,
|
||||
WriteMsrHandler(AddRelocations(), oaknut::XReg{static_cast<int>(msr.GetRt())});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto exclusive = Exclusive{inst}; exclusive.Verify()) {
|
||||
m_exclusives.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine patching mode for the final relocation step
|
||||
@@ -167,9 +163,11 @@ void Patcher::RelocateAndCopy(Common::ProcessAddress load_base,
|
||||
|
||||
// Cortex-A57 seems to treat all exclusives as ordered, but newer processors do not.
|
||||
// Convert to ordered to preserve this assumption.
|
||||
for (const ModuleTextAddress i : m_exclusives) {
|
||||
auto exclusive = Exclusive{text_words[i]};
|
||||
text_words[i] = exclusive.AsOrdered();
|
||||
for (u32 i = ModuleCodeIndex; i < static_cast<u32>(text_words.size()); i++) {
|
||||
const u32 inst = text_words[i];
|
||||
if (auto exclusive = Exclusive{inst}; exclusive.Verify()) {
|
||||
text_words[i] = exclusive.AsOrdered();
|
||||
}
|
||||
}
|
||||
|
||||
// Copy to program image
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
#include <span>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
|
||||
#include <oaknut/code_block.hpp>
|
||||
#include <oaknut/oaknut.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/kernel/code_set.h"
|
||||
@@ -89,7 +93,6 @@ private:
|
||||
std::vector<Relocation> m_branch_to_patch_relocations{};
|
||||
std::vector<Relocation> m_branch_to_module_relocations{};
|
||||
std::vector<Relocation> m_write_module_pc_relocations{};
|
||||
std::vector<ModuleTextAddress> m_exclusives{};
|
||||
oaknut::Label m_save_context{};
|
||||
oaknut::Label m_load_context{};
|
||||
PatchMode mode{PatchMode::None};
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "common/thread.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/input_converter.h"
|
||||
#include "core/hle/service/hid/hid_util.h"
|
||||
|
||||
namespace Core::HID {
|
||||
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
|
||||
@@ -83,7 +82,7 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleInde
|
||||
}
|
||||
|
||||
void EmulatedController::ReloadFromSettings() {
|
||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||
const auto& player = Settings::values.players.GetValue()[player_index];
|
||||
|
||||
for (std::size_t index = 0; index < player.buttons.size(); ++index) {
|
||||
@@ -119,7 +118,7 @@ void EmulatedController::ReloadFromSettings() {
|
||||
}
|
||||
|
||||
void EmulatedController::ReloadColorsFromSettings() {
|
||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||
const auto& player = Settings::values.players.GetValue()[player_index];
|
||||
|
||||
// Avoid updating colors if overridden by physical controller
|
||||
@@ -216,7 +215,7 @@ void EmulatedController::LoadDevices() {
|
||||
}
|
||||
|
||||
void EmulatedController::LoadTASParams() {
|
||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||
Common::ParamPackage common_params{};
|
||||
common_params.Set("engine", "tas");
|
||||
common_params.Set("port", static_cast<int>(player_index));
|
||||
@@ -265,7 +264,7 @@ void EmulatedController::LoadTASParams() {
|
||||
}
|
||||
|
||||
void EmulatedController::LoadVirtualGamepadParams() {
|
||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||
Common::ParamPackage common_params{};
|
||||
common_params.Set("engine", "virtual_gamepad");
|
||||
common_params.Set("port", static_cast<int>(player_index));
|
||||
@@ -616,7 +615,7 @@ bool EmulatedController::IsConfiguring() const {
|
||||
}
|
||||
|
||||
void EmulatedController::SaveCurrentConfig() {
|
||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||
auto& player = Settings::values.players.GetValue()[player_index];
|
||||
player.connected = is_connected;
|
||||
player.controller_type = MapNPadToSettingsType(npad_type);
|
||||
@@ -1213,7 +1212,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
|
||||
if (!output_devices[device_index]) {
|
||||
return false;
|
||||
}
|
||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||
const auto& player = Settings::values.players.GetValue()[player_index];
|
||||
const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f;
|
||||
|
||||
@@ -1239,7 +1238,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
|
||||
}
|
||||
|
||||
bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
|
||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||
const auto& player = Settings::values.players.GetValue()[player_index];
|
||||
|
||||
if (!player.vibration_enabled) {
|
||||
@@ -1649,7 +1648,7 @@ void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) {
|
||||
}
|
||||
if (is_connected) {
|
||||
LOG_WARNING(Service_HID, "Controller {} type changed while it's connected",
|
||||
Service::HID::NpadIdTypeToIndex(npad_id_type));
|
||||
NpadIdTypeToIndex(npad_id_type));
|
||||
}
|
||||
npad_type = npad_type_;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/emulated_devices.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/hid_util.h"
|
||||
|
||||
namespace Core::HID {
|
||||
|
||||
@@ -99,11 +98,11 @@ const EmulatedDevices* HIDCore::GetEmulatedDevices() const {
|
||||
}
|
||||
|
||||
EmulatedController* HIDCore::GetEmulatedControllerByIndex(std::size_t index) {
|
||||
return GetEmulatedController(Service::HID::IndexToNpadIdType(index));
|
||||
return GetEmulatedController(IndexToNpadIdType(index));
|
||||
}
|
||||
|
||||
const EmulatedController* HIDCore::GetEmulatedControllerByIndex(std::size_t index) const {
|
||||
return GetEmulatedController(Service::HID::IndexToNpadIdType(index));
|
||||
return GetEmulatedController(IndexToNpadIdType(index));
|
||||
}
|
||||
|
||||
void HIDCore::SetSupportedStyleTag(NpadStyleTag style_tag) {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "common/common_types.h"
|
||||
#include "common/point.h"
|
||||
#include "common/uuid.h"
|
||||
#include "common/vector_math.h"
|
||||
|
||||
namespace Core::HID {
|
||||
|
||||
@@ -599,29 +598,6 @@ struct SixAxisSensorIcInformation {
|
||||
static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8,
|
||||
"SixAxisSensorIcInformation is an invalid size");
|
||||
|
||||
// This is nn::hid::SixAxisSensorAttribute
|
||||
struct SixAxisSensorAttribute {
|
||||
union {
|
||||
u32 raw{};
|
||||
BitField<0, 1, u32> is_connected;
|
||||
BitField<1, 1, u32> is_interpolated;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(SixAxisSensorAttribute) == 4, "SixAxisSensorAttribute is an invalid size");
|
||||
|
||||
// This is nn::hid::SixAxisSensorState
|
||||
struct SixAxisSensorState {
|
||||
s64 delta_time{};
|
||||
s64 sampling_number{};
|
||||
Common::Vec3f accel{};
|
||||
Common::Vec3f gyro{};
|
||||
Common::Vec3f rotation{};
|
||||
std::array<Common::Vec3f, 3> orientation{};
|
||||
SixAxisSensorAttribute attribute{};
|
||||
INSERT_PADDING_BYTES(4); // Reserved
|
||||
};
|
||||
static_assert(sizeof(SixAxisSensorState) == 0x60, "SixAxisSensorState is an invalid size");
|
||||
|
||||
// This is nn::hid::VibrationDeviceHandle
|
||||
struct VibrationDeviceHandle {
|
||||
NpadStyleIndex npad_type{NpadStyleIndex::None};
|
||||
@@ -732,4 +708,60 @@ struct UniquePadId {
|
||||
};
|
||||
static_assert(sizeof(UniquePadId) == 0x8, "UniquePadId is an invalid size");
|
||||
|
||||
/// Converts a NpadIdType to an array index.
|
||||
constexpr size_t NpadIdTypeToIndex(NpadIdType npad_id_type) {
|
||||
switch (npad_id_type) {
|
||||
case NpadIdType::Player1:
|
||||
return 0;
|
||||
case NpadIdType::Player2:
|
||||
return 1;
|
||||
case NpadIdType::Player3:
|
||||
return 2;
|
||||
case NpadIdType::Player4:
|
||||
return 3;
|
||||
case NpadIdType::Player5:
|
||||
return 4;
|
||||
case NpadIdType::Player6:
|
||||
return 5;
|
||||
case NpadIdType::Player7:
|
||||
return 6;
|
||||
case NpadIdType::Player8:
|
||||
return 7;
|
||||
case NpadIdType::Handheld:
|
||||
return 8;
|
||||
case NpadIdType::Other:
|
||||
return 9;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts an array index to a NpadIdType
|
||||
constexpr NpadIdType IndexToNpadIdType(size_t index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return NpadIdType::Player1;
|
||||
case 1:
|
||||
return NpadIdType::Player2;
|
||||
case 2:
|
||||
return NpadIdType::Player3;
|
||||
case 3:
|
||||
return NpadIdType::Player4;
|
||||
case 4:
|
||||
return NpadIdType::Player5;
|
||||
case 5:
|
||||
return NpadIdType::Player6;
|
||||
case 6:
|
||||
return NpadIdType::Player7;
|
||||
case 7:
|
||||
return NpadIdType::Player8;
|
||||
case 8:
|
||||
return NpadIdType::Handheld;
|
||||
case 9:
|
||||
return NpadIdType::Other;
|
||||
default:
|
||||
return NpadIdType::Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Core::HID
|
||||
|
||||
@@ -13,14 +13,14 @@ InputInterpreter::InputInterpreter(Core::System& system)
|
||||
: npad{system.ServiceManager()
|
||||
.GetService<Service::HID::IHidServer>("hid")
|
||||
->GetResourceManager()
|
||||
->GetNpad()} {
|
||||
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)} {
|
||||
ResetButtonStates();
|
||||
}
|
||||
|
||||
InputInterpreter::~InputInterpreter() = default;
|
||||
|
||||
void InputInterpreter::PollInput() {
|
||||
const auto button_state = npad->GetAndResetPressState();
|
||||
const auto button_state = npad.GetAndResetPressState();
|
||||
|
||||
previous_index = current_index;
|
||||
current_index = (current_index + 1) % button_states.size();
|
||||
|
||||
@@ -16,7 +16,7 @@ enum class NpadButton : u64;
|
||||
}
|
||||
|
||||
namespace Service::HID {
|
||||
class NPad;
|
||||
class Controller_NPad;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Service::HID::NPad> npad;
|
||||
Service::HID::Controller_NPad& npad;
|
||||
|
||||
/// Stores 9 consecutive button states polled from HID.
|
||||
std::array<Core::HID::NpadButton, 9> button_states{};
|
||||
|
||||
@@ -5678,8 +5678,15 @@ Result KPageTableBase::Operate(PageLinkedList* page_list, KProcessAddress virt_a
|
||||
case OperationType::ChangePermissions:
|
||||
case OperationType::ChangePermissionsAndRefresh:
|
||||
case OperationType::ChangePermissionsAndRefreshAndFlush: {
|
||||
m_memory->ProtectRegion(*m_impl, virt_addr, num_pages * PageSize,
|
||||
ConvertToMemoryPermission(properties.perm));
|
||||
const bool read = True(properties.perm & Kernel::KMemoryPermission::UserRead);
|
||||
const bool write = True(properties.perm & Kernel::KMemoryPermission::UserWrite);
|
||||
// todo: this doesn't really belong here and should go into m_memory to handle rasterizer
|
||||
// access todo: ignore exec on non-direct-mapped case
|
||||
const bool exec = True(properties.perm & Kernel::KMemoryPermission::UserExecute);
|
||||
if (Settings::IsFastmemEnabled()) {
|
||||
m_system.DeviceMemory().buffer.Protect(GetInteger(virt_addr), num_pages * PageSize,
|
||||
read, write, exec);
|
||||
}
|
||||
R_SUCCEED();
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
{10200, nullptr, "SendFriendRequestForApplication"},
|
||||
{10211, nullptr, "AddFacedFriendRequestForApplication"},
|
||||
{10400, &IFriendService::GetBlockedUserListIds, "GetBlockedUserListIds"},
|
||||
{10420, &IFriendService::CheckBlockedUserListAvailability, "CheckBlockedUserListAvailability"},
|
||||
{10420, nullptr, "IsBlockedUserListCacheAvailable"},
|
||||
{10421, nullptr, "EnsureBlockedUserListAvailable"},
|
||||
{10500, nullptr, "GetProfileList"},
|
||||
{10600, nullptr, "DeclareOpenOnlinePlaySession"},
|
||||
@@ -206,17 +206,6 @@ private:
|
||||
rb.Push(true);
|
||||
}
|
||||
|
||||
void CheckBlockedUserListAvailability(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto uuid{rp.PopRaw<Common::UUID>()};
|
||||
|
||||
LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(true);
|
||||
}
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
|
||||
Kernel::KEvent* completion_event;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hid/emulated_console.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/controllers/console_six_axis.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200;
|
||||
|
||||
ConsoleSixAxis::ConsoleSixAxis(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
: ControllerBase{hid_core_} {
|
||||
console = hid_core.GetEmulatedConsole();
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size,
|
||||
"ConsoleSharedMemory is bigger than the shared memory");
|
||||
shared_memory = std::construct_at(
|
||||
reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||
}
|
||||
|
||||
ConsoleSixAxis::~ConsoleSixAxis() = default;
|
||||
|
||||
void ConsoleSixAxis::OnInit() {}
|
||||
|
||||
void ConsoleSixAxis::OnRelease() {}
|
||||
|
||||
void ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto motion_status = console->GetMotion();
|
||||
|
||||
shared_memory->sampling_number++;
|
||||
shared_memory->is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest;
|
||||
shared_memory->verticalization_error = motion_status.verticalization_error;
|
||||
shared_memory->gyro_bias = motion_status.gyro_bias;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
@@ -1,43 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/vector_math.h"
|
||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||
|
||||
namespace Core::HID {
|
||||
class EmulatedConsole;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class ConsoleSixAxis final : public ControllerBase {
|
||||
public:
|
||||
explicit ConsoleSixAxis(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~ConsoleSixAxis() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
// When the controller is released
|
||||
void OnRelease() override;
|
||||
|
||||
// When the controller is requesting an update for the shared memory
|
||||
void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
|
||||
|
||||
private:
|
||||
// This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat
|
||||
struct ConsoleSharedMemory {
|
||||
u64 sampling_number{};
|
||||
bool is_seven_six_axis_sensor_at_rest{};
|
||||
INSERT_PADDING_BYTES(3); // padding
|
||||
f32 verticalization_error{};
|
||||
Common::Vec3f gyro_bias{};
|
||||
INSERT_PADDING_BYTES(4); // padding
|
||||
};
|
||||
static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size");
|
||||
|
||||
ConsoleSharedMemory* shared_memory = nullptr;
|
||||
Core::HID::EmulatedConsole* console = nullptr;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
@@ -1,29 +1,32 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <cstring>
|
||||
#include "common/common_types.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/frontend/emu_window.h"
|
||||
#include "core/hid/emulated_console.h"
|
||||
#include "core/hid/emulated_devices.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/controllers/seven_six_axis.h"
|
||||
#include "core/hle/service/hid/controllers/console_sixaxis.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
namespace Service::HID {
|
||||
SevenSixAxis::SevenSixAxis(Core::System& system_)
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200;
|
||||
|
||||
Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::System& system_, u8* raw_shared_memory_)
|
||||
: ControllerBase{system_.HIDCore()}, system{system_} {
|
||||
console = hid_core.GetEmulatedConsole();
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size,
|
||||
"ConsoleSharedMemory is bigger than the shared memory");
|
||||
shared_memory = std::construct_at(
|
||||
reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||
}
|
||||
|
||||
SevenSixAxis::~SevenSixAxis() = default;
|
||||
Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default;
|
||||
|
||||
void SevenSixAxis::OnInit() {}
|
||||
void SevenSixAxis::OnRelease() {}
|
||||
void Controller_ConsoleSixAxis::OnInit() {}
|
||||
|
||||
void SevenSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_ConsoleSixAxis::OnRelease() {}
|
||||
|
||||
void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated() || transfer_memory == 0) {
|
||||
seven_sixaxis_lifo.buffer_count = 0;
|
||||
seven_sixaxis_lifo.buffer_tail = 0;
|
||||
@@ -50,17 +53,22 @@ void SevenSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
-motion_status.quaternion.xyz.z,
|
||||
};
|
||||
|
||||
shared_memory->sampling_number++;
|
||||
shared_memory->is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest;
|
||||
shared_memory->verticalization_error = motion_status.verticalization_error;
|
||||
shared_memory->gyro_bias = motion_status.gyro_bias;
|
||||
|
||||
// Update seven six axis transfer memory
|
||||
seven_sixaxis_lifo.WriteNextEntry(next_seven_sixaxis_state);
|
||||
system.ApplicationMemory().WriteBlock(transfer_memory, &seven_sixaxis_lifo,
|
||||
sizeof(seven_sixaxis_lifo));
|
||||
}
|
||||
|
||||
void SevenSixAxis::SetTransferMemoryAddress(Common::ProcessAddress t_mem) {
|
||||
void Controller_ConsoleSixAxis::SetTransferMemoryAddress(Common::ProcessAddress t_mem) {
|
||||
transfer_memory = t_mem;
|
||||
}
|
||||
|
||||
void SevenSixAxis::ResetTimestamp() {
|
||||
void Controller_ConsoleSixAxis::ResetTimestamp() {
|
||||
last_saved_timestamp = last_global_timestamp;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
@@ -1,9 +1,10 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include <array>
|
||||
|
||||
#include "common/quaternion.h"
|
||||
#include "common/typed_address.h"
|
||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||
@@ -18,10 +19,10 @@ class EmulatedConsole;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class SevenSixAxis final : public ControllerBase {
|
||||
class Controller_ConsoleSixAxis final : public ControllerBase {
|
||||
public:
|
||||
explicit SevenSixAxis(Core::System& system_);
|
||||
~SevenSixAxis() override;
|
||||
explicit Controller_ConsoleSixAxis(Core::System& system_, u8* raw_shared_memory_);
|
||||
~Controller_ConsoleSixAxis() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
@@ -50,16 +51,28 @@ private:
|
||||
};
|
||||
static_assert(sizeof(SevenSixAxisState) == 0x48, "SevenSixAxisState is an invalid size");
|
||||
|
||||
// This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat
|
||||
struct ConsoleSharedMemory {
|
||||
u64 sampling_number{};
|
||||
bool is_seven_six_axis_sensor_at_rest{};
|
||||
INSERT_PADDING_BYTES(3); // padding
|
||||
f32 verticalization_error{};
|
||||
Common::Vec3f gyro_bias{};
|
||||
INSERT_PADDING_BYTES(4); // padding
|
||||
};
|
||||
static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size");
|
||||
|
||||
Lifo<SevenSixAxisState, 0x21> seven_sixaxis_lifo{};
|
||||
static_assert(sizeof(seven_sixaxis_lifo) == 0xA70, "SevenSixAxisState is an invalid size");
|
||||
|
||||
SevenSixAxisState next_seven_sixaxis_state{};
|
||||
Common::ProcessAddress transfer_memory{};
|
||||
ConsoleSharedMemory* shared_memory = nullptr;
|
||||
Core::HID::EmulatedConsole* console = nullptr;
|
||||
|
||||
u64 last_saved_timestamp{};
|
||||
u64 last_global_timestamp{};
|
||||
|
||||
SevenSixAxisState next_seven_sixaxis_state{};
|
||||
Common::ProcessAddress transfer_memory{};
|
||||
Core::HID::EmulatedConsole* console = nullptr;
|
||||
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x00000;
|
||||
|
||||
DebugPad::DebugPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
Controller_DebugPad::Controller_DebugPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
: ControllerBase{hid_core_} {
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(DebugPadSharedMemory) < shared_memory_size,
|
||||
"DebugPadSharedMemory is bigger than the shared memory");
|
||||
@@ -22,13 +22,13 @@ DebugPad::DebugPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other);
|
||||
}
|
||||
|
||||
DebugPad::~DebugPad() = default;
|
||||
Controller_DebugPad::~Controller_DebugPad() = default;
|
||||
|
||||
void DebugPad::OnInit() {}
|
||||
void Controller_DebugPad::OnInit() {}
|
||||
|
||||
void DebugPad::OnRelease() {}
|
||||
void Controller_DebugPad::OnRelease() {}
|
||||
|
||||
void DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
shared_memory->debug_pad_lifo.buffer_count = 0;
|
||||
shared_memory->debug_pad_lifo.buffer_tail = 0;
|
||||
|
||||
@@ -15,10 +15,10 @@ struct AnalogStickState;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class DebugPad final : public ControllerBase {
|
||||
class Controller_DebugPad final : public ControllerBase {
|
||||
public:
|
||||
explicit DebugPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~DebugPad() override;
|
||||
explicit Controller_DebugPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Controller_DebugPad() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
@@ -23,7 +23,7 @@ constexpr f32 Square(s32 num) {
|
||||
return static_cast<f32>(num * num);
|
||||
}
|
||||
|
||||
Gesture::Gesture(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
Controller_Gesture::Controller_Gesture(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
: ControllerBase(hid_core_) {
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(GestureSharedMemory) < shared_memory_size,
|
||||
"GestureSharedMemory is bigger than the shared memory");
|
||||
@@ -31,17 +31,17 @@ Gesture::Gesture(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
reinterpret_cast<GestureSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||
console = hid_core.GetEmulatedConsole();
|
||||
}
|
||||
Gesture::~Gesture() = default;
|
||||
Controller_Gesture::~Controller_Gesture() = default;
|
||||
|
||||
void Gesture::OnInit() {
|
||||
void Controller_Gesture::OnInit() {
|
||||
shared_memory->gesture_lifo.buffer_count = 0;
|
||||
shared_memory->gesture_lifo.buffer_tail = 0;
|
||||
force_update = true;
|
||||
}
|
||||
|
||||
void Gesture::OnRelease() {}
|
||||
void Controller_Gesture::OnRelease() {}
|
||||
|
||||
void Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
shared_memory->gesture_lifo.buffer_count = 0;
|
||||
shared_memory->gesture_lifo.buffer_tail = 0;
|
||||
@@ -64,7 +64,7 @@ void Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
UpdateGestureSharedMemory(gesture, time_difference);
|
||||
}
|
||||
|
||||
void Gesture::ReadTouchInput() {
|
||||
void Controller_Gesture::ReadTouchInput() {
|
||||
if (!Settings::values.touchscreen.enabled) {
|
||||
fingers = {};
|
||||
return;
|
||||
@@ -76,7 +76,8 @@ void Gesture::ReadTouchInput() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Gesture::ShouldUpdateGesture(const GestureProperties& gesture, f32 time_difference) {
|
||||
bool Controller_Gesture::ShouldUpdateGesture(const GestureProperties& gesture,
|
||||
f32 time_difference) {
|
||||
const auto& last_entry = GetLastGestureEntry();
|
||||
if (force_update) {
|
||||
force_update = false;
|
||||
@@ -99,7 +100,8 @@ bool Gesture::ShouldUpdateGesture(const GestureProperties& gesture, f32 time_dif
|
||||
return false;
|
||||
}
|
||||
|
||||
void Gesture::UpdateGestureSharedMemory(GestureProperties& gesture, f32 time_difference) {
|
||||
void Controller_Gesture::UpdateGestureSharedMemory(GestureProperties& gesture,
|
||||
f32 time_difference) {
|
||||
GestureType type = GestureType::Idle;
|
||||
GestureAttribute attributes{};
|
||||
|
||||
@@ -136,8 +138,8 @@ void Gesture::UpdateGestureSharedMemory(GestureProperties& gesture, f32 time_dif
|
||||
shared_memory->gesture_lifo.WriteNextEntry(next_state);
|
||||
}
|
||||
|
||||
void Gesture::NewGesture(GestureProperties& gesture, GestureType& type,
|
||||
GestureAttribute& attributes) {
|
||||
void Controller_Gesture::NewGesture(GestureProperties& gesture, GestureType& type,
|
||||
GestureAttribute& attributes) {
|
||||
const auto& last_entry = GetLastGestureEntry();
|
||||
|
||||
gesture.detection_count++;
|
||||
@@ -150,8 +152,8 @@ void Gesture::NewGesture(GestureProperties& gesture, GestureType& type,
|
||||
}
|
||||
}
|
||||
|
||||
void Gesture::UpdateExistingGesture(GestureProperties& gesture, GestureType& type,
|
||||
f32 time_difference) {
|
||||
void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, GestureType& type,
|
||||
f32 time_difference) {
|
||||
const auto& last_entry = GetLastGestureEntry();
|
||||
|
||||
// Promote to pan type if touch moved
|
||||
@@ -184,8 +186,9 @@ void Gesture::UpdateExistingGesture(GestureProperties& gesture, GestureType& typ
|
||||
}
|
||||
}
|
||||
|
||||
void Gesture::EndGesture(GestureProperties& gesture, GestureProperties& last_gesture_props,
|
||||
GestureType& type, GestureAttribute& attributes, f32 time_difference) {
|
||||
void Controller_Gesture::EndGesture(GestureProperties& gesture,
|
||||
GestureProperties& last_gesture_props, GestureType& type,
|
||||
GestureAttribute& attributes, f32 time_difference) {
|
||||
const auto& last_entry = GetLastGestureEntry();
|
||||
|
||||
if (last_gesture_props.active_points != 0) {
|
||||
@@ -219,8 +222,9 @@ void Gesture::EndGesture(GestureProperties& gesture, GestureProperties& last_ges
|
||||
}
|
||||
}
|
||||
|
||||
void Gesture::SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
|
||||
GestureType& type, GestureAttribute& attributes) {
|
||||
void Controller_Gesture::SetTapEvent(GestureProperties& gesture,
|
||||
GestureProperties& last_gesture_props, GestureType& type,
|
||||
GestureAttribute& attributes) {
|
||||
type = GestureType::Tap;
|
||||
gesture = last_gesture_props;
|
||||
force_update = true;
|
||||
@@ -232,8 +236,9 @@ void Gesture::SetTapEvent(GestureProperties& gesture, GestureProperties& last_ge
|
||||
}
|
||||
}
|
||||
|
||||
void Gesture::UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
|
||||
GestureType& type, f32 time_difference) {
|
||||
void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture,
|
||||
GestureProperties& last_gesture_props, GestureType& type,
|
||||
f32 time_difference) {
|
||||
const auto& last_entry = GetLastGestureEntry();
|
||||
|
||||
next_state.delta = gesture.mid_point - last_entry.pos;
|
||||
@@ -258,8 +263,9 @@ void Gesture::UpdatePanEvent(GestureProperties& gesture, GestureProperties& last
|
||||
}
|
||||
}
|
||||
|
||||
void Gesture::EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
|
||||
GestureType& type, f32 time_difference) {
|
||||
void Controller_Gesture::EndPanEvent(GestureProperties& gesture,
|
||||
GestureProperties& last_gesture_props, GestureType& type,
|
||||
f32 time_difference) {
|
||||
const auto& last_entry = GetLastGestureEntry();
|
||||
next_state.vel_x =
|
||||
static_cast<f32>(last_entry.delta.x) / (last_pan_time_difference + time_difference);
|
||||
@@ -281,8 +287,8 @@ void Gesture::EndPanEvent(GestureProperties& gesture, GestureProperties& last_ge
|
||||
force_update = true;
|
||||
}
|
||||
|
||||
void Gesture::SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
|
||||
GestureType& type) {
|
||||
void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture,
|
||||
GestureProperties& last_gesture_props, GestureType& type) {
|
||||
const auto& last_entry = GetLastGestureEntry();
|
||||
|
||||
type = GestureType::Swipe;
|
||||
@@ -305,11 +311,11 @@ void Gesture::SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_
|
||||
next_state.direction = GestureDirection::Up;
|
||||
}
|
||||
|
||||
const Gesture::GestureState& Gesture::GetLastGestureEntry() const {
|
||||
const Controller_Gesture::GestureState& Controller_Gesture::GetLastGestureEntry() const {
|
||||
return shared_memory->gesture_lifo.ReadCurrentEntry().state;
|
||||
}
|
||||
|
||||
Gesture::GestureProperties Gesture::GetGestureProperties() {
|
||||
Controller_Gesture::GestureProperties Controller_Gesture::GetGestureProperties() {
|
||||
GestureProperties gesture;
|
||||
std::array<Core::HID::TouchFinger, MAX_POINTS> active_fingers;
|
||||
const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(),
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
#include "core/hle/service/hid/ring_lifo.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class Gesture final : public ControllerBase {
|
||||
class Controller_Gesture final : public ControllerBase {
|
||||
public:
|
||||
explicit Gesture(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Gesture() override;
|
||||
explicit Controller_Gesture(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Controller_Gesture() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800;
|
||||
|
||||
Keyboard::Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
Controller_Keyboard::Controller_Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
: ControllerBase{hid_core_} {
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(KeyboardSharedMemory) < shared_memory_size,
|
||||
"KeyboardSharedMemory is bigger than the shared memory");
|
||||
@@ -21,13 +21,13 @@ Keyboard::Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
emulated_devices = hid_core.GetEmulatedDevices();
|
||||
}
|
||||
|
||||
Keyboard::~Keyboard() = default;
|
||||
Controller_Keyboard::~Controller_Keyboard() = default;
|
||||
|
||||
void Keyboard::OnInit() {}
|
||||
void Controller_Keyboard::OnInit() {}
|
||||
|
||||
void Keyboard::OnRelease() {}
|
||||
void Controller_Keyboard::OnRelease() {}
|
||||
|
||||
void Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
shared_memory->keyboard_lifo.buffer_count = 0;
|
||||
shared_memory->keyboard_lifo.buffer_tail = 0;
|
||||
|
||||
@@ -14,10 +14,10 @@ struct KeyboardKey;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class Keyboard final : public ControllerBase {
|
||||
class Controller_Keyboard final : public ControllerBase {
|
||||
public:
|
||||
explicit Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Keyboard() override;
|
||||
explicit Controller_Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Controller_Keyboard() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400;
|
||||
|
||||
Mouse::Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) : ControllerBase{hid_core_} {
|
||||
Controller_Mouse::Controller_Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
: ControllerBase{hid_core_} {
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(MouseSharedMemory) < shared_memory_size,
|
||||
"MouseSharedMemory is bigger than the shared memory");
|
||||
shared_memory = std::construct_at(
|
||||
@@ -20,12 +21,12 @@ Mouse::Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) : Controller
|
||||
emulated_devices = hid_core.GetEmulatedDevices();
|
||||
}
|
||||
|
||||
Mouse::~Mouse() = default;
|
||||
Controller_Mouse::~Controller_Mouse() = default;
|
||||
|
||||
void Mouse::OnInit() {}
|
||||
void Mouse::OnRelease() {}
|
||||
void Controller_Mouse::OnInit() {}
|
||||
void Controller_Mouse::OnRelease() {}
|
||||
|
||||
void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
shared_memory->mouse_lifo.buffer_count = 0;
|
||||
shared_memory->mouse_lifo.buffer_tail = 0;
|
||||
|
||||
@@ -14,10 +14,10 @@ struct AnalogStickState;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class Mouse final : public ControllerBase {
|
||||
class Controller_Mouse final : public ControllerBase {
|
||||
public:
|
||||
explicit Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Mouse() override;
|
||||
explicit Controller_Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Controller_Mouse() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "core/hle/kernel/k_readable_event.h"
|
||||
#include "core/hle/service/hid/controllers/npad.h"
|
||||
#include "core/hle/service/hid/errors.h"
|
||||
#include "core/hle/service/hid/hid_util.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
|
||||
namespace Service::HID {
|
||||
@@ -30,8 +29,60 @@ constexpr std::array<Core::HID::NpadIdType, 10> npad_id_list{
|
||||
Core::HID::NpadIdType::Handheld,
|
||||
};
|
||||
|
||||
NPad::NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_)
|
||||
bool Controller_NPad::IsNpadIdValid(Core::HID::NpadIdType npad_id) {
|
||||
switch (npad_id) {
|
||||
case Core::HID::NpadIdType::Player1:
|
||||
case Core::HID::NpadIdType::Player2:
|
||||
case Core::HID::NpadIdType::Player3:
|
||||
case Core::HID::NpadIdType::Player4:
|
||||
case Core::HID::NpadIdType::Player5:
|
||||
case Core::HID::NpadIdType::Player6:
|
||||
case Core::HID::NpadIdType::Player7:
|
||||
case Core::HID::NpadIdType::Player8:
|
||||
case Core::HID::NpadIdType::Other:
|
||||
case Core::HID::NpadIdType::Handheld:
|
||||
return true;
|
||||
default:
|
||||
LOG_ERROR(Service_HID, "Invalid npad id {}", npad_id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Result Controller_NPad::IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle) {
|
||||
const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id));
|
||||
const bool npad_type = device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType;
|
||||
const bool device_index = device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex;
|
||||
|
||||
if (!npad_type) {
|
||||
return VibrationInvalidStyleIndex;
|
||||
}
|
||||
if (!npad_id) {
|
||||
return VibrationInvalidNpadId;
|
||||
}
|
||||
if (!device_index) {
|
||||
return VibrationDeviceIndexOutOfRange;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::VerifyValidSixAxisSensorHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) {
|
||||
const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id));
|
||||
const bool device_index = device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex;
|
||||
|
||||
if (!npad_id) {
|
||||
return InvalidNpadId;
|
||||
}
|
||||
if (!device_index) {
|
||||
return NpadDeviceIndexOutOfRange;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Controller_NPad::Controller_NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_)
|
||||
: ControllerBase{hid_core_}, service_context{service_context_} {
|
||||
static_assert(NPAD_OFFSET + (NPAD_COUNT * sizeof(NpadInternalState)) < shared_memory_size);
|
||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||
@@ -52,7 +103,7 @@ NPad::NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
}
|
||||
}
|
||||
|
||||
NPad::~NPad() {
|
||||
Controller_NPad::~Controller_NPad() {
|
||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||
auto& controller = controller_data[i];
|
||||
controller.device->DeleteCallback(controller.callback_key);
|
||||
@@ -60,7 +111,8 @@ NPad::~NPad() {
|
||||
OnRelease();
|
||||
}
|
||||
|
||||
void NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx) {
|
||||
void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type,
|
||||
std::size_t controller_idx) {
|
||||
if (type == Core::HID::ControllerTriggerType::All) {
|
||||
ControllerUpdate(Core::HID::ControllerTriggerType::Connected, controller_idx);
|
||||
ControllerUpdate(Core::HID::ControllerTriggerType::Battery, controller_idx);
|
||||
@@ -98,7 +150,7 @@ void NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t c
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||
void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||
auto& controller = GetControllerFromNpadIdType(npad_id);
|
||||
if (!IsControllerSupported(controller.device->GetNpadStyleIndex())) {
|
||||
return;
|
||||
@@ -298,7 +350,7 @@ void NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||
hid_core.SetLastActiveController(npad_id);
|
||||
}
|
||||
|
||||
void NPad::OnInit() {
|
||||
void Controller_NPad::OnInit() {
|
||||
if (!IsControllerActivated()) {
|
||||
return;
|
||||
}
|
||||
@@ -332,7 +384,7 @@ void NPad::OnInit() {
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::WriteEmptyEntry(NpadInternalState* npad) {
|
||||
void Controller_NPad::WriteEmptyEntry(NpadInternalState* npad) {
|
||||
NPadGenericState dummy_pad_state{};
|
||||
NpadGcTriggerState dummy_gc_state{};
|
||||
dummy_pad_state.sampling_number = npad->fullkey_lifo.ReadCurrentEntry().sampling_number + 1;
|
||||
@@ -353,7 +405,7 @@ void NPad::WriteEmptyEntry(NpadInternalState* npad) {
|
||||
npad->gc_trigger_lifo.WriteNextEntry(dummy_gc_state);
|
||||
}
|
||||
|
||||
void NPad::OnRelease() {
|
||||
void Controller_NPad::OnRelease() {
|
||||
is_controller_initialized = false;
|
||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||
auto& controller = controller_data[i];
|
||||
@@ -364,7 +416,7 @@ void NPad::OnRelease() {
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
|
||||
void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
|
||||
std::scoped_lock lock{mutex};
|
||||
auto& controller = GetControllerFromNpadIdType(npad_id);
|
||||
const auto controller_type = controller.device->GetNpadStyleIndex();
|
||||
@@ -433,7 +485,7 @@ void NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
return;
|
||||
}
|
||||
@@ -563,7 +615,134 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::SetSupportedStyleSet(Core::HID::NpadStyleTag style_set) {
|
||||
void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||
auto& controller = controller_data[i];
|
||||
|
||||
const auto& controller_type = controller.device->GetNpadStyleIndex();
|
||||
|
||||
if (controller_type == Core::HID::NpadStyleIndex::None ||
|
||||
!controller.device->IsConnected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* npad = controller.shared_memory;
|
||||
const auto& motion_state = controller.device->GetMotions();
|
||||
auto& sixaxis_fullkey_state = controller.sixaxis_fullkey_state;
|
||||
auto& sixaxis_handheld_state = controller.sixaxis_handheld_state;
|
||||
auto& sixaxis_dual_left_state = controller.sixaxis_dual_left_state;
|
||||
auto& sixaxis_dual_right_state = controller.sixaxis_dual_right_state;
|
||||
auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state;
|
||||
auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state;
|
||||
|
||||
// Clear previous state
|
||||
sixaxis_fullkey_state = {};
|
||||
sixaxis_handheld_state = {};
|
||||
sixaxis_dual_left_state = {};
|
||||
sixaxis_dual_right_state = {};
|
||||
sixaxis_left_lifo_state = {};
|
||||
sixaxis_right_lifo_state = {};
|
||||
|
||||
if (controller.sixaxis_sensor_enabled && Settings::values.motion_enabled.GetValue()) {
|
||||
controller.sixaxis_at_rest = true;
|
||||
for (std::size_t e = 0; e < motion_state.size(); ++e) {
|
||||
controller.sixaxis_at_rest =
|
||||
controller.sixaxis_at_rest && motion_state[e].is_at_rest;
|
||||
}
|
||||
}
|
||||
|
||||
const auto set_motion_state = [&](SixAxisSensorState& state,
|
||||
const Core::HID::ControllerMotion& hid_state) {
|
||||
using namespace std::literals::chrono_literals;
|
||||
static constexpr SixAxisSensorState default_motion_state = {
|
||||
.delta_time = std::chrono::nanoseconds(5ms).count(),
|
||||
.accel = {0, 0, -1.0f},
|
||||
.orientation =
|
||||
{
|
||||
Common::Vec3f{1.0f, 0, 0},
|
||||
Common::Vec3f{0, 1.0f, 0},
|
||||
Common::Vec3f{0, 0, 1.0f},
|
||||
},
|
||||
.attribute = {1},
|
||||
};
|
||||
if (!controller.sixaxis_sensor_enabled) {
|
||||
state = default_motion_state;
|
||||
return;
|
||||
}
|
||||
if (!Settings::values.motion_enabled.GetValue()) {
|
||||
state = default_motion_state;
|
||||
return;
|
||||
}
|
||||
state.attribute.is_connected.Assign(1);
|
||||
state.delta_time = std::chrono::nanoseconds(5ms).count();
|
||||
state.accel = hid_state.accel;
|
||||
state.gyro = hid_state.gyro;
|
||||
state.rotation = hid_state.rotation;
|
||||
state.orientation = hid_state.orientation;
|
||||
};
|
||||
|
||||
switch (controller_type) {
|
||||
case Core::HID::NpadStyleIndex::None:
|
||||
ASSERT(false);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
set_motion_state(sixaxis_handheld_state, motion_state[0]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
set_motion_state(sixaxis_dual_left_state, motion_state[0]);
|
||||
set_motion_state(sixaxis_dual_right_state, motion_state[1]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
set_motion_state(sixaxis_left_lifo_state, motion_state[0]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
set_motion_state(sixaxis_right_lifo_state, motion_state[1]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::Pokeball:
|
||||
using namespace std::literals::chrono_literals;
|
||||
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
||||
sixaxis_fullkey_state.delta_time = std::chrono::nanoseconds(15ms).count();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sixaxis_fullkey_state.sampling_number =
|
||||
npad->sixaxis_fullkey_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_handheld_state.sampling_number =
|
||||
npad->sixaxis_handheld_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_dual_left_state.sampling_number =
|
||||
npad->sixaxis_dual_left_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_dual_right_state.sampling_number =
|
||||
npad->sixaxis_dual_right_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_left_lifo_state.sampling_number =
|
||||
npad->sixaxis_left_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_right_lifo_state.sampling_number =
|
||||
npad->sixaxis_right_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
|
||||
if (Core::HID::IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) {
|
||||
// This buffer only is updated on handheld on HW
|
||||
npad->sixaxis_handheld_lifo.WriteNextEntry(sixaxis_handheld_state);
|
||||
} else {
|
||||
// Handheld doesn't update this buffer on HW
|
||||
npad->sixaxis_fullkey_lifo.WriteNextEntry(sixaxis_fullkey_state);
|
||||
}
|
||||
|
||||
npad->sixaxis_dual_left_lifo.WriteNextEntry(sixaxis_dual_left_state);
|
||||
npad->sixaxis_dual_right_lifo.WriteNextEntry(sixaxis_dual_right_state);
|
||||
npad->sixaxis_left_lifo.WriteNextEntry(sixaxis_left_lifo_state);
|
||||
npad->sixaxis_right_lifo.WriteNextEntry(sixaxis_right_lifo_state);
|
||||
}
|
||||
}
|
||||
|
||||
void Controller_NPad::SetSupportedStyleSet(Core::HID::NpadStyleTag style_set) {
|
||||
hid_core.SetSupportedStyleTag(style_set);
|
||||
|
||||
if (is_controller_initialized) {
|
||||
@@ -574,14 +753,14 @@ void NPad::SetSupportedStyleSet(Core::HID::NpadStyleTag style_set) {
|
||||
is_controller_initialized = true;
|
||||
}
|
||||
|
||||
Core::HID::NpadStyleTag NPad::GetSupportedStyleSet() const {
|
||||
Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
|
||||
if (!is_controller_initialized) {
|
||||
return {Core::HID::NpadStyleSet::None};
|
||||
}
|
||||
return hid_core.GetSupportedStyleTag();
|
||||
}
|
||||
|
||||
Result NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
|
||||
Result Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
|
||||
constexpr std::size_t max_number_npad_ids = 0xa;
|
||||
const auto length = data.size();
|
||||
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
|
||||
@@ -597,17 +776,17 @@ Result NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
|
||||
void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
|
||||
const auto copy_amount = supported_npad_id_types.size() * sizeof(u32);
|
||||
ASSERT(max_length <= copy_amount);
|
||||
std::memcpy(data, supported_npad_id_types.data(), copy_amount);
|
||||
}
|
||||
|
||||
std::size_t NPad::GetSupportedNpadIdTypesSize() const {
|
||||
std::size_t Controller_NPad::GetSupportedNpadIdTypesSize() const {
|
||||
return supported_npad_id_types.size();
|
||||
}
|
||||
|
||||
void NPad::SetHoldType(NpadJoyHoldType joy_hold_type) {
|
||||
void Controller_NPad::SetHoldType(NpadJoyHoldType joy_hold_type) {
|
||||
if (joy_hold_type != NpadJoyHoldType::Horizontal &&
|
||||
joy_hold_type != NpadJoyHoldType::Vertical) {
|
||||
LOG_ERROR(Service_HID, "Npad joy hold type needs to be valid, joy_hold_type={}",
|
||||
@@ -617,11 +796,11 @@ void NPad::SetHoldType(NpadJoyHoldType joy_hold_type) {
|
||||
hold_type = joy_hold_type;
|
||||
}
|
||||
|
||||
NPad::NpadJoyHoldType NPad::GetHoldType() const {
|
||||
Controller_NPad::NpadJoyHoldType Controller_NPad::GetHoldType() const {
|
||||
return hold_type;
|
||||
}
|
||||
|
||||
void NPad::SetNpadHandheldActivationMode(NpadHandheldActivationMode activation_mode) {
|
||||
void Controller_NPad::SetNpadHandheldActivationMode(NpadHandheldActivationMode activation_mode) {
|
||||
if (activation_mode >= NpadHandheldActivationMode::MaxActivationMode) {
|
||||
ASSERT_MSG(false, "Activation mode should be always None, Single or Dual");
|
||||
return;
|
||||
@@ -630,20 +809,21 @@ void NPad::SetNpadHandheldActivationMode(NpadHandheldActivationMode activation_m
|
||||
handheld_activation_mode = activation_mode;
|
||||
}
|
||||
|
||||
NPad::NpadHandheldActivationMode NPad::GetNpadHandheldActivationMode() const {
|
||||
Controller_NPad::NpadHandheldActivationMode Controller_NPad::GetNpadHandheldActivationMode() const {
|
||||
return handheld_activation_mode;
|
||||
}
|
||||
|
||||
void NPad::SetNpadCommunicationMode(NpadCommunicationMode communication_mode_) {
|
||||
void Controller_NPad::SetNpadCommunicationMode(NpadCommunicationMode communication_mode_) {
|
||||
communication_mode = communication_mode_;
|
||||
}
|
||||
|
||||
NPad::NpadCommunicationMode NPad::GetNpadCommunicationMode() const {
|
||||
Controller_NPad::NpadCommunicationMode Controller_NPad::GetNpadCommunicationMode() const {
|
||||
return communication_mode;
|
||||
}
|
||||
|
||||
bool NPad::SetNpadMode(Core::HID::NpadIdType& new_npad_id, Core::HID::NpadIdType npad_id,
|
||||
NpadJoyDeviceType npad_device_type, NpadJoyAssignmentMode assignment_mode) {
|
||||
bool Controller_NPad::SetNpadMode(Core::HID::NpadIdType& new_npad_id, Core::HID::NpadIdType npad_id,
|
||||
NpadJoyDeviceType npad_device_type,
|
||||
NpadJoyAssignmentMode assignment_mode) {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
return false;
|
||||
@@ -712,8 +892,9 @@ bool NPad::SetNpadMode(Core::HID::NpadIdType& new_npad_id, Core::HID::NpadIdType
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index,
|
||||
const Core::HID::VibrationValue& vibration_value) {
|
||||
bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id,
|
||||
std::size_t device_index,
|
||||
const Core::HID::VibrationValue& vibration_value) {
|
||||
auto& controller = GetControllerFromNpadIdType(npad_id);
|
||||
if (!controller.device->IsConnected()) {
|
||||
return false;
|
||||
@@ -757,9 +938,10 @@ bool NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t d
|
||||
return controller.device->SetVibration(device_index, vibration);
|
||||
}
|
||||
|
||||
void NPad::VibrateController(const Core::HID::VibrationDeviceHandle& vibration_device_handle,
|
||||
const Core::HID::VibrationValue& vibration_value) {
|
||||
if (IsVibrationHandleValid(vibration_device_handle).IsError()) {
|
||||
void Controller_NPad::VibrateController(
|
||||
const Core::HID::VibrationDeviceHandle& vibration_device_handle,
|
||||
const Core::HID::VibrationValue& vibration_value) {
|
||||
if (IsDeviceHandleValid(vibration_device_handle).IsError()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -803,7 +985,7 @@ void NPad::VibrateController(const Core::HID::VibrationDeviceHandle& vibration_d
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::VibrateControllers(
|
||||
void Controller_NPad::VibrateControllers(
|
||||
std::span<const Core::HID::VibrationDeviceHandle> vibration_device_handles,
|
||||
std::span<const Core::HID::VibrationValue> vibration_values) {
|
||||
if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) {
|
||||
@@ -820,9 +1002,9 @@ void NPad::VibrateControllers(
|
||||
}
|
||||
}
|
||||
|
||||
Core::HID::VibrationValue NPad::GetLastVibration(
|
||||
Core::HID::VibrationValue Controller_NPad::GetLastVibration(
|
||||
const Core::HID::VibrationDeviceHandle& vibration_device_handle) const {
|
||||
if (IsVibrationHandleValid(vibration_device_handle).IsError()) {
|
||||
if (IsDeviceHandleValid(vibration_device_handle).IsError()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -831,9 +1013,9 @@ Core::HID::VibrationValue NPad::GetLastVibration(
|
||||
return controller.vibration[device_index].latest_vibration_value;
|
||||
}
|
||||
|
||||
void NPad::InitializeVibrationDevice(
|
||||
void Controller_NPad::InitializeVibrationDevice(
|
||||
const Core::HID::VibrationDeviceHandle& vibration_device_handle) {
|
||||
if (IsVibrationHandleValid(vibration_device_handle).IsError()) {
|
||||
if (IsDeviceHandleValid(vibration_device_handle).IsError()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -842,8 +1024,8 @@ void NPad::InitializeVibrationDevice(
|
||||
InitializeVibrationDeviceAtIndex(npad_index, device_index);
|
||||
}
|
||||
|
||||
void NPad::InitializeVibrationDeviceAtIndex(Core::HID::NpadIdType npad_id,
|
||||
std::size_t device_index) {
|
||||
void Controller_NPad::InitializeVibrationDeviceAtIndex(Core::HID::NpadIdType npad_id,
|
||||
std::size_t device_index) {
|
||||
auto& controller = GetControllerFromNpadIdType(npad_id);
|
||||
if (!Settings::values.vibration_enabled.GetValue()) {
|
||||
controller.vibration[device_index].device_mounted = false;
|
||||
@@ -854,13 +1036,13 @@ void NPad::InitializeVibrationDeviceAtIndex(Core::HID::NpadIdType npad_id,
|
||||
controller.device->IsVibrationEnabled(device_index);
|
||||
}
|
||||
|
||||
void NPad::SetPermitVibrationSession(bool permit_vibration_session) {
|
||||
void Controller_NPad::SetPermitVibrationSession(bool permit_vibration_session) {
|
||||
permit_vibration_session_enabled = permit_vibration_session;
|
||||
}
|
||||
|
||||
bool NPad::IsVibrationDeviceMounted(
|
||||
bool Controller_NPad::IsVibrationDeviceMounted(
|
||||
const Core::HID::VibrationDeviceHandle& vibration_device_handle) const {
|
||||
if (IsVibrationHandleValid(vibration_device_handle).IsError()) {
|
||||
if (IsDeviceHandleValid(vibration_device_handle).IsError()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -869,7 +1051,7 @@ bool NPad::IsVibrationDeviceMounted(
|
||||
return controller.vibration[device_index].device_mounted;
|
||||
}
|
||||
|
||||
Kernel::KReadableEvent& NPad::GetStyleSetChangedEvent(Core::HID::NpadIdType npad_id) {
|
||||
Kernel::KReadableEvent& Controller_NPad::GetStyleSetChangedEvent(Core::HID::NpadIdType npad_id) {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
// Fallback to player 1
|
||||
@@ -881,17 +1063,18 @@ Kernel::KReadableEvent& NPad::GetStyleSetChangedEvent(Core::HID::NpadIdType npad
|
||||
return controller.styleset_changed_event->GetReadableEvent();
|
||||
}
|
||||
|
||||
void NPad::SignalStyleSetChangedEvent(Core::HID::NpadIdType npad_id) const {
|
||||
void Controller_NPad::SignalStyleSetChangedEvent(Core::HID::NpadIdType npad_id) const {
|
||||
const auto& controller = GetControllerFromNpadIdType(npad_id);
|
||||
controller.styleset_changed_event->Signal();
|
||||
}
|
||||
|
||||
void NPad::AddNewControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id) {
|
||||
void Controller_NPad::AddNewControllerAt(Core::HID::NpadStyleIndex controller,
|
||||
Core::HID::NpadIdType npad_id) {
|
||||
UpdateControllerAt(controller, npad_id, true);
|
||||
}
|
||||
|
||||
void NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type, Core::HID::NpadIdType npad_id,
|
||||
bool connected) {
|
||||
void Controller_NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type,
|
||||
Core::HID::NpadIdType npad_id, bool connected) {
|
||||
auto& controller = GetControllerFromNpadIdType(npad_id);
|
||||
if (!connected) {
|
||||
DisconnectNpad(npad_id);
|
||||
@@ -902,7 +1085,7 @@ void NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type, Core::HID::NpadIdT
|
||||
InitNewlyAddedController(npad_id);
|
||||
}
|
||||
|
||||
Result NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) {
|
||||
Result Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
return InvalidNpadId;
|
||||
@@ -951,9 +1134,54 @@ Result NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
|
||||
Result Controller_NPad::SetGyroscopeZeroDriftMode(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode drift_mode) {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
sixaxis.gyroscope_zero_drift_mode = drift_mode;
|
||||
controller.device->SetGyroscopeZeroDriftMode(drift_mode);
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::GetGyroscopeZeroDriftMode(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode& drift_mode) const {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
drift_mode = sixaxis.gyroscope_zero_drift_mode;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool& is_at_rest) const {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
is_at_rest = controller.sixaxis_at_rest;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
@@ -964,9 +1192,65 @@ Result NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result NPad::ResetIsSixAxisSensorDeviceNewlyAssigned(
|
||||
Result Controller_NPad::EnableSixAxisSensorUnalteredPassthrough(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled) {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
sixaxis.unaltered_passtrough = is_enabled;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
is_enabled = sixaxis.unaltered_passtrough;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::LoadSixAxisSensorCalibrationParameter(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorCalibrationParameter& calibration) const {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
// TODO: Request this data to the controller. On error return 0xd8ca
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
calibration = sixaxis.calibration;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::GetSixAxisSensorIcInformation(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorIcInformation& ic_information) const {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
// TODO: Request this data to the controller. On error return 0xd8ca
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
ic_information = sixaxis.ic_information;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Controller_NPad::ResetIsSixAxisSensorDeviceNewlyAssigned(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle) {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
@@ -978,32 +1262,83 @@ Result NPad::ResetIsSixAxisSensorDeviceNewlyAssigned(
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
NPad::SixAxisLifo& NPad::GetSixAxisFullkeyLifo(Core::HID::NpadIdType npad_id) {
|
||||
return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_fullkey_lifo;
|
||||
Result Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool sixaxis_status) {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
controller.sixaxis_sensor_enabled = sixaxis_status;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
NPad::SixAxisLifo& NPad::GetSixAxisHandheldLifo(Core::HID::NpadIdType npad_id) {
|
||||
return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_handheld_lifo;
|
||||
Result Controller_NPad::IsSixAxisSensorFusionEnabled(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_fusion_enabled) const {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
is_fusion_enabled = sixaxis.is_fusion_enabled;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
Result Controller_NPad::SetSixAxisFusionEnabled(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_fusion_enabled) {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
sixaxis.is_fusion_enabled = is_fusion_enabled;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
NPad::SixAxisLifo& NPad::GetSixAxisDualLeftLifo(Core::HID::NpadIdType npad_id) {
|
||||
return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_dual_left_lifo;
|
||||
Result Controller_NPad::SetSixAxisFusionParameters(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto param1 = sixaxis_fusion_parameters.parameter1;
|
||||
if (param1 < 0.0f || param1 > 1.0f) {
|
||||
return InvalidSixAxisFusionRange;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
sixaxis.fusion = sixaxis_fusion_parameters;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
NPad::SixAxisLifo& NPad::GetSixAxisDualRightLifo(Core::HID::NpadIdType npad_id) {
|
||||
return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_dual_right_lifo;
|
||||
Result Controller_NPad::GetSixAxisFusionParameters(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters& parameters) const {
|
||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
parameters = sixaxis.fusion;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
NPad::SixAxisLifo& NPad::GetSixAxisLeftLifo(Core::HID::NpadIdType npad_id) {
|
||||
return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_left_lifo;
|
||||
}
|
||||
|
||||
NPad::SixAxisLifo& NPad::GetSixAxisRightLifo(Core::HID::NpadIdType npad_id) {
|
||||
return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_right_lifo;
|
||||
}
|
||||
|
||||
Result NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
|
||||
Core::HID::NpadIdType npad_id_2) {
|
||||
Result Controller_NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
|
||||
Core::HID::NpadIdType npad_id_2) {
|
||||
if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1,
|
||||
npad_id_2);
|
||||
@@ -1065,17 +1400,18 @@ Result NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void NPad::StartLRAssignmentMode() {
|
||||
void Controller_NPad::StartLRAssignmentMode() {
|
||||
// Nothing internally is used for lr assignment mode. Since we have the ability to set the
|
||||
// controller types from boot, it doesn't really matter about showing a selection screen
|
||||
is_in_lr_assignment_mode = true;
|
||||
}
|
||||
|
||||
void NPad::StopLRAssignmentMode() {
|
||||
void Controller_NPad::StopLRAssignmentMode() {
|
||||
is_in_lr_assignment_mode = false;
|
||||
}
|
||||
|
||||
Result NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2) {
|
||||
Result Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1,
|
||||
Core::HID::NpadIdType npad_id_2) {
|
||||
if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1,
|
||||
npad_id_2);
|
||||
@@ -1106,7 +1442,8 @@ Result NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::Npad
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result NPad::GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const {
|
||||
Result Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id,
|
||||
Core::HID::LedPattern& pattern) const {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
return InvalidNpadId;
|
||||
@@ -1116,8 +1453,8 @@ Result NPad::GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern&
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
|
||||
bool& is_valid) const {
|
||||
Result Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
|
||||
bool& is_valid) const {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
return InvalidNpadId;
|
||||
@@ -1127,8 +1464,8 @@ Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result NPad::SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled,
|
||||
Core::HID::NpadIdType npad_id) {
|
||||
Result Controller_NPad::SetUnintendedHomeButtonInputProtectionEnabled(
|
||||
bool is_protection_enabled, Core::HID::NpadIdType npad_id) {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
return InvalidNpadId;
|
||||
@@ -1138,11 +1475,11 @@ Result NPad::SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_en
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void NPad::SetAnalogStickUseCenterClamp(bool use_center_clamp) {
|
||||
void Controller_NPad::SetAnalogStickUseCenterClamp(bool use_center_clamp) {
|
||||
analog_stick_use_center_clamp = use_center_clamp;
|
||||
}
|
||||
|
||||
void NPad::ClearAllConnectedControllers() {
|
||||
void Controller_NPad::ClearAllConnectedControllers() {
|
||||
for (auto& controller : controller_data) {
|
||||
if (controller.device->IsConnected() &&
|
||||
controller.device->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::None) {
|
||||
@@ -1152,13 +1489,13 @@ void NPad::ClearAllConnectedControllers() {
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::DisconnectAllConnectedControllers() {
|
||||
void Controller_NPad::DisconnectAllConnectedControllers() {
|
||||
for (auto& controller : controller_data) {
|
||||
controller.device->Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::ConnectAllDisconnectedControllers() {
|
||||
void Controller_NPad::ConnectAllDisconnectedControllers() {
|
||||
for (auto& controller : controller_data) {
|
||||
if (controller.device->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::None &&
|
||||
!controller.device->IsConnected()) {
|
||||
@@ -1167,18 +1504,18 @@ void NPad::ConnectAllDisconnectedControllers() {
|
||||
}
|
||||
}
|
||||
|
||||
void NPad::ClearAllControllers() {
|
||||
void Controller_NPad::ClearAllControllers() {
|
||||
for (auto& controller : controller_data) {
|
||||
controller.device->Disconnect();
|
||||
controller.device->SetNpadStyleIndex(Core::HID::NpadStyleIndex::None);
|
||||
}
|
||||
}
|
||||
|
||||
Core::HID::NpadButton NPad::GetAndResetPressState() {
|
||||
Core::HID::NpadButton Controller_NPad::GetAndResetPressState() {
|
||||
return static_cast<Core::HID::NpadButton>(press_state.exchange(0));
|
||||
}
|
||||
|
||||
void NPad::ApplyNpadSystemCommonPolicy() {
|
||||
void Controller_NPad::ApplyNpadSystemCommonPolicy() {
|
||||
Core::HID::NpadStyleTag styletag{};
|
||||
styletag.fullkey.Assign(1);
|
||||
styletag.handheld.Assign(1);
|
||||
@@ -1203,7 +1540,7 @@ void NPad::ApplyNpadSystemCommonPolicy() {
|
||||
supported_npad_id_types[9] = Core::HID::NpadIdType::Handheld;
|
||||
}
|
||||
|
||||
bool NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const {
|
||||
bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const {
|
||||
if (controller == Core::HID::NpadStyleIndex::Handheld) {
|
||||
const bool support_handheld =
|
||||
std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(),
|
||||
@@ -1254,50 +1591,51 @@ bool NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
NPad::NpadControllerData& NPad::GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle) {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
const NPad::NpadControllerData& NPad::GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle) const {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
NPad::NpadControllerData& NPad::GetControllerFromHandle(
|
||||
Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
const NPad::NpadControllerData& NPad::GetControllerFromHandle(
|
||||
const Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) const {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
NPad::NpadControllerData& NPad::GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) {
|
||||
Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle) {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
const Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle) const {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromNpadIdType(
|
||||
Core::HID::NpadIdType npad_id) {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
npad_id = Core::HID::NpadIdType::Player1;
|
||||
}
|
||||
const auto npad_index = NpadIdTypeToIndex(npad_id);
|
||||
const auto npad_index = Core::HID::NpadIdTypeToIndex(npad_id);
|
||||
return controller_data[npad_index];
|
||||
}
|
||||
|
||||
const NPad::NpadControllerData& NPad::GetControllerFromNpadIdType(
|
||||
const Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromNpadIdType(
|
||||
Core::HID::NpadIdType npad_id) const {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
npad_id = Core::HID::NpadIdType::Player1;
|
||||
}
|
||||
const auto npad_index = NpadIdTypeToIndex(npad_id);
|
||||
const auto npad_index = Core::HID::NpadIdTypeToIndex(npad_id);
|
||||
return controller_data[npad_index];
|
||||
}
|
||||
|
||||
Core::HID::SixAxisSensorProperties& NPad::GetSixaxisProperties(
|
||||
Core::HID::SixAxisSensorProperties& Controller_NPad::GetSixaxisProperties(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle) {
|
||||
auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
switch (sixaxis_handle.npad_type) {
|
||||
@@ -1320,7 +1658,7 @@ Core::HID::SixAxisSensorProperties& NPad::GetSixaxisProperties(
|
||||
}
|
||||
}
|
||||
|
||||
const Core::HID::SixAxisSensorProperties& NPad::GetSixaxisProperties(
|
||||
const Core::HID::SixAxisSensorProperties& Controller_NPad::GetSixaxisProperties(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle) const {
|
||||
const auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
switch (sixaxis_handle.npad_type) {
|
||||
@@ -1343,13 +1681,65 @@ const Core::HID::SixAxisSensorProperties& NPad::GetSixaxisProperties(
|
||||
}
|
||||
}
|
||||
|
||||
NPad::AppletDetailedUiType NPad::GetAppletDetailedUiType(Core::HID::NpadIdType npad_id) {
|
||||
const auto& shared_memory = GetControllerFromNpadIdType(npad_id).shared_memory;
|
||||
Controller_NPad::SixaxisParameters& Controller_NPad::GetSixaxisState(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle) {
|
||||
auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
switch (sixaxis_handle.npad_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::Pokeball:
|
||||
return controller.sixaxis_fullkey;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
return controller.sixaxis_handheld;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) {
|
||||
return controller.sixaxis_dual_left;
|
||||
}
|
||||
return controller.sixaxis_dual_right;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
return controller.sixaxis_left;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
return controller.sixaxis_right;
|
||||
default:
|
||||
return controller.sixaxis_unknown;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
const Controller_NPad::SixaxisParameters& Controller_NPad::GetSixaxisState(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle) const {
|
||||
const auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
switch (sixaxis_handle.npad_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::Pokeball:
|
||||
return controller.sixaxis_fullkey;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
return controller.sixaxis_handheld;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) {
|
||||
return controller.sixaxis_dual_left;
|
||||
}
|
||||
return controller.sixaxis_dual_right;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
return controller.sixaxis_left;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
return controller.sixaxis_right;
|
||||
default:
|
||||
return controller.sixaxis_unknown;
|
||||
}
|
||||
}
|
||||
|
||||
Controller_NPad::AppletDetailedUiType Controller_NPad::GetAppletDetailedUiType(
|
||||
Core::HID::NpadIdType npad_id) {
|
||||
|
||||
auto controller = GetControllerFromNpadIdType(npad_id);
|
||||
auto shared_memory = controller.shared_memory;
|
||||
Service::HID::Controller_NPad::AppletFooterUiType applet_footer_type =
|
||||
shared_memory->applet_footer_type;
|
||||
|
||||
Controller_NPad::AppletDetailedUiType detailed_ui_type{
|
||||
.ui_variant = 0,
|
||||
.footer = shared_memory->applet_footer_type,
|
||||
.footer = applet_footer_type,
|
||||
};
|
||||
return detailed_ui_type;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/vector_math.h"
|
||||
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||
@@ -33,11 +34,11 @@ union Result;
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
class NPad final : public ControllerBase {
|
||||
class Controller_NPad final : public ControllerBase {
|
||||
public:
|
||||
explicit NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_);
|
||||
~NPad() override;
|
||||
explicit Controller_NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_);
|
||||
~Controller_NPad() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
@@ -48,6 +49,9 @@ public:
|
||||
// When the controller is requesting an update for the shared memory
|
||||
void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
|
||||
|
||||
// When the controller is requesting a motion update for the shared memory
|
||||
void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) override;
|
||||
|
||||
// This is nn::hid::NpadJoyHoldType
|
||||
enum class NpadJoyHoldType : u64 {
|
||||
Vertical = 0,
|
||||
@@ -129,8 +133,6 @@ public:
|
||||
Revision3 = 3,
|
||||
};
|
||||
|
||||
using SixAxisLifo = Lifo<Core::HID::SixAxisSensorState, hid_entry_count>;
|
||||
|
||||
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
|
||||
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
|
||||
|
||||
@@ -183,18 +185,37 @@ public:
|
||||
|
||||
Result DisconnectNpad(Core::HID::NpadIdType npad_id);
|
||||
|
||||
Result SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode drift_mode);
|
||||
Result GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode& drift_mode) const;
|
||||
Result IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool& is_at_rest) const;
|
||||
Result IsFirmwareUpdateAvailableForSixAxisSensor(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const;
|
||||
Result EnableSixAxisSensorUnalteredPassthrough(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled);
|
||||
Result IsSixAxisSensorUnalteredPassthroughEnabled(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const;
|
||||
Result LoadSixAxisSensorCalibrationParameter(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorCalibrationParameter& calibration) const;
|
||||
Result GetSixAxisSensorIcInformation(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorIcInformation& ic_information) const;
|
||||
Result ResetIsSixAxisSensorDeviceNewlyAssigned(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle);
|
||||
|
||||
SixAxisLifo& GetSixAxisFullkeyLifo(Core::HID::NpadIdType npad_id);
|
||||
SixAxisLifo& GetSixAxisHandheldLifo(Core::HID::NpadIdType npad_id);
|
||||
SixAxisLifo& GetSixAxisDualLeftLifo(Core::HID::NpadIdType npad_id);
|
||||
SixAxisLifo& GetSixAxisDualRightLifo(Core::HID::NpadIdType npad_id);
|
||||
SixAxisLifo& GetSixAxisLeftLifo(Core::HID::NpadIdType npad_id);
|
||||
SixAxisLifo& GetSixAxisRightLifo(Core::HID::NpadIdType npad_id);
|
||||
|
||||
Result SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool sixaxis_status);
|
||||
Result IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool& is_fusion_enabled) const;
|
||||
Result SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool is_fusion_enabled);
|
||||
Result SetSixAxisFusionParameters(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters);
|
||||
Result GetSixAxisFusionParameters(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters& parameters) const;
|
||||
Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const;
|
||||
Result IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
|
||||
bool& is_enabled) const;
|
||||
@@ -218,6 +239,10 @@ public:
|
||||
|
||||
void ApplyNpadSystemCommonPolicy();
|
||||
|
||||
static bool IsNpadIdValid(Core::HID::NpadIdType npad_id);
|
||||
static Result IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
|
||||
static Result VerifyValidSixAxisSensorHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle);
|
||||
AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id);
|
||||
|
||||
private:
|
||||
@@ -277,6 +302,29 @@ private:
|
||||
};
|
||||
static_assert(sizeof(NPadGenericState) == 0x28, "NPadGenericState is an invalid size");
|
||||
|
||||
// This is nn::hid::SixAxisSensorAttribute
|
||||
struct SixAxisSensorAttribute {
|
||||
union {
|
||||
u32 raw{};
|
||||
BitField<0, 1, u32> is_connected;
|
||||
BitField<1, 1, u32> is_interpolated;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(SixAxisSensorAttribute) == 4, "SixAxisSensorAttribute is an invalid size");
|
||||
|
||||
// This is nn::hid::SixAxisSensorState
|
||||
struct SixAxisSensorState {
|
||||
s64 delta_time{};
|
||||
s64 sampling_number{};
|
||||
Common::Vec3f accel{};
|
||||
Common::Vec3f gyro{};
|
||||
Common::Vec3f rotation{};
|
||||
std::array<Common::Vec3f, 3> orientation{};
|
||||
SixAxisSensorAttribute attribute{};
|
||||
INSERT_PADDING_BYTES(4); // Reserved
|
||||
};
|
||||
static_assert(sizeof(SixAxisSensorState) == 0x60, "SixAxisSensorState is an invalid size");
|
||||
|
||||
// This is nn::hid::server::NpadGcTriggerState
|
||||
struct NpadGcTriggerState {
|
||||
s64 sampling_number{};
|
||||
@@ -396,12 +444,12 @@ private:
|
||||
Lifo<NPadGenericState, hid_entry_count> joy_right_lifo{};
|
||||
Lifo<NPadGenericState, hid_entry_count> palma_lifo{};
|
||||
Lifo<NPadGenericState, hid_entry_count> system_ext_lifo{};
|
||||
Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_fullkey_lifo{};
|
||||
Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_handheld_lifo{};
|
||||
Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_dual_left_lifo{};
|
||||
Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_dual_right_lifo{};
|
||||
Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_left_lifo{};
|
||||
Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_right_lifo{};
|
||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_fullkey_lifo{};
|
||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_handheld_lifo{};
|
||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_left_lifo{};
|
||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_right_lifo{};
|
||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_left_lifo{};
|
||||
Lifo<SixAxisSensorState, hid_entry_count> sixaxis_right_lifo{};
|
||||
DeviceType device_type{};
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
NPadSystemProperties system_properties{};
|
||||
@@ -435,6 +483,16 @@ private:
|
||||
std::chrono::steady_clock::time_point last_vibration_timepoint{};
|
||||
};
|
||||
|
||||
struct SixaxisParameters {
|
||||
bool is_fusion_enabled{true};
|
||||
bool unaltered_passtrough{false};
|
||||
Core::HID::SixAxisSensorFusionParameters fusion{};
|
||||
Core::HID::SixAxisSensorCalibrationParameter calibration{};
|
||||
Core::HID::SixAxisSensorIcInformation ic_information{};
|
||||
Core::HID::GyroscopeZeroDriftMode gyroscope_zero_drift_mode{
|
||||
Core::HID::GyroscopeZeroDriftMode::Standard};
|
||||
};
|
||||
|
||||
struct NpadControllerData {
|
||||
Kernel::KEvent* styleset_changed_event{};
|
||||
NpadInternalState* shared_memory = nullptr;
|
||||
@@ -448,10 +506,27 @@ private:
|
||||
bool is_dual_left_connected{true};
|
||||
bool is_dual_right_connected{true};
|
||||
|
||||
// Motion parameters
|
||||
bool sixaxis_at_rest{true};
|
||||
bool sixaxis_sensor_enabled{true};
|
||||
SixaxisParameters sixaxis_fullkey{};
|
||||
SixaxisParameters sixaxis_handheld{};
|
||||
SixaxisParameters sixaxis_dual_left{};
|
||||
SixaxisParameters sixaxis_dual_right{};
|
||||
SixaxisParameters sixaxis_left{};
|
||||
SixaxisParameters sixaxis_right{};
|
||||
SixaxisParameters sixaxis_unknown{};
|
||||
|
||||
// Current pad state
|
||||
NPadGenericState npad_pad_state{};
|
||||
NPadGenericState npad_libnx_state{};
|
||||
NpadGcTriggerState npad_trigger_state{};
|
||||
SixAxisSensorState sixaxis_fullkey_state{};
|
||||
SixAxisSensorState sixaxis_handheld_state{};
|
||||
SixAxisSensorState sixaxis_dual_left_state{};
|
||||
SixAxisSensorState sixaxis_dual_right_state{};
|
||||
SixAxisSensorState sixaxis_left_lifo_state{};
|
||||
SixAxisSensorState sixaxis_right_lifo_state{};
|
||||
int callback_key{};
|
||||
};
|
||||
|
||||
@@ -461,14 +536,14 @@ private:
|
||||
void RequestPadStateUpdate(Core::HID::NpadIdType npad_id);
|
||||
void WriteEmptyEntry(NpadInternalState* npad);
|
||||
|
||||
NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle);
|
||||
const NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle) const;
|
||||
NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle);
|
||||
const NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) const;
|
||||
NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle);
|
||||
const NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::VibrationDeviceHandle& device_handle) const;
|
||||
NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id);
|
||||
const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const;
|
||||
|
||||
@@ -476,6 +551,9 @@ private:
|
||||
const Core::HID::SixAxisSensorHandle& device_handle);
|
||||
const Core::HID::SixAxisSensorProperties& GetSixaxisProperties(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) const;
|
||||
SixaxisParameters& GetSixaxisState(const Core::HID::SixAxisSensorHandle& device_handle);
|
||||
const SixaxisParameters& GetSixaxisState(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) const;
|
||||
|
||||
std::atomic<u64> press_state{};
|
||||
|
||||
|
||||
@@ -12,35 +12,35 @@
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
Palma::Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_)
|
||||
Controller_Palma::Controller_Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_)
|
||||
: ControllerBase{hid_core_}, service_context{service_context_} {
|
||||
controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other);
|
||||
operation_complete_event = service_context.CreateEvent("hid:PalmaOperationCompleteEvent");
|
||||
}
|
||||
|
||||
Palma::~Palma() {
|
||||
Controller_Palma::~Controller_Palma() {
|
||||
service_context.CloseEvent(operation_complete_event);
|
||||
};
|
||||
|
||||
void Palma::OnInit() {}
|
||||
void Controller_Palma::OnInit() {}
|
||||
|
||||
void Palma::OnRelease() {}
|
||||
void Controller_Palma::OnRelease() {}
|
||||
|
||||
void Palma::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_Palma::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Result Palma::GetPalmaConnectionHandle(Core::HID::NpadIdType npad_id,
|
||||
PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::GetPalmaConnectionHandle(Core::HID::NpadIdType npad_id,
|
||||
PalmaConnectionHandle& handle) {
|
||||
active_handle.npad_id = npad_id;
|
||||
handle = active_handle;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::InitializePalma(const PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::InitializePalma(const PalmaConnectionHandle& handle) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ Result Palma::InitializePalma(const PalmaConnectionHandle& handle) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Kernel::KReadableEvent& Palma::AcquirePalmaOperationCompleteEvent(
|
||||
Kernel::KReadableEvent& Controller_Palma::AcquirePalmaOperationCompleteEvent(
|
||||
const PalmaConnectionHandle& handle) const {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
LOG_ERROR(Service_HID, "Invalid npad id {}", handle.npad_id);
|
||||
@@ -56,9 +56,9 @@ Kernel::KReadableEvent& Palma::AcquirePalmaOperationCompleteEvent(
|
||||
return operation_complete_event->GetReadableEvent();
|
||||
}
|
||||
|
||||
Result Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle,
|
||||
PalmaOperationType& operation_type,
|
||||
PalmaOperationData& data) const {
|
||||
Result Controller_Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle,
|
||||
PalmaOperationType& operation_type,
|
||||
PalmaOperationData& data) const {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -67,7 +67,8 @@ Result Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle,
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_activity) {
|
||||
Result Controller_Palma::PlayPalmaActivity(const PalmaConnectionHandle& handle,
|
||||
u64 palma_activity) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -78,7 +79,8 @@ Result Palma::PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_a
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::SetPalmaFrModeType(const PalmaConnectionHandle& handle, PalmaFrModeType fr_mode_) {
|
||||
Result Controller_Palma::SetPalmaFrModeType(const PalmaConnectionHandle& handle,
|
||||
PalmaFrModeType fr_mode_) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -86,7 +88,7 @@ Result Palma::SetPalmaFrModeType(const PalmaConnectionHandle& handle, PalmaFrMod
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::ReadPalmaStep(const PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::ReadPalmaStep(const PalmaConnectionHandle& handle) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -97,25 +99,25 @@ Result Palma::ReadPalmaStep(const PalmaConnectionHandle& handle) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::EnablePalmaStep(const PalmaConnectionHandle& handle, bool is_enabled) {
|
||||
Result Controller_Palma::EnablePalmaStep(const PalmaConnectionHandle& handle, bool is_enabled) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::ResetPalmaStep(const PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::ResetPalmaStep(const PalmaConnectionHandle& handle) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void Palma::ReadPalmaApplicationSection() {}
|
||||
void Controller_Palma::ReadPalmaApplicationSection() {}
|
||||
|
||||
void Palma::WritePalmaApplicationSection() {}
|
||||
void Controller_Palma::WritePalmaApplicationSection() {}
|
||||
|
||||
Result Palma::ReadPalmaUniqueCode(const PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::ReadPalmaUniqueCode(const PalmaConnectionHandle& handle) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -126,7 +128,7 @@ Result Palma::ReadPalmaUniqueCode(const PalmaConnectionHandle& handle) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -137,9 +139,10 @@ Result Palma::SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void Palma::WritePalmaActivityEntry() {}
|
||||
void Controller_Palma::WritePalmaActivityEntry() {}
|
||||
|
||||
Result Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle, u64 unknown) {
|
||||
Result Controller_Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle,
|
||||
u64 unknown) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -150,8 +153,8 @@ Result Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle,
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave,
|
||||
Common::ProcessAddress t_mem, u64 size) {
|
||||
Result Controller_Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave,
|
||||
Common::ProcessAddress t_mem, u64 size) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -162,8 +165,8 @@ Result Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWave
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle,
|
||||
s32 database_id_version_) {
|
||||
Result Controller_Palma::SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle,
|
||||
s32 database_id_version_) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -175,7 +178,8 @@ Result Palma::SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle&
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Palma::GetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::GetPalmaDataBaseIdentificationVersion(
|
||||
const PalmaConnectionHandle& handle) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -187,26 +191,26 @@ Result Palma::GetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle&
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void Palma::SuspendPalmaFeature() {}
|
||||
void Controller_Palma::SuspendPalmaFeature() {}
|
||||
|
||||
Result Palma::GetPalmaOperationResult(const PalmaConnectionHandle& handle) const {
|
||||
Result Controller_Palma::GetPalmaOperationResult(const PalmaConnectionHandle& handle) const {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
return operation.result;
|
||||
}
|
||||
void Palma::ReadPalmaPlayLog() {}
|
||||
void Controller_Palma::ReadPalmaPlayLog() {}
|
||||
|
||||
void Palma::ResetPalmaPlayLog() {}
|
||||
void Controller_Palma::ResetPalmaPlayLog() {}
|
||||
|
||||
void Palma::SetIsPalmaAllConnectable(bool is_all_connectable) {
|
||||
void Controller_Palma::SetIsPalmaAllConnectable(bool is_all_connectable) {
|
||||
// If true controllers are able to be paired
|
||||
is_connectable = is_all_connectable;
|
||||
}
|
||||
|
||||
void Palma::SetIsPalmaPairedConnectable() {}
|
||||
void Controller_Palma::SetIsPalmaPairedConnectable() {}
|
||||
|
||||
Result Palma::PairPalma(const PalmaConnectionHandle& handle) {
|
||||
Result Controller_Palma::PairPalma(const PalmaConnectionHandle& handle) {
|
||||
if (handle.npad_id != active_handle.npad_id) {
|
||||
return InvalidPalmaHandle;
|
||||
}
|
||||
@@ -214,14 +218,14 @@ Result Palma::PairPalma(const PalmaConnectionHandle& handle) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void Palma::SetPalmaBoostMode(bool boost_mode) {}
|
||||
void Controller_Palma::SetPalmaBoostMode(bool boost_mode) {}
|
||||
|
||||
void Palma::CancelWritePalmaWaveEntry() {}
|
||||
void Controller_Palma::CancelWritePalmaWaveEntry() {}
|
||||
|
||||
void Palma::EnablePalmaBoostMode() {}
|
||||
void Controller_Palma::EnablePalmaBoostMode() {}
|
||||
|
||||
void Palma::GetPalmaBluetoothAddress() {}
|
||||
void Controller_Palma::GetPalmaBluetoothAddress() {}
|
||||
|
||||
void Palma::SetDisallowedPalmaConnection() {}
|
||||
void Controller_Palma::SetDisallowedPalmaConnection() {}
|
||||
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -23,7 +23,7 @@ class EmulatedController;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class Palma final : public ControllerBase {
|
||||
class Controller_Palma final : public ControllerBase {
|
||||
public:
|
||||
using PalmaOperationData = std::array<u8, 0x140>;
|
||||
|
||||
@@ -97,9 +97,9 @@ public:
|
||||
static_assert(sizeof(PalmaConnectionHandle) == 0x8,
|
||||
"PalmaConnectionHandle has incorrect size.");
|
||||
|
||||
explicit Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_);
|
||||
~Palma() override;
|
||||
explicit Controller_Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
|
||||
KernelHelpers::ServiceContext& service_context_);
|
||||
~Controller_Palma() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
@@ -1,413 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/controllers/npad.h"
|
||||
#include "core/hle/service/hid/controllers/six_axis.h"
|
||||
#include "core/hle/service/hid/errors.h"
|
||||
#include "core/hle/service/hid/hid_util.h"
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
SixAxis::SixAxis(Core::HID::HIDCore& hid_core_, std::shared_ptr<NPad> npad_)
|
||||
: ControllerBase{hid_core_}, npad{npad_} {
|
||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||
auto& controller = controller_data[i];
|
||||
controller.device = hid_core.GetEmulatedControllerByIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
SixAxis::~SixAxis() = default;
|
||||
|
||||
void SixAxis::OnInit() {}
|
||||
void SixAxis::OnRelease() {}
|
||||
|
||||
void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||
auto& controller = controller_data[i];
|
||||
|
||||
const auto npad_id = IndexToNpadIdType(i);
|
||||
const auto& controller_type = controller.device->GetNpadStyleIndex();
|
||||
|
||||
if (controller_type == Core::HID::NpadStyleIndex::None ||
|
||||
!controller.device->IsConnected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& motion_state = controller.device->GetMotions();
|
||||
auto& sixaxis_fullkey_state = controller.sixaxis_fullkey_state;
|
||||
auto& sixaxis_handheld_state = controller.sixaxis_handheld_state;
|
||||
auto& sixaxis_dual_left_state = controller.sixaxis_dual_left_state;
|
||||
auto& sixaxis_dual_right_state = controller.sixaxis_dual_right_state;
|
||||
auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state;
|
||||
auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state;
|
||||
|
||||
auto& sixaxis_fullkey_lifo = npad->GetSixAxisFullkeyLifo(npad_id);
|
||||
auto& sixaxis_handheld_lifo = npad->GetSixAxisHandheldLifo(npad_id);
|
||||
auto& sixaxis_dual_left_lifo = npad->GetSixAxisDualLeftLifo(npad_id);
|
||||
auto& sixaxis_dual_right_lifo = npad->GetSixAxisDualRightLifo(npad_id);
|
||||
auto& sixaxis_left_lifo = npad->GetSixAxisLeftLifo(npad_id);
|
||||
auto& sixaxis_right_lifo = npad->GetSixAxisRightLifo(npad_id);
|
||||
|
||||
// Clear previous state
|
||||
sixaxis_fullkey_state = {};
|
||||
sixaxis_handheld_state = {};
|
||||
sixaxis_dual_left_state = {};
|
||||
sixaxis_dual_right_state = {};
|
||||
sixaxis_left_lifo_state = {};
|
||||
sixaxis_right_lifo_state = {};
|
||||
|
||||
if (controller.sixaxis_sensor_enabled && Settings::values.motion_enabled.GetValue()) {
|
||||
controller.sixaxis_at_rest = true;
|
||||
for (std::size_t e = 0; e < motion_state.size(); ++e) {
|
||||
controller.sixaxis_at_rest =
|
||||
controller.sixaxis_at_rest && motion_state[e].is_at_rest;
|
||||
}
|
||||
}
|
||||
|
||||
const auto set_motion_state = [&](Core::HID::SixAxisSensorState& state,
|
||||
const Core::HID::ControllerMotion& hid_state) {
|
||||
using namespace std::literals::chrono_literals;
|
||||
static constexpr Core::HID::SixAxisSensorState default_motion_state = {
|
||||
.delta_time = std::chrono::nanoseconds(5ms).count(),
|
||||
.accel = {0, 0, -1.0f},
|
||||
.orientation =
|
||||
{
|
||||
Common::Vec3f{1.0f, 0, 0},
|
||||
Common::Vec3f{0, 1.0f, 0},
|
||||
Common::Vec3f{0, 0, 1.0f},
|
||||
},
|
||||
.attribute = {1},
|
||||
};
|
||||
if (!controller.sixaxis_sensor_enabled) {
|
||||
state = default_motion_state;
|
||||
return;
|
||||
}
|
||||
if (!Settings::values.motion_enabled.GetValue()) {
|
||||
state = default_motion_state;
|
||||
return;
|
||||
}
|
||||
state.attribute.is_connected.Assign(1);
|
||||
state.delta_time = std::chrono::nanoseconds(5ms).count();
|
||||
state.accel = hid_state.accel;
|
||||
state.gyro = hid_state.gyro;
|
||||
state.rotation = hid_state.rotation;
|
||||
state.orientation = hid_state.orientation;
|
||||
};
|
||||
|
||||
switch (controller_type) {
|
||||
case Core::HID::NpadStyleIndex::None:
|
||||
ASSERT(false);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
set_motion_state(sixaxis_handheld_state, motion_state[0]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
set_motion_state(sixaxis_dual_left_state, motion_state[0]);
|
||||
set_motion_state(sixaxis_dual_right_state, motion_state[1]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
set_motion_state(sixaxis_left_lifo_state, motion_state[0]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
set_motion_state(sixaxis_right_lifo_state, motion_state[1]);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::Pokeball:
|
||||
using namespace std::literals::chrono_literals;
|
||||
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
||||
sixaxis_fullkey_state.delta_time = std::chrono::nanoseconds(15ms).count();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sixaxis_fullkey_state.sampling_number =
|
||||
sixaxis_fullkey_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_handheld_state.sampling_number =
|
||||
sixaxis_handheld_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_dual_left_state.sampling_number =
|
||||
sixaxis_dual_left_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_dual_right_state.sampling_number =
|
||||
sixaxis_dual_right_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_left_lifo_state.sampling_number =
|
||||
sixaxis_left_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
sixaxis_right_lifo_state.sampling_number =
|
||||
sixaxis_right_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
|
||||
if (IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) {
|
||||
// This buffer only is updated on handheld on HW
|
||||
sixaxis_handheld_lifo.WriteNextEntry(sixaxis_handheld_state);
|
||||
} else {
|
||||
// Handheld doesn't update this buffer on HW
|
||||
sixaxis_fullkey_lifo.WriteNextEntry(sixaxis_fullkey_state);
|
||||
}
|
||||
|
||||
sixaxis_dual_left_lifo.WriteNextEntry(sixaxis_dual_left_state);
|
||||
sixaxis_dual_right_lifo.WriteNextEntry(sixaxis_dual_right_state);
|
||||
sixaxis_left_lifo.WriteNextEntry(sixaxis_left_lifo_state);
|
||||
sixaxis_right_lifo.WriteNextEntry(sixaxis_right_lifo_state);
|
||||
}
|
||||
}
|
||||
|
||||
Result SixAxis::SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode drift_mode) {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
sixaxis.gyroscope_zero_drift_mode = drift_mode;
|
||||
controller.device->SetGyroscopeZeroDriftMode(drift_mode);
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode& drift_mode) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
drift_mode = sixaxis.gyroscope_zero_drift_mode;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool& is_at_rest) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
is_at_rest = controller.sixaxis_at_rest;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::LoadSixAxisSensorCalibrationParameter(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorCalibrationParameter& calibration) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
// TODO: Request this data to the controller. On error return 0xd8ca
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
calibration = sixaxis.calibration;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::GetSixAxisSensorIcInformation(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorIcInformation& ic_information) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
// TODO: Request this data to the controller. On error return 0xd8ca
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
ic_information = sixaxis.ic_information;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::EnableSixAxisSensorUnalteredPassthrough(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled) {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
sixaxis.unaltered_passtrough = is_enabled;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::IsSixAxisSensorUnalteredPassthroughEnabled(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
is_enabled = sixaxis.unaltered_passtrough;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool sixaxis_status) {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
controller.sixaxis_sensor_enabled = sixaxis_status;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool& is_fusion_enabled) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
is_fusion_enabled = sixaxis.is_fusion_enabled;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
Result SixAxis::SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool is_fusion_enabled) {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
sixaxis.is_fusion_enabled = is_fusion_enabled;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::SetSixAxisFusionParameters(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto param1 = sixaxis_fusion_parameters.parameter1;
|
||||
if (param1 < 0.0f || param1 > 1.0f) {
|
||||
return InvalidSixAxisFusionRange;
|
||||
}
|
||||
|
||||
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
sixaxis.fusion = sixaxis_fusion_parameters;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SixAxis::GetSixAxisFusionParameters(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters& parameters) const {
|
||||
const auto is_valid = IsSixaxisHandleValid(sixaxis_handle);
|
||||
if (is_valid.IsError()) {
|
||||
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||
parameters = sixaxis.fusion;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
SixAxis::SixaxisParameters& SixAxis::GetSixaxisState(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle) {
|
||||
auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
switch (sixaxis_handle.npad_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::Pokeball:
|
||||
return controller.sixaxis_fullkey;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
return controller.sixaxis_handheld;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) {
|
||||
return controller.sixaxis_dual_left;
|
||||
}
|
||||
return controller.sixaxis_dual_right;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
return controller.sixaxis_left;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
return controller.sixaxis_right;
|
||||
default:
|
||||
return controller.sixaxis_unknown;
|
||||
}
|
||||
}
|
||||
|
||||
const SixAxis::SixaxisParameters& SixAxis::GetSixaxisState(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle) const {
|
||||
const auto& controller = GetControllerFromHandle(sixaxis_handle);
|
||||
switch (sixaxis_handle.npad_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::Pokeball:
|
||||
return controller.sixaxis_fullkey;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
return controller.sixaxis_handheld;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) {
|
||||
return controller.sixaxis_dual_left;
|
||||
}
|
||||
return controller.sixaxis_dual_right;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
return controller.sixaxis_left;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
return controller.sixaxis_right;
|
||||
default:
|
||||
return controller.sixaxis_unknown;
|
||||
}
|
||||
}
|
||||
|
||||
SixAxis::NpadControllerData& SixAxis::GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
const SixAxis::NpadControllerData& SixAxis::GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) const {
|
||||
const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id);
|
||||
return GetControllerFromNpadIdType(npad_id);
|
||||
}
|
||||
|
||||
SixAxis::NpadControllerData& SixAxis::GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
npad_id = Core::HID::NpadIdType::Player1;
|
||||
}
|
||||
const auto npad_index = NpadIdTypeToIndex(npad_id);
|
||||
return controller_data[npad_index];
|
||||
}
|
||||
|
||||
const SixAxis::NpadControllerData& SixAxis::GetControllerFromNpadIdType(
|
||||
Core::HID::NpadIdType npad_id) const {
|
||||
if (!IsNpadIdValid(npad_id)) {
|
||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
||||
npad_id = Core::HID::NpadIdType::Player1;
|
||||
}
|
||||
const auto npad_index = NpadIdTypeToIndex(npad_id);
|
||||
return controller_data[npad_index];
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
@@ -1,111 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||
#include "core/hle/service/hid/ring_lifo.h"
|
||||
|
||||
namespace Core::HID {
|
||||
class EmulatedController;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class NPad;
|
||||
|
||||
class SixAxis final : public ControllerBase {
|
||||
public:
|
||||
explicit SixAxis(Core::HID::HIDCore& hid_core_, std::shared_ptr<NPad> npad_);
|
||||
~SixAxis() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
// When the controller is released
|
||||
void OnRelease() override;
|
||||
|
||||
// When the controller is requesting an update for the shared memory
|
||||
void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
|
||||
|
||||
Result SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode drift_mode);
|
||||
Result GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::GyroscopeZeroDriftMode& drift_mode) const;
|
||||
Result IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool& is_at_rest) const;
|
||||
Result EnableSixAxisSensorUnalteredPassthrough(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled);
|
||||
Result IsSixAxisSensorUnalteredPassthroughEnabled(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const;
|
||||
Result LoadSixAxisSensorCalibrationParameter(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorCalibrationParameter& calibration) const;
|
||||
Result GetSixAxisSensorIcInformation(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorIcInformation& ic_information) const;
|
||||
Result SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool sixaxis_status);
|
||||
Result IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool& is_fusion_enabled) const;
|
||||
Result SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
bool is_fusion_enabled);
|
||||
Result SetSixAxisFusionParameters(
|
||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters);
|
||||
Result GetSixAxisFusionParameters(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||
Core::HID::SixAxisSensorFusionParameters& parameters) const;
|
||||
|
||||
private:
|
||||
static constexpr std::size_t NPAD_COUNT = 10;
|
||||
|
||||
struct SixaxisParameters {
|
||||
bool is_fusion_enabled{true};
|
||||
bool unaltered_passtrough{false};
|
||||
Core::HID::SixAxisSensorFusionParameters fusion{};
|
||||
Core::HID::SixAxisSensorCalibrationParameter calibration{};
|
||||
Core::HID::SixAxisSensorIcInformation ic_information{};
|
||||
Core::HID::GyroscopeZeroDriftMode gyroscope_zero_drift_mode{
|
||||
Core::HID::GyroscopeZeroDriftMode::Standard};
|
||||
};
|
||||
|
||||
struct NpadControllerData {
|
||||
Core::HID::EmulatedController* device = nullptr;
|
||||
|
||||
// Motion parameters
|
||||
bool sixaxis_at_rest{true};
|
||||
bool sixaxis_sensor_enabled{true};
|
||||
SixaxisParameters sixaxis_fullkey{};
|
||||
SixaxisParameters sixaxis_handheld{};
|
||||
SixaxisParameters sixaxis_dual_left{};
|
||||
SixaxisParameters sixaxis_dual_right{};
|
||||
SixaxisParameters sixaxis_left{};
|
||||
SixaxisParameters sixaxis_right{};
|
||||
SixaxisParameters sixaxis_unknown{};
|
||||
|
||||
// Current pad state
|
||||
Core::HID::SixAxisSensorState sixaxis_fullkey_state{};
|
||||
Core::HID::SixAxisSensorState sixaxis_handheld_state{};
|
||||
Core::HID::SixAxisSensorState sixaxis_dual_left_state{};
|
||||
Core::HID::SixAxisSensorState sixaxis_dual_right_state{};
|
||||
Core::HID::SixAxisSensorState sixaxis_left_lifo_state{};
|
||||
Core::HID::SixAxisSensorState sixaxis_right_lifo_state{};
|
||||
int callback_key{};
|
||||
};
|
||||
|
||||
SixaxisParameters& GetSixaxisState(const Core::HID::SixAxisSensorHandle& device_handle);
|
||||
const SixaxisParameters& GetSixaxisState(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) const;
|
||||
|
||||
NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle);
|
||||
const NpadControllerData& GetControllerFromHandle(
|
||||
const Core::HID::SixAxisSensorHandle& device_handle) const;
|
||||
NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id);
|
||||
const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const;
|
||||
|
||||
std::shared_ptr<NPad> npad;
|
||||
std::array<NpadControllerData, NPAD_COUNT> controller_data{};
|
||||
};
|
||||
} // namespace Service::HID
|
||||
@@ -15,7 +15,8 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400;
|
||||
|
||||
TouchScreen::TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
Controller_Touchscreen::Controller_Touchscreen(Core::HID::HIDCore& hid_core_,
|
||||
u8* raw_shared_memory_)
|
||||
: ControllerBase{hid_core_} {
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size,
|
||||
"TouchSharedMemory is bigger than the shared memory");
|
||||
@@ -24,13 +25,13 @@ TouchScreen::TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
console = hid_core.GetEmulatedConsole();
|
||||
}
|
||||
|
||||
TouchScreen::~TouchScreen() = default;
|
||||
Controller_Touchscreen::~Controller_Touchscreen() = default;
|
||||
|
||||
void TouchScreen::OnInit() {}
|
||||
void Controller_Touchscreen::OnInit() {}
|
||||
|
||||
void TouchScreen::OnRelease() {}
|
||||
void Controller_Touchscreen::OnRelease() {}
|
||||
|
||||
void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
shared_memory->touch_screen_lifo.timestamp = core_timing.GetGlobalTimeNs().count();
|
||||
|
||||
if (!IsControllerActivated()) {
|
||||
|
||||
@@ -14,10 +14,10 @@ class EmulatedConsole;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class TouchScreen final : public ControllerBase {
|
||||
class Controller_Touchscreen final : public ControllerBase {
|
||||
public:
|
||||
explicit TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~TouchScreen() override;
|
||||
explicit Controller_Touchscreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Controller_Touchscreen() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
@@ -10,19 +10,20 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00;
|
||||
|
||||
XPad::XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) : ControllerBase{hid_core_} {
|
||||
Controller_XPad::Controller_XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_)
|
||||
: ControllerBase{hid_core_} {
|
||||
static_assert(SHARED_MEMORY_OFFSET + sizeof(XpadSharedMemory) < shared_memory_size,
|
||||
"XpadSharedMemory is bigger than the shared memory");
|
||||
shared_memory = std::construct_at(
|
||||
reinterpret_cast<XpadSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
|
||||
}
|
||||
XPad::~XPad() = default;
|
||||
Controller_XPad::~Controller_XPad() = default;
|
||||
|
||||
void XPad::OnInit() {}
|
||||
void Controller_XPad::OnInit() {}
|
||||
|
||||
void XPad::OnRelease() {}
|
||||
void Controller_XPad::OnRelease() {}
|
||||
|
||||
void XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
void Controller_XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!IsControllerActivated()) {
|
||||
shared_memory->basic_xpad_lifo.buffer_count = 0;
|
||||
shared_memory->basic_xpad_lifo.buffer_tail = 0;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#include "core/hle/service/hid/ring_lifo.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class XPad final : public ControllerBase {
|
||||
class Controller_XPad final : public ControllerBase {
|
||||
public:
|
||||
explicit XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~XPad() override;
|
||||
explicit Controller_XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
|
||||
~Controller_XPad() override;
|
||||
|
||||
// Called when the controller is initialized
|
||||
void OnInit() override;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,206 +16,206 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
resource_manager{resource} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{31, nullptr, "SendKeyboardLockKeyEvent"},
|
||||
{101, nullptr, "AcquireHomeButtonEventHandle"},
|
||||
{111, nullptr, "ActivateHomeButton"},
|
||||
{121, nullptr, "AcquireSleepButtonEventHandle"},
|
||||
{131, nullptr, "ActivateSleepButton"},
|
||||
{141, nullptr, "AcquireCaptureButtonEventHandle"},
|
||||
{151, nullptr, "ActivateCaptureButton"},
|
||||
{161, nullptr, "GetPlatformConfig"},
|
||||
{210, nullptr, "AcquireNfcDeviceUpdateEventHandle"},
|
||||
{211, nullptr, "GetNpadsWithNfc"},
|
||||
{212, nullptr, "AcquireNfcActivateEventHandle"},
|
||||
{213, nullptr, "ActivateNfc"},
|
||||
{214, nullptr, "GetXcdHandleForNpadWithNfc"},
|
||||
{215, nullptr, "IsNfcActivated"},
|
||||
{230, nullptr, "AcquireIrSensorEventHandle"},
|
||||
{231, nullptr, "ActivateIrSensor"},
|
||||
{232, nullptr, "GetIrSensorState"},
|
||||
{233, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||
{301, nullptr, "ActivateNpadSystem"},
|
||||
{303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"},
|
||||
{304, &IHidSystemServer::EnableAssigningSingleOnSlSrPress, "EnableAssigningSingleOnSlSrPress"},
|
||||
{305, &IHidSystemServer::DisableAssigningSingleOnSlSrPress, "DisableAssigningSingleOnSlSrPress"},
|
||||
{306, &IHidSystemServer::GetLastActiveNpad, "GetLastActiveNpad"},
|
||||
{307, nullptr, "GetNpadSystemExtStyle"},
|
||||
{308, &IHidSystemServer::ApplyNpadSystemCommonPolicyFull, "ApplyNpadSystemCommonPolicyFull"},
|
||||
{309, &IHidSystemServer::GetNpadFullKeyGripColor, "GetNpadFullKeyGripColor"},
|
||||
{310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
|
||||
{311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
|
||||
{312, &IHidSystemServer::SetSupportedNpadStyleSetAll, "SetSupportedNpadStyleSetAll"},
|
||||
{313, nullptr, "GetNpadCaptureButtonAssignment"},
|
||||
{314, nullptr, "GetAppletFooterUiType"},
|
||||
{315, &IHidSystemServer::GetAppletDetailedUiType, "GetAppletDetailedUiType"},
|
||||
{316, &IHidSystemServer::GetNpadInterfaceType, "GetNpadInterfaceType"},
|
||||
{317, &IHidSystemServer::GetNpadLeftRightInterfaceType, "GetNpadLeftRightInterfaceType"},
|
||||
{318, &IHidSystemServer::HasBattery, "HasBattery"},
|
||||
{319, &IHidSystemServer::HasLeftRightBattery, "HasLeftRightBattery"},
|
||||
{321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"},
|
||||
{322, &IHidSystemServer::GetIrSensorState, "GetIrSensorState"},
|
||||
{323, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||
{324, nullptr, "GetUniquePadButtonSet"},
|
||||
{325, nullptr, "GetUniquePadColor"},
|
||||
{326, nullptr, "GetUniquePadAppletDetailedUiType"},
|
||||
{327, nullptr, "GetAbstractedPadIdDataFromNpad"},
|
||||
{328, nullptr, "AttachAbstractedPadToNpad"},
|
||||
{329, nullptr, "DetachAbstractedPadAll"},
|
||||
{330, nullptr, "CheckAbstractedPadConnection"},
|
||||
{500, nullptr, "SetAppletResourceUserId"},
|
||||
{501, nullptr, "RegisterAppletResourceUserId"},
|
||||
{502, nullptr, "UnregisterAppletResourceUserId"},
|
||||
{503, nullptr, "EnableAppletToGetInput"},
|
||||
{504, nullptr, "SetAruidValidForVibration"},
|
||||
{505, nullptr, "EnableAppletToGetSixAxisSensor"},
|
||||
{506, nullptr, "EnableAppletToGetPadInput"},
|
||||
{507, nullptr, "EnableAppletToGetTouchScreen"},
|
||||
{510, nullptr, "SetVibrationMasterVolume"},
|
||||
{511, nullptr, "GetVibrationMasterVolume"},
|
||||
{512, nullptr, "BeginPermitVibrationSession"},
|
||||
{513, nullptr, "EndPermitVibrationSession"},
|
||||
{514, nullptr, "Unknown514"},
|
||||
{520, nullptr, "EnableHandheldHids"},
|
||||
{521, nullptr, "DisableHandheldHids"},
|
||||
{522, nullptr, "SetJoyConRailEnabled"},
|
||||
{523, nullptr, "IsJoyConRailEnabled"},
|
||||
{524, nullptr, "IsHandheldHidsEnabled"},
|
||||
{525, nullptr, "IsJoyConAttachedOnAllRail"},
|
||||
{540, nullptr, "AcquirePlayReportControllerUsageUpdateEvent"},
|
||||
{541, nullptr, "GetPlayReportControllerUsages"},
|
||||
{542, nullptr, "AcquirePlayReportRegisteredDeviceUpdateEvent"},
|
||||
{543, nullptr, "GetRegisteredDevicesOld"},
|
||||
{544, &IHidSystemServer::AcquireConnectionTriggerTimeoutEvent, "AcquireConnectionTriggerTimeoutEvent"},
|
||||
{545, nullptr, "SendConnectionTrigger"},
|
||||
{546, &IHidSystemServer::AcquireDeviceRegisteredEventForControllerSupport, "AcquireDeviceRegisteredEventForControllerSupport"},
|
||||
{547, nullptr, "GetAllowedBluetoothLinksCount"},
|
||||
{548, &IHidSystemServer::GetRegisteredDevices, "GetRegisteredDevices"},
|
||||
{549, nullptr, "GetConnectableRegisteredDevices"},
|
||||
{700, nullptr, "ActivateUniquePad"},
|
||||
{702, &IHidSystemServer::AcquireUniquePadConnectionEventHandle, "AcquireUniquePadConnectionEventHandle"},
|
||||
{703, &IHidSystemServer::GetUniquePadIds, "GetUniquePadIds"},
|
||||
{751, &IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"},
|
||||
{800, nullptr, "ListSixAxisSensorHandles"},
|
||||
{801, nullptr, "IsSixAxisSensorUserCalibrationSupported"},
|
||||
{802, nullptr, "ResetSixAxisSensorCalibrationValues"},
|
||||
{803, nullptr, "StartSixAxisSensorUserCalibration"},
|
||||
{804, nullptr, "CancelSixAxisSensorUserCalibration"},
|
||||
{805, nullptr, "GetUniquePadBluetoothAddress"},
|
||||
{806, nullptr, "DisconnectUniquePad"},
|
||||
{807, nullptr, "GetUniquePadType"},
|
||||
{808, nullptr, "GetUniquePadInterface"},
|
||||
{809, nullptr, "GetUniquePadSerialNumber"},
|
||||
{810, nullptr, "GetUniquePadControllerNumber"},
|
||||
{811, nullptr, "GetSixAxisSensorUserCalibrationStage"},
|
||||
{812, nullptr, "GetConsoleUniqueSixAxisSensorHandle"},
|
||||
{821, nullptr, "StartAnalogStickManualCalibration"},
|
||||
{822, nullptr, "RetryCurrentAnalogStickManualCalibrationStage"},
|
||||
{823, nullptr, "CancelAnalogStickManualCalibration"},
|
||||
{824, nullptr, "ResetAnalogStickManualCalibration"},
|
||||
{825, nullptr, "GetAnalogStickState"},
|
||||
{826, nullptr, "GetAnalogStickManualCalibrationStage"},
|
||||
{827, nullptr, "IsAnalogStickButtonPressed"},
|
||||
{828, nullptr, "IsAnalogStickInReleasePosition"},
|
||||
{829, nullptr, "IsAnalogStickInCircumference"},
|
||||
{830, nullptr, "SetNotificationLedPattern"},
|
||||
{831, nullptr, "SetNotificationLedPatternWithTimeout"},
|
||||
{832, nullptr, "PrepareHidsForNotificationWake"},
|
||||
{850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
|
||||
{851, nullptr, "EnableUsbFullKeyController"},
|
||||
{852, nullptr, "IsUsbConnected"},
|
||||
{870, &IHidSystemServer::IsHandheldButtonPressedOnConsoleMode, "IsHandheldButtonPressedOnConsoleMode"},
|
||||
{900, nullptr, "ActivateInputDetector"},
|
||||
{901, nullptr, "NotifyInputDetector"},
|
||||
{1000, &IHidSystemServer::InitializeFirmwareUpdate, "InitializeFirmwareUpdate"},
|
||||
{1001, nullptr, "GetFirmwareVersion"},
|
||||
{1002, nullptr, "GetAvailableFirmwareVersion"},
|
||||
{1003, nullptr, "IsFirmwareUpdateAvailable"},
|
||||
{1004, nullptr, "CheckFirmwareUpdateRequired"},
|
||||
{1005, nullptr, "StartFirmwareUpdate"},
|
||||
{1006, nullptr, "AbortFirmwareUpdate"},
|
||||
{1007, nullptr, "GetFirmwareUpdateState"},
|
||||
{1008, nullptr, "ActivateAudioControl"},
|
||||
{1009, nullptr, "AcquireAudioControlEventHandle"},
|
||||
{1010, nullptr, "GetAudioControlStates"},
|
||||
{1011, nullptr, "DeactivateAudioControl"},
|
||||
{1050, nullptr, "IsSixAxisSensorAccurateUserCalibrationSupported"},
|
||||
{1051, nullptr, "StartSixAxisSensorAccurateUserCalibration"},
|
||||
{1052, nullptr, "CancelSixAxisSensorAccurateUserCalibration"},
|
||||
{1053, nullptr, "GetSixAxisSensorAccurateUserCalibrationState"},
|
||||
{1100, nullptr, "GetHidbusSystemServiceObject"},
|
||||
{1120, nullptr, "SetFirmwareHotfixUpdateSkipEnabled"},
|
||||
{1130, nullptr, "InitializeUsbFirmwareUpdate"},
|
||||
{1131, nullptr, "FinalizeUsbFirmwareUpdate"},
|
||||
{1132, nullptr, "CheckUsbFirmwareUpdateRequired"},
|
||||
{1133, nullptr, "StartUsbFirmwareUpdate"},
|
||||
{1134, nullptr, "GetUsbFirmwareUpdateState"},
|
||||
{1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
|
||||
{1150, nullptr, "SetTouchScreenMagnification"},
|
||||
{1151, nullptr, "GetTouchScreenFirmwareVersion"},
|
||||
{1152, nullptr, "SetTouchScreenDefaultConfiguration"},
|
||||
{1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
|
||||
{1154, nullptr, "IsFirmwareAvailableForNotification"},
|
||||
{1155, nullptr, "SetForceHandheldStyleVibration"},
|
||||
{1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"},
|
||||
{1157, nullptr, "CancelConnectionTrigger"},
|
||||
{1200, nullptr, "IsButtonConfigSupported"},
|
||||
{1201, nullptr, "IsButtonConfigEmbeddedSupported"},
|
||||
{1202, nullptr, "DeleteButtonConfig"},
|
||||
{1203, nullptr, "DeleteButtonConfigEmbedded"},
|
||||
{1204, nullptr, "SetButtonConfigEnabled"},
|
||||
{1205, nullptr, "SetButtonConfigEmbeddedEnabled"},
|
||||
{1206, nullptr, "IsButtonConfigEnabled"},
|
||||
{1207, nullptr, "IsButtonConfigEmbeddedEnabled"},
|
||||
{1208, nullptr, "SetButtonConfigEmbedded"},
|
||||
{1209, nullptr, "SetButtonConfigFull"},
|
||||
{1210, nullptr, "SetButtonConfigLeft"},
|
||||
{1211, nullptr, "SetButtonConfigRight"},
|
||||
{1212, nullptr, "GetButtonConfigEmbedded"},
|
||||
{1213, nullptr, "GetButtonConfigFull"},
|
||||
{1214, nullptr, "GetButtonConfigLeft"},
|
||||
{1215, nullptr, "GetButtonConfigRight"},
|
||||
{1250, nullptr, "IsCustomButtonConfigSupported"},
|
||||
{1251, nullptr, "IsDefaultButtonConfigEmbedded"},
|
||||
{1252, nullptr, "IsDefaultButtonConfigFull"},
|
||||
{1253, nullptr, "IsDefaultButtonConfigLeft"},
|
||||
{1254, nullptr, "IsDefaultButtonConfigRight"},
|
||||
{1255, nullptr, "IsButtonConfigStorageEmbeddedEmpty"},
|
||||
{1256, nullptr, "IsButtonConfigStorageFullEmpty"},
|
||||
{1257, nullptr, "IsButtonConfigStorageLeftEmpty"},
|
||||
{1258, nullptr, "IsButtonConfigStorageRightEmpty"},
|
||||
{1259, nullptr, "GetButtonConfigStorageEmbeddedDeprecated"},
|
||||
{1260, nullptr, "GetButtonConfigStorageFullDeprecated"},
|
||||
{1261, nullptr, "GetButtonConfigStorageLeftDeprecated"},
|
||||
{1262, nullptr, "GetButtonConfigStorageRightDeprecated"},
|
||||
{1263, nullptr, "SetButtonConfigStorageEmbeddedDeprecated"},
|
||||
{1264, nullptr, "SetButtonConfigStorageFullDeprecated"},
|
||||
{1265, nullptr, "SetButtonConfigStorageLeftDeprecated"},
|
||||
{1266, nullptr, "SetButtonConfigStorageRightDeprecated"},
|
||||
{1267, nullptr, "DeleteButtonConfigStorageEmbedded"},
|
||||
{1268, nullptr, "DeleteButtonConfigStorageFull"},
|
||||
{1269, nullptr, "DeleteButtonConfigStorageLeft"},
|
||||
{1270, nullptr, "DeleteButtonConfigStorageRight"},
|
||||
{1271, nullptr, "IsUsingCustomButtonConfig"},
|
||||
{1272, nullptr, "IsAnyCustomButtonConfigEnabled"},
|
||||
{1273, nullptr, "SetAllCustomButtonConfigEnabled"},
|
||||
{1274, nullptr, "SetDefaultButtonConfig"},
|
||||
{1275, nullptr, "SetAllDefaultButtonConfig"},
|
||||
{1276, nullptr, "SetHidButtonConfigEmbedded"},
|
||||
{1277, nullptr, "SetHidButtonConfigFull"},
|
||||
{1278, nullptr, "SetHidButtonConfigLeft"},
|
||||
{1279, nullptr, "SetHidButtonConfigRight"},
|
||||
{1280, nullptr, "GetHidButtonConfigEmbedded"},
|
||||
{1281, nullptr, "GetHidButtonConfigFull"},
|
||||
{1282, nullptr, "GetHidButtonConfigLeft"},
|
||||
{1283, nullptr, "GetHidButtonConfigRight"},
|
||||
{1284, nullptr, "GetButtonConfigStorageEmbedded"},
|
||||
{1285, nullptr, "GetButtonConfigStorageFull"},
|
||||
{1286, nullptr, "GetButtonConfigStorageLeft"},
|
||||
{1287, nullptr, "GetButtonConfigStorageRight"},
|
||||
{1288, nullptr, "SetButtonConfigStorageEmbedded"},
|
||||
{1289, nullptr, "SetButtonConfigStorageFull"},
|
||||
{1290, nullptr, "DeleteButtonConfigStorageRight"},
|
||||
{1291, nullptr, "DeleteButtonConfigStorageRight"},
|
||||
{31, nullptr, "SendKeyboardLockKeyEvent"},
|
||||
{101, nullptr, "AcquireHomeButtonEventHandle"},
|
||||
{111, nullptr, "ActivateHomeButton"},
|
||||
{121, nullptr, "AcquireSleepButtonEventHandle"},
|
||||
{131, nullptr, "ActivateSleepButton"},
|
||||
{141, nullptr, "AcquireCaptureButtonEventHandle"},
|
||||
{151, nullptr, "ActivateCaptureButton"},
|
||||
{161, nullptr, "GetPlatformConfig"},
|
||||
{210, nullptr, "AcquireNfcDeviceUpdateEventHandle"},
|
||||
{211, nullptr, "GetNpadsWithNfc"},
|
||||
{212, nullptr, "AcquireNfcActivateEventHandle"},
|
||||
{213, nullptr, "ActivateNfc"},
|
||||
{214, nullptr, "GetXcdHandleForNpadWithNfc"},
|
||||
{215, nullptr, "IsNfcActivated"},
|
||||
{230, nullptr, "AcquireIrSensorEventHandle"},
|
||||
{231, nullptr, "ActivateIrSensor"},
|
||||
{232, nullptr, "GetIrSensorState"},
|
||||
{233, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||
{301, nullptr, "ActivateNpadSystem"},
|
||||
{303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"},
|
||||
{304, &IHidSystemServer::EnableAssigningSingleOnSlSrPress, "EnableAssigningSingleOnSlSrPress"},
|
||||
{305, &IHidSystemServer::DisableAssigningSingleOnSlSrPress, "DisableAssigningSingleOnSlSrPress"},
|
||||
{306, &IHidSystemServer::GetLastActiveNpad, "GetLastActiveNpad"},
|
||||
{307, nullptr, "GetNpadSystemExtStyle"},
|
||||
{308, &IHidSystemServer::ApplyNpadSystemCommonPolicyFull, "ApplyNpadSystemCommonPolicyFull"},
|
||||
{309, &IHidSystemServer::GetNpadFullKeyGripColor, "GetNpadFullKeyGripColor"},
|
||||
{310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
|
||||
{311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
|
||||
{312, &IHidSystemServer::SetSupportedNpadStyleSetAll, "SetSupportedNpadStyleSetAll"},
|
||||
{313, nullptr, "GetNpadCaptureButtonAssignment"},
|
||||
{314, nullptr, "GetAppletFooterUiType"},
|
||||
{315, &IHidSystemServer::GetAppletDetailedUiType, "GetAppletDetailedUiType"},
|
||||
{316, &IHidSystemServer::GetNpadInterfaceType, "GetNpadInterfaceType"},
|
||||
{317, &IHidSystemServer::GetNpadLeftRightInterfaceType, "GetNpadLeftRightInterfaceType"},
|
||||
{318, &IHidSystemServer::HasBattery, "HasBattery"},
|
||||
{319, &IHidSystemServer::HasLeftRightBattery, "HasLeftRightBattery"},
|
||||
{321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"},
|
||||
{322, &IHidSystemServer::GetIrSensorState, "GetIrSensorState"},
|
||||
{323, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||
{324, nullptr, "GetUniquePadButtonSet"},
|
||||
{325, nullptr, "GetUniquePadColor"},
|
||||
{326, nullptr, "GetUniquePadAppletDetailedUiType"},
|
||||
{327, nullptr, "GetAbstractedPadIdDataFromNpad"},
|
||||
{328, nullptr, "AttachAbstractedPadToNpad"},
|
||||
{329, nullptr, "DetachAbstractedPadAll"},
|
||||
{330, nullptr, "CheckAbstractedPadConnection"},
|
||||
{500, nullptr, "SetAppletResourceUserId"},
|
||||
{501, nullptr, "RegisterAppletResourceUserId"},
|
||||
{502, nullptr, "UnregisterAppletResourceUserId"},
|
||||
{503, nullptr, "EnableAppletToGetInput"},
|
||||
{504, nullptr, "SetAruidValidForVibration"},
|
||||
{505, nullptr, "EnableAppletToGetSixAxisSensor"},
|
||||
{506, nullptr, "EnableAppletToGetPadInput"},
|
||||
{507, nullptr, "EnableAppletToGetTouchScreen"},
|
||||
{510, nullptr, "SetVibrationMasterVolume"},
|
||||
{511, nullptr, "GetVibrationMasterVolume"},
|
||||
{512, nullptr, "BeginPermitVibrationSession"},
|
||||
{513, nullptr, "EndPermitVibrationSession"},
|
||||
{514, nullptr, "Unknown514"},
|
||||
{520, nullptr, "EnableHandheldHids"},
|
||||
{521, nullptr, "DisableHandheldHids"},
|
||||
{522, nullptr, "SetJoyConRailEnabled"},
|
||||
{523, nullptr, "IsJoyConRailEnabled"},
|
||||
{524, nullptr, "IsHandheldHidsEnabled"},
|
||||
{525, nullptr, "IsJoyConAttachedOnAllRail"},
|
||||
{540, nullptr, "AcquirePlayReportControllerUsageUpdateEvent"},
|
||||
{541, nullptr, "GetPlayReportControllerUsages"},
|
||||
{542, nullptr, "AcquirePlayReportRegisteredDeviceUpdateEvent"},
|
||||
{543, nullptr, "GetRegisteredDevicesOld"},
|
||||
{544, &IHidSystemServer::AcquireConnectionTriggerTimeoutEvent, "AcquireConnectionTriggerTimeoutEvent"},
|
||||
{545, nullptr, "SendConnectionTrigger"},
|
||||
{546, &IHidSystemServer::AcquireDeviceRegisteredEventForControllerSupport, "AcquireDeviceRegisteredEventForControllerSupport"},
|
||||
{547, nullptr, "GetAllowedBluetoothLinksCount"},
|
||||
{548, &IHidSystemServer::GetRegisteredDevices, "GetRegisteredDevices"},
|
||||
{549, nullptr, "GetConnectableRegisteredDevices"},
|
||||
{700, nullptr, "ActivateUniquePad"},
|
||||
{702, &IHidSystemServer::AcquireUniquePadConnectionEventHandle, "AcquireUniquePadConnectionEventHandle"},
|
||||
{703, &IHidSystemServer::GetUniquePadIds, "GetUniquePadIds"},
|
||||
{751, &IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"},
|
||||
{800, nullptr, "ListSixAxisSensorHandles"},
|
||||
{801, nullptr, "IsSixAxisSensorUserCalibrationSupported"},
|
||||
{802, nullptr, "ResetSixAxisSensorCalibrationValues"},
|
||||
{803, nullptr, "StartSixAxisSensorUserCalibration"},
|
||||
{804, nullptr, "CancelSixAxisSensorUserCalibration"},
|
||||
{805, nullptr, "GetUniquePadBluetoothAddress"},
|
||||
{806, nullptr, "DisconnectUniquePad"},
|
||||
{807, nullptr, "GetUniquePadType"},
|
||||
{808, nullptr, "GetUniquePadInterface"},
|
||||
{809, nullptr, "GetUniquePadSerialNumber"},
|
||||
{810, nullptr, "GetUniquePadControllerNumber"},
|
||||
{811, nullptr, "GetSixAxisSensorUserCalibrationStage"},
|
||||
{812, nullptr, "GetConsoleUniqueSixAxisSensorHandle"},
|
||||
{821, nullptr, "StartAnalogStickManualCalibration"},
|
||||
{822, nullptr, "RetryCurrentAnalogStickManualCalibrationStage"},
|
||||
{823, nullptr, "CancelAnalogStickManualCalibration"},
|
||||
{824, nullptr, "ResetAnalogStickManualCalibration"},
|
||||
{825, nullptr, "GetAnalogStickState"},
|
||||
{826, nullptr, "GetAnalogStickManualCalibrationStage"},
|
||||
{827, nullptr, "IsAnalogStickButtonPressed"},
|
||||
{828, nullptr, "IsAnalogStickInReleasePosition"},
|
||||
{829, nullptr, "IsAnalogStickInCircumference"},
|
||||
{830, nullptr, "SetNotificationLedPattern"},
|
||||
{831, nullptr, "SetNotificationLedPatternWithTimeout"},
|
||||
{832, nullptr, "PrepareHidsForNotificationWake"},
|
||||
{850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
|
||||
{851, nullptr, "EnableUsbFullKeyController"},
|
||||
{852, nullptr, "IsUsbConnected"},
|
||||
{870, &IHidSystemServer::IsHandheldButtonPressedOnConsoleMode, "IsHandheldButtonPressedOnConsoleMode"},
|
||||
{900, nullptr, "ActivateInputDetector"},
|
||||
{901, nullptr, "NotifyInputDetector"},
|
||||
{1000, &IHidSystemServer::InitializeFirmwareUpdate, "InitializeFirmwareUpdate"},
|
||||
{1001, nullptr, "GetFirmwareVersion"},
|
||||
{1002, nullptr, "GetAvailableFirmwareVersion"},
|
||||
{1003, nullptr, "IsFirmwareUpdateAvailable"},
|
||||
{1004, nullptr, "CheckFirmwareUpdateRequired"},
|
||||
{1005, nullptr, "StartFirmwareUpdate"},
|
||||
{1006, nullptr, "AbortFirmwareUpdate"},
|
||||
{1007, nullptr, "GetFirmwareUpdateState"},
|
||||
{1008, nullptr, "ActivateAudioControl"},
|
||||
{1009, nullptr, "AcquireAudioControlEventHandle"},
|
||||
{1010, nullptr, "GetAudioControlStates"},
|
||||
{1011, nullptr, "DeactivateAudioControl"},
|
||||
{1050, nullptr, "IsSixAxisSensorAccurateUserCalibrationSupported"},
|
||||
{1051, nullptr, "StartSixAxisSensorAccurateUserCalibration"},
|
||||
{1052, nullptr, "CancelSixAxisSensorAccurateUserCalibration"},
|
||||
{1053, nullptr, "GetSixAxisSensorAccurateUserCalibrationState"},
|
||||
{1100, nullptr, "GetHidbusSystemServiceObject"},
|
||||
{1120, nullptr, "SetFirmwareHotfixUpdateSkipEnabled"},
|
||||
{1130, nullptr, "InitializeUsbFirmwareUpdate"},
|
||||
{1131, nullptr, "FinalizeUsbFirmwareUpdate"},
|
||||
{1132, nullptr, "CheckUsbFirmwareUpdateRequired"},
|
||||
{1133, nullptr, "StartUsbFirmwareUpdate"},
|
||||
{1134, nullptr, "GetUsbFirmwareUpdateState"},
|
||||
{1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
|
||||
{1150, nullptr, "SetTouchScreenMagnification"},
|
||||
{1151, nullptr, "GetTouchScreenFirmwareVersion"},
|
||||
{1152, nullptr, "SetTouchScreenDefaultConfiguration"},
|
||||
{1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
|
||||
{1154, nullptr, "IsFirmwareAvailableForNotification"},
|
||||
{1155, nullptr, "SetForceHandheldStyleVibration"},
|
||||
{1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"},
|
||||
{1157, nullptr, "CancelConnectionTrigger"},
|
||||
{1200, nullptr, "IsButtonConfigSupported"},
|
||||
{1201, nullptr, "IsButtonConfigEmbeddedSupported"},
|
||||
{1202, nullptr, "DeleteButtonConfig"},
|
||||
{1203, nullptr, "DeleteButtonConfigEmbedded"},
|
||||
{1204, nullptr, "SetButtonConfigEnabled"},
|
||||
{1205, nullptr, "SetButtonConfigEmbeddedEnabled"},
|
||||
{1206, nullptr, "IsButtonConfigEnabled"},
|
||||
{1207, nullptr, "IsButtonConfigEmbeddedEnabled"},
|
||||
{1208, nullptr, "SetButtonConfigEmbedded"},
|
||||
{1209, nullptr, "SetButtonConfigFull"},
|
||||
{1210, nullptr, "SetButtonConfigLeft"},
|
||||
{1211, nullptr, "SetButtonConfigRight"},
|
||||
{1212, nullptr, "GetButtonConfigEmbedded"},
|
||||
{1213, nullptr, "GetButtonConfigFull"},
|
||||
{1214, nullptr, "GetButtonConfigLeft"},
|
||||
{1215, nullptr, "GetButtonConfigRight"},
|
||||
{1250, nullptr, "IsCustomButtonConfigSupported"},
|
||||
{1251, nullptr, "IsDefaultButtonConfigEmbedded"},
|
||||
{1252, nullptr, "IsDefaultButtonConfigFull"},
|
||||
{1253, nullptr, "IsDefaultButtonConfigLeft"},
|
||||
{1254, nullptr, "IsDefaultButtonConfigRight"},
|
||||
{1255, nullptr, "IsButtonConfigStorageEmbeddedEmpty"},
|
||||
{1256, nullptr, "IsButtonConfigStorageFullEmpty"},
|
||||
{1257, nullptr, "IsButtonConfigStorageLeftEmpty"},
|
||||
{1258, nullptr, "IsButtonConfigStorageRightEmpty"},
|
||||
{1259, nullptr, "GetButtonConfigStorageEmbeddedDeprecated"},
|
||||
{1260, nullptr, "GetButtonConfigStorageFullDeprecated"},
|
||||
{1261, nullptr, "GetButtonConfigStorageLeftDeprecated"},
|
||||
{1262, nullptr, "GetButtonConfigStorageRightDeprecated"},
|
||||
{1263, nullptr, "SetButtonConfigStorageEmbeddedDeprecated"},
|
||||
{1264, nullptr, "SetButtonConfigStorageFullDeprecated"},
|
||||
{1265, nullptr, "SetButtonConfigStorageLeftDeprecated"},
|
||||
{1266, nullptr, "SetButtonConfigStorageRightDeprecated"},
|
||||
{1267, nullptr, "DeleteButtonConfigStorageEmbedded"},
|
||||
{1268, nullptr, "DeleteButtonConfigStorageFull"},
|
||||
{1269, nullptr, "DeleteButtonConfigStorageLeft"},
|
||||
{1270, nullptr, "DeleteButtonConfigStorageRight"},
|
||||
{1271, nullptr, "IsUsingCustomButtonConfig"},
|
||||
{1272, nullptr, "IsAnyCustomButtonConfigEnabled"},
|
||||
{1273, nullptr, "SetAllCustomButtonConfigEnabled"},
|
||||
{1274, nullptr, "SetDefaultButtonConfig"},
|
||||
{1275, nullptr, "SetAllDefaultButtonConfig"},
|
||||
{1276, nullptr, "SetHidButtonConfigEmbedded"},
|
||||
{1277, nullptr, "SetHidButtonConfigFull"},
|
||||
{1278, nullptr, "SetHidButtonConfigLeft"},
|
||||
{1279, nullptr, "SetHidButtonConfigRight"},
|
||||
{1280, nullptr, "GetHidButtonConfigEmbedded"},
|
||||
{1281, nullptr, "GetHidButtonConfigFull"},
|
||||
{1282, nullptr, "GetHidButtonConfigLeft"},
|
||||
{1283, nullptr, "GetHidButtonConfigRight"},
|
||||
{1284, nullptr, "GetButtonConfigStorageEmbedded"},
|
||||
{1285, nullptr, "GetButtonConfigStorageFull"},
|
||||
{1286, nullptr, "GetButtonConfigStorageLeft"},
|
||||
{1287, nullptr, "GetButtonConfigStorageRight"},
|
||||
{1288, nullptr, "SetButtonConfigStorageEmbedded"},
|
||||
{1289, nullptr, "SetButtonConfigStorageFull"},
|
||||
{1290, nullptr, "DeleteButtonConfigStorageRight"},
|
||||
{1291, nullptr, "DeleteButtonConfigStorageRight"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -240,7 +240,9 @@ IHidSystemServer::~IHidSystemServer() {
|
||||
void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "called");
|
||||
|
||||
GetResourceManager()->GetNpad()->ApplyNpadSystemCommonPolicy();
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.ApplyNpadSystemCommonPolicy();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -271,7 +273,9 @@ void IHidSystemServer::GetLastActiveNpad(HLERequestContext& ctx) {
|
||||
void IHidSystemServer::ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "called");
|
||||
|
||||
GetResourceManager()->GetNpad()->ApplyNpadSystemCommonPolicy();
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.ApplyNpadSystemCommonPolicy();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -300,7 +304,10 @@ void IHidSystemServer::GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_HID, "(STUBBED) called");
|
||||
|
||||
Core::HID::NpadStyleSet supported_styleset =
|
||||
GetResourceManager()->GetNpad()->GetSupportedStyleSet().raw;
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.GetSupportedStyleSet()
|
||||
.raw;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -313,7 +320,10 @@ void IHidSystemServer::SetSupportedNpadStyleSetAll(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_HID, "(STUBBED) called");
|
||||
|
||||
Core::HID::NpadStyleSet supported_styleset =
|
||||
GetResourceManager()->GetNpad()->GetSupportedStyleSet().raw;
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.GetSupportedStyleSet()
|
||||
.raw;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -327,8 +337,10 @@ void IHidSystemServer::GetAppletDetailedUiType(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_HID, "called, npad_id_type={}",
|
||||
npad_id_type); // Spams a lot when controller applet is running
|
||||
|
||||
const NPad::AppletDetailedUiType detailed_ui_type =
|
||||
GetResourceManager()->GetNpad()->GetAppletDetailedUiType(npad_id_type);
|
||||
const Service::HID::Controller_NPad::AppletDetailedUiType detailed_ui_type =
|
||||
GetResourceManager()
|
||||
->GetController<Controller_NPad>(HidController::NPad)
|
||||
.GetAppletDetailedUiType(npad_id_type);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "core/hle/service/hid/errors.h"
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
constexpr bool IsNpadIdValid(const Core::HID::NpadIdType npad_id) {
|
||||
switch (npad_id) {
|
||||
case Core::HID::NpadIdType::Player1:
|
||||
case Core::HID::NpadIdType::Player2:
|
||||
case Core::HID::NpadIdType::Player3:
|
||||
case Core::HID::NpadIdType::Player4:
|
||||
case Core::HID::NpadIdType::Player5:
|
||||
case Core::HID::NpadIdType::Player6:
|
||||
case Core::HID::NpadIdType::Player7:
|
||||
case Core::HID::NpadIdType::Player8:
|
||||
case Core::HID::NpadIdType::Other:
|
||||
case Core::HID::NpadIdType::Handheld:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr Result IsSixaxisHandleValid(const Core::HID::SixAxisSensorHandle& handle) {
|
||||
const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(handle.npad_id));
|
||||
const bool device_index = handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex;
|
||||
|
||||
if (!npad_id) {
|
||||
return InvalidNpadId;
|
||||
}
|
||||
if (!device_index) {
|
||||
return NpadDeviceIndexOutOfRange;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
constexpr Result IsVibrationHandleValid(const Core::HID::VibrationDeviceHandle& handle) {
|
||||
switch (handle.npad_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
case Core::HID::NpadStyleIndex::GameCube:
|
||||
case Core::HID::NpadStyleIndex::N64:
|
||||
case Core::HID::NpadStyleIndex::SystemExt:
|
||||
case Core::HID::NpadStyleIndex::System:
|
||||
// These support vibration
|
||||
break;
|
||||
default:
|
||||
return VibrationInvalidStyleIndex;
|
||||
}
|
||||
|
||||
if (!IsNpadIdValid(static_cast<Core::HID::NpadIdType>(handle.npad_id))) {
|
||||
return VibrationInvalidNpadId;
|
||||
}
|
||||
|
||||
if (handle.device_index >= Core::HID::DeviceIndex::MaxDeviceIndex) {
|
||||
return VibrationDeviceIndexOutOfRange;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
/// Converts a Core::HID::NpadIdType to an array index.
|
||||
constexpr size_t NpadIdTypeToIndex(Core::HID::NpadIdType npad_id_type) {
|
||||
switch (npad_id_type) {
|
||||
case Core::HID::NpadIdType::Player1:
|
||||
return 0;
|
||||
case Core::HID::NpadIdType::Player2:
|
||||
return 1;
|
||||
case Core::HID::NpadIdType::Player3:
|
||||
return 2;
|
||||
case Core::HID::NpadIdType::Player4:
|
||||
return 3;
|
||||
case Core::HID::NpadIdType::Player5:
|
||||
return 4;
|
||||
case Core::HID::NpadIdType::Player6:
|
||||
return 5;
|
||||
case Core::HID::NpadIdType::Player7:
|
||||
return 6;
|
||||
case Core::HID::NpadIdType::Player8:
|
||||
return 7;
|
||||
case Core::HID::NpadIdType::Handheld:
|
||||
return 8;
|
||||
case Core::HID::NpadIdType::Other:
|
||||
return 9;
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts an array index to a Core::HID::NpadIdType
|
||||
constexpr Core::HID::NpadIdType IndexToNpadIdType(size_t index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return Core::HID::NpadIdType::Player1;
|
||||
case 1:
|
||||
return Core::HID::NpadIdType::Player2;
|
||||
case 2:
|
||||
return Core::HID::NpadIdType::Player3;
|
||||
case 3:
|
||||
return Core::HID::NpadIdType::Player4;
|
||||
case 4:
|
||||
return Core::HID::NpadIdType::Player5;
|
||||
case 5:
|
||||
return Core::HID::NpadIdType::Player6;
|
||||
case 6:
|
||||
return Core::HID::NpadIdType::Player7;
|
||||
case 7:
|
||||
return Core::HID::NpadIdType::Player8;
|
||||
case 8:
|
||||
return Core::HID::NpadIdType::Handheld;
|
||||
case 9:
|
||||
return Core::HID::NpadIdType::Other;
|
||||
default:
|
||||
return Core::HID::NpadIdType::Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr Core::HID::NpadStyleSet GetStylesetByIndex(std::size_t index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return Core::HID::NpadStyleSet::Fullkey;
|
||||
case 1:
|
||||
return Core::HID::NpadStyleSet::Handheld;
|
||||
case 2:
|
||||
return Core::HID::NpadStyleSet::JoyDual;
|
||||
case 3:
|
||||
return Core::HID::NpadStyleSet::JoyLeft;
|
||||
case 4:
|
||||
return Core::HID::NpadStyleSet::JoyRight;
|
||||
case 5:
|
||||
return Core::HID::NpadStyleSet::Palma;
|
||||
default:
|
||||
return Core::HID::NpadStyleSet::None;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "core/hle/kernel/k_transfer_memory.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/service/hid/errors.h"
|
||||
#include "core/hle/service/hid/hid_util.h"
|
||||
#include "core/hle/service/hid/irs.h"
|
||||
#include "core/hle/service/hid/irsensor/clustering_processor.h"
|
||||
#include "core/hle/service/hid/irsensor/image_transfer_processor.h"
|
||||
@@ -321,7 +320,7 @@ void IRS::GetNpadIrCameraHandle(HLERequestContext& ctx) {
|
||||
}
|
||||
|
||||
Core::IrSensor::IrCameraHandle camera_handle{
|
||||
.npad_id = static_cast<u8>(HID::NpadIdTypeToIndex(npad_id)),
|
||||
.npad_id = static_cast<u8>(NpadIdTypeToIndex(npad_id)),
|
||||
.npad_type = Core::HID::NpadStyleIndex::None,
|
||||
};
|
||||
|
||||
@@ -546,7 +545,7 @@ void IRS::ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx) {
|
||||
|
||||
Result IRS::IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const {
|
||||
if (camera_handle.npad_id >
|
||||
static_cast<u8>(HID::NpadIdTypeToIndex(Core::HID::NpadIdType::Handheld))) {
|
||||
static_cast<u8>(NpadIdTypeToIndex(Core::HID::NpadIdType::Handheld))) {
|
||||
return InvalidIrCameraHandle;
|
||||
}
|
||||
if (camera_handle.npad_type != Core::HID::NpadStyleIndex::None) {
|
||||
|
||||
@@ -9,15 +9,14 @@
|
||||
#include "core/hle/service/hid/resource_manager.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
|
||||
#include "core/hle/service/hid/controllers/console_six_axis.h"
|
||||
#include "core/hle/service/hid/controllers/console_sixaxis.h"
|
||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||
#include "core/hle/service/hid/controllers/debug_pad.h"
|
||||
#include "core/hle/service/hid/controllers/gesture.h"
|
||||
#include "core/hle/service/hid/controllers/keyboard.h"
|
||||
#include "core/hle/service/hid/controllers/mouse.h"
|
||||
#include "core/hle/service/hid/controllers/npad.h"
|
||||
#include "core/hle/service/hid/controllers/palma.h"
|
||||
#include "core/hle/service/hid/controllers/seven_six_axis.h"
|
||||
#include "core/hle/service/hid/controllers/six_axis.h"
|
||||
#include "core/hle/service/hid/controllers/stubbed.h"
|
||||
#include "core/hle/service/hid/controllers/touchscreen.h"
|
||||
#include "core/hle/service/hid/controllers/xpad.h"
|
||||
@@ -43,132 +42,76 @@ void ResourceManager::Initialize() {
|
||||
}
|
||||
|
||||
u8* shared_memory = system.Kernel().GetHidSharedMem().GetPointer();
|
||||
debug_pad = std::make_shared<DebugPad>(system.HIDCore(), shared_memory);
|
||||
mouse = std::make_shared<Mouse>(system.HIDCore(), shared_memory);
|
||||
debug_mouse = std::make_shared<DebugMouse>(system.HIDCore(), shared_memory);
|
||||
keyboard = std::make_shared<Keyboard>(system.HIDCore(), shared_memory);
|
||||
unique_pad = std::make_shared<UniquePad>(system.HIDCore(), shared_memory);
|
||||
npad = std::make_shared<NPad>(system.HIDCore(), shared_memory, service_context);
|
||||
gesture = std::make_shared<Gesture>(system.HIDCore(), shared_memory);
|
||||
touch_screen = std::make_shared<TouchScreen>(system.HIDCore(), shared_memory);
|
||||
xpad = std::make_shared<XPad>(system.HIDCore(), shared_memory);
|
||||
|
||||
palma = std::make_shared<Palma>(system.HIDCore(), shared_memory, service_context);
|
||||
|
||||
home_button = std::make_shared<HomeButton>(system.HIDCore(), shared_memory);
|
||||
sleep_button = std::make_shared<SleepButton>(system.HIDCore(), shared_memory);
|
||||
capture_button = std::make_shared<CaptureButton>(system.HIDCore(), shared_memory);
|
||||
|
||||
six_axis = std::make_shared<SixAxis>(system.HIDCore(), npad);
|
||||
console_six_axis = std::make_shared<ConsoleSixAxis>(system.HIDCore(), shared_memory);
|
||||
seven_six_axis = std::make_shared<SevenSixAxis>(system);
|
||||
|
||||
home_button->SetCommonHeaderOffset(0x4C00);
|
||||
sleep_button->SetCommonHeaderOffset(0x4E00);
|
||||
capture_button->SetCommonHeaderOffset(0x5000);
|
||||
unique_pad->SetCommonHeaderOffset(0x5A00);
|
||||
debug_mouse->SetCommonHeaderOffset(0x3DC00);
|
||||
MakeController<Controller_DebugPad>(HidController::DebugPad, shared_memory);
|
||||
MakeController<Controller_Touchscreen>(HidController::Touchscreen, shared_memory);
|
||||
MakeController<Controller_Mouse>(HidController::Mouse, shared_memory);
|
||||
MakeController<Controller_Keyboard>(HidController::Keyboard, shared_memory);
|
||||
MakeController<Controller_XPad>(HidController::XPad, shared_memory);
|
||||
MakeController<Controller_Stubbed>(HidController::HomeButton, shared_memory);
|
||||
MakeController<Controller_Stubbed>(HidController::SleepButton, shared_memory);
|
||||
MakeController<Controller_Stubbed>(HidController::CaptureButton, shared_memory);
|
||||
MakeController<Controller_Stubbed>(HidController::InputDetector, shared_memory);
|
||||
MakeController<Controller_Stubbed>(HidController::UniquePad, shared_memory);
|
||||
MakeControllerWithServiceContext<Controller_NPad>(HidController::NPad, shared_memory);
|
||||
MakeController<Controller_Gesture>(HidController::Gesture, shared_memory);
|
||||
MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor, shared_memory);
|
||||
MakeController<Controller_Stubbed>(HidController::DebugMouse, shared_memory);
|
||||
MakeControllerWithServiceContext<Controller_Palma>(HidController::Palma, shared_memory);
|
||||
|
||||
// Homebrew doesn't try to activate some controllers, so we activate them by default
|
||||
npad->Activate();
|
||||
six_axis->Activate();
|
||||
touch_screen->Activate();
|
||||
GetController<Controller_NPad>(HidController::NPad).Activate();
|
||||
GetController<Controller_Touchscreen>(HidController::Touchscreen).Activate();
|
||||
|
||||
GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00);
|
||||
GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00);
|
||||
GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000);
|
||||
GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200);
|
||||
GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00);
|
||||
GetController<Controller_Stubbed>(HidController::DebugMouse).SetCommonHeaderOffset(0x3DC00);
|
||||
|
||||
system.HIDCore().ReloadInputDevices();
|
||||
is_initialized = true;
|
||||
}
|
||||
std::shared_ptr<CaptureButton> ResourceManager::GetCaptureButton() const {
|
||||
return capture_button;
|
||||
}
|
||||
|
||||
std::shared_ptr<ConsoleSixAxis> ResourceManager::GetConsoleSixAxis() const {
|
||||
return console_six_axis;
|
||||
}
|
||||
|
||||
std::shared_ptr<DebugMouse> ResourceManager::GetDebugMouse() const {
|
||||
return debug_mouse;
|
||||
}
|
||||
|
||||
std::shared_ptr<DebugPad> ResourceManager::GetDebugPad() const {
|
||||
return debug_pad;
|
||||
}
|
||||
|
||||
std::shared_ptr<Gesture> ResourceManager::GetGesture() const {
|
||||
return gesture;
|
||||
}
|
||||
|
||||
std::shared_ptr<HomeButton> ResourceManager::GetHomeButton() const {
|
||||
return home_button;
|
||||
}
|
||||
|
||||
std::shared_ptr<Keyboard> ResourceManager::GetKeyboard() const {
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
std::shared_ptr<Mouse> ResourceManager::GetMouse() const {
|
||||
return mouse;
|
||||
}
|
||||
|
||||
std::shared_ptr<NPad> ResourceManager::GetNpad() const {
|
||||
return npad;
|
||||
}
|
||||
|
||||
std::shared_ptr<Palma> ResourceManager::GetPalma() const {
|
||||
return palma;
|
||||
}
|
||||
|
||||
std::shared_ptr<SevenSixAxis> ResourceManager::GetSevenSixAxis() const {
|
||||
return seven_six_axis;
|
||||
}
|
||||
|
||||
std::shared_ptr<SixAxis> ResourceManager::GetSixAxis() const {
|
||||
return six_axis;
|
||||
}
|
||||
|
||||
std::shared_ptr<SleepButton> ResourceManager::GetSleepButton() const {
|
||||
return sleep_button;
|
||||
}
|
||||
|
||||
std::shared_ptr<TouchScreen> ResourceManager::GetTouchScreen() const {
|
||||
return touch_screen;
|
||||
}
|
||||
|
||||
std::shared_ptr<UniquePad> ResourceManager::GetUniquePad() const {
|
||||
return unique_pad;
|
||||
}
|
||||
|
||||
void ResourceManager::UpdateControllers(std::uintptr_t user_data,
|
||||
std::chrono::nanoseconds ns_late) {
|
||||
auto& core_timing = system.CoreTiming();
|
||||
debug_pad->OnUpdate(core_timing);
|
||||
unique_pad->OnUpdate(core_timing);
|
||||
gesture->OnUpdate(core_timing);
|
||||
touch_screen->OnUpdate(core_timing);
|
||||
palma->OnUpdate(core_timing);
|
||||
home_button->OnUpdate(core_timing);
|
||||
sleep_button->OnUpdate(core_timing);
|
||||
capture_button->OnUpdate(core_timing);
|
||||
xpad->OnUpdate(core_timing);
|
||||
|
||||
for (const auto& controller : controllers) {
|
||||
// Keyboard has it's own update event
|
||||
if (controller == controllers[static_cast<size_t>(HidController::Keyboard)]) {
|
||||
continue;
|
||||
}
|
||||
// Mouse has it's own update event
|
||||
if (controller == controllers[static_cast<size_t>(HidController::Mouse)]) {
|
||||
continue;
|
||||
}
|
||||
// Npad has it's own update event
|
||||
if (controller == controllers[static_cast<size_t>(HidController::NPad)]) {
|
||||
continue;
|
||||
}
|
||||
controller->OnUpdate(core_timing);
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceManager::UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) {
|
||||
auto& core_timing = system.CoreTiming();
|
||||
npad->OnUpdate(core_timing);
|
||||
|
||||
controllers[static_cast<size_t>(HidController::NPad)]->OnUpdate(core_timing);
|
||||
}
|
||||
|
||||
void ResourceManager::UpdateMouseKeyboard(std::uintptr_t user_data,
|
||||
std::chrono::nanoseconds ns_late) {
|
||||
auto& core_timing = system.CoreTiming();
|
||||
mouse->OnUpdate(core_timing);
|
||||
debug_mouse->OnUpdate(core_timing);
|
||||
keyboard->OnUpdate(core_timing);
|
||||
|
||||
controllers[static_cast<size_t>(HidController::Mouse)]->OnUpdate(core_timing);
|
||||
controllers[static_cast<size_t>(HidController::Keyboard)]->OnUpdate(core_timing);
|
||||
}
|
||||
|
||||
void ResourceManager::UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) {
|
||||
auto& core_timing = system.CoreTiming();
|
||||
six_axis->OnUpdate(core_timing);
|
||||
seven_six_axis->OnUpdate(core_timing);
|
||||
console_six_axis->OnUpdate(core_timing);
|
||||
|
||||
controllers[static_cast<size_t>(HidController::NPad)]->OnMotionUpdate(core_timing);
|
||||
}
|
||||
|
||||
IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource)
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
@@ -10,49 +14,47 @@ namespace Core::Timing {
|
||||
struct EventType;
|
||||
}
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
}
|
||||
|
||||
namespace Service::HID {
|
||||
class Controller_Stubbed;
|
||||
class ConsoleSixAxis;
|
||||
class DebugPad;
|
||||
class Gesture;
|
||||
class Keyboard;
|
||||
class Mouse;
|
||||
class NPad;
|
||||
class Palma;
|
||||
class SevenSixAxis;
|
||||
class SixAxis;
|
||||
class TouchScreen;
|
||||
class XPad;
|
||||
|
||||
using CaptureButton = Controller_Stubbed;
|
||||
using DebugMouse = Controller_Stubbed;
|
||||
using HomeButton = Controller_Stubbed;
|
||||
using SleepButton = Controller_Stubbed;
|
||||
using UniquePad = Controller_Stubbed;
|
||||
enum class HidController : std::size_t {
|
||||
DebugPad,
|
||||
Touchscreen,
|
||||
Mouse,
|
||||
Keyboard,
|
||||
XPad,
|
||||
HomeButton,
|
||||
SleepButton,
|
||||
CaptureButton,
|
||||
InputDetector,
|
||||
UniquePad,
|
||||
NPad,
|
||||
Gesture,
|
||||
ConsoleSixAxisSensor,
|
||||
DebugMouse,
|
||||
Palma,
|
||||
|
||||
MaxControllers,
|
||||
};
|
||||
class ResourceManager {
|
||||
|
||||
public:
|
||||
explicit ResourceManager(Core::System& system_);
|
||||
~ResourceManager();
|
||||
|
||||
void Initialize();
|
||||
template <typename T>
|
||||
T& GetController(HidController controller) {
|
||||
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
||||
}
|
||||
|
||||
std::shared_ptr<CaptureButton> GetCaptureButton() const;
|
||||
std::shared_ptr<ConsoleSixAxis> GetConsoleSixAxis() const;
|
||||
std::shared_ptr<DebugMouse> GetDebugMouse() const;
|
||||
std::shared_ptr<DebugPad> GetDebugPad() const;
|
||||
std::shared_ptr<Gesture> GetGesture() const;
|
||||
std::shared_ptr<HomeButton> GetHomeButton() const;
|
||||
std::shared_ptr<Keyboard> GetKeyboard() const;
|
||||
std::shared_ptr<Mouse> GetMouse() const;
|
||||
std::shared_ptr<NPad> GetNpad() const;
|
||||
std::shared_ptr<Palma> GetPalma() const;
|
||||
std::shared_ptr<SevenSixAxis> GetSevenSixAxis() const;
|
||||
std::shared_ptr<SixAxis> GetSixAxis() const;
|
||||
std::shared_ptr<SleepButton> GetSleepButton() const;
|
||||
std::shared_ptr<TouchScreen> GetTouchScreen() const;
|
||||
std::shared_ptr<UniquePad> GetUniquePad() const;
|
||||
template <typename T>
|
||||
const T& GetController(HidController controller) const {
|
||||
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
||||
}
|
||||
|
||||
void Initialize();
|
||||
|
||||
void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
||||
void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
||||
@@ -60,35 +62,26 @@ public:
|
||||
void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
void MakeController(HidController controller, u8* shared_memory) {
|
||||
if constexpr (std::is_constructible_v<T, Core::System&, u8*>) {
|
||||
controllers[static_cast<std::size_t>(controller)] =
|
||||
std::make_unique<T>(system, shared_memory);
|
||||
} else {
|
||||
controllers[static_cast<std::size_t>(controller)] =
|
||||
std::make_unique<T>(system.HIDCore(), shared_memory);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) {
|
||||
controllers[static_cast<std::size_t>(controller)] =
|
||||
std::make_unique<T>(system.HIDCore(), shared_memory, service_context);
|
||||
}
|
||||
|
||||
bool is_initialized{false};
|
||||
|
||||
std::shared_ptr<CaptureButton> capture_button = nullptr;
|
||||
std::shared_ptr<ConsoleSixAxis> console_six_axis = nullptr;
|
||||
std::shared_ptr<DebugMouse> debug_mouse = nullptr;
|
||||
std::shared_ptr<DebugPad> debug_pad = nullptr;
|
||||
std::shared_ptr<Gesture> gesture = nullptr;
|
||||
std::shared_ptr<HomeButton> home_button = nullptr;
|
||||
std::shared_ptr<Keyboard> keyboard = nullptr;
|
||||
std::shared_ptr<Mouse> mouse = nullptr;
|
||||
std::shared_ptr<NPad> npad = nullptr;
|
||||
std::shared_ptr<Palma> palma = nullptr;
|
||||
std::shared_ptr<SevenSixAxis> seven_six_axis = nullptr;
|
||||
std::shared_ptr<SixAxis> six_axis = nullptr;
|
||||
std::shared_ptr<SleepButton> sleep_button = nullptr;
|
||||
std::shared_ptr<TouchScreen> touch_screen = nullptr;
|
||||
std::shared_ptr<UniquePad> unique_pad = nullptr;
|
||||
std::shared_ptr<XPad> xpad = nullptr;
|
||||
|
||||
// TODO: Create these resources
|
||||
// std::shared_ptr<AudioControl> audio_control = nullptr;
|
||||
// std::shared_ptr<ButtonConfig> button_config = nullptr;
|
||||
// std::shared_ptr<Config> config = nullptr;
|
||||
// std::shared_ptr<Connection> connection = nullptr;
|
||||
// std::shared_ptr<CustomConfig> custom_config = nullptr;
|
||||
// std::shared_ptr<Digitizer> digitizer = nullptr;
|
||||
// std::shared_ptr<Hdls> hdls = nullptr;
|
||||
// std::shared_ptr<PlayReport> play_report = nullptr;
|
||||
// std::shared_ptr<Rail> rail = nullptr;
|
||||
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
||||
controllers{};
|
||||
|
||||
Core::System& system;
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "core/core.h"
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/service/hid/hid_util.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/nfc/common/device.h"
|
||||
#include "core/hle/service/nfc/common/device_manager.h"
|
||||
@@ -25,7 +24,7 @@ DeviceManager::DeviceManager(Core::System& system_, KernelHelpers::ServiceContex
|
||||
|
||||
for (u32 device_index = 0; device_index < devices.size(); device_index++) {
|
||||
devices[device_index] =
|
||||
std::make_shared<NfcDevice>(HID::IndexToNpadIdType(device_index), system,
|
||||
std::make_shared<NfcDevice>(Core::HID::IndexToNpadIdType(device_index), system,
|
||||
service_context, availability_change_event);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,16 +145,14 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
|
||||
// Apply patches if necessary
|
||||
const auto name = nso_file.GetName();
|
||||
if (pm && (pm->HasNSOPatch(nso_header.build_id, name) || Settings::values.dump_nso)) {
|
||||
std::span<u8> patchable_section(program_image.data() + module_start,
|
||||
program_image.size() - module_start);
|
||||
std::vector<u8> pi_header(sizeof(NSOHeader) + patchable_section.size());
|
||||
std::vector<u8> pi_header(sizeof(NSOHeader) + program_image.size());
|
||||
std::memcpy(pi_header.data(), &nso_header, sizeof(NSOHeader));
|
||||
std::memcpy(pi_header.data() + sizeof(NSOHeader), patchable_section.data(),
|
||||
patchable_section.size());
|
||||
std::memcpy(pi_header.data() + sizeof(NSOHeader), program_image.data(),
|
||||
program_image.size());
|
||||
|
||||
pi_header = pm->PatchNSO(pi_header, name);
|
||||
|
||||
std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), patchable_section.data());
|
||||
std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.data());
|
||||
}
|
||||
|
||||
#ifdef HAS_NCE
|
||||
|
||||
@@ -78,51 +78,6 @@ struct Memory::Impl {
|
||||
}
|
||||
}
|
||||
|
||||
void ProtectRegion(Common::PageTable& page_table, VAddr vaddr, u64 size,
|
||||
Common::MemoryPermission perms) {
|
||||
ASSERT_MSG((size & YUZU_PAGEMASK) == 0, "non-page aligned size: {:016X}", size);
|
||||
ASSERT_MSG((vaddr & YUZU_PAGEMASK) == 0, "non-page aligned base: {:016X}", vaddr);
|
||||
|
||||
if (!Settings::IsFastmemEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool is_r = True(perms & Common::MemoryPermission::Read);
|
||||
const bool is_w = True(perms & Common::MemoryPermission::Write);
|
||||
const bool is_x =
|
||||
True(perms & Common::MemoryPermission::Execute) && Settings::IsNceEnabled();
|
||||
|
||||
if (!current_page_table) {
|
||||
system.DeviceMemory().buffer.Protect(vaddr, size, is_r, is_w, is_x);
|
||||
return;
|
||||
}
|
||||
|
||||
u64 protect_bytes{};
|
||||
u64 protect_begin{};
|
||||
for (u64 addr = vaddr; addr < vaddr + size; addr += YUZU_PAGESIZE) {
|
||||
const Common::PageType page_type{
|
||||
current_page_table->pointers[addr >> YUZU_PAGEBITS].Type()};
|
||||
switch (page_type) {
|
||||
case Common::PageType::RasterizerCachedMemory:
|
||||
if (protect_bytes > 0) {
|
||||
system.DeviceMemory().buffer.Protect(protect_begin, protect_bytes, is_r, is_w,
|
||||
is_x);
|
||||
protect_bytes = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (protect_bytes == 0) {
|
||||
protect_begin = addr;
|
||||
}
|
||||
protect_bytes += YUZU_PAGESIZE;
|
||||
}
|
||||
}
|
||||
|
||||
if (protect_bytes > 0) {
|
||||
system.DeviceMemory().buffer.Protect(protect_begin, protect_bytes, is_r, is_w, is_x);
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] u8* GetPointerFromRasterizerCachedMemory(u64 vaddr) const {
|
||||
const Common::PhysicalAddress paddr{
|
||||
current_page_table->backing_addr[vaddr >> YUZU_PAGEBITS]};
|
||||
@@ -884,11 +839,6 @@ void Memory::UnmapRegion(Common::PageTable& page_table, Common::ProcessAddress b
|
||||
impl->UnmapRegion(page_table, base, size);
|
||||
}
|
||||
|
||||
void Memory::ProtectRegion(Common::PageTable& page_table, Common::ProcessAddress vaddr, u64 size,
|
||||
Common::MemoryPermission perms) {
|
||||
impl->ProtectRegion(page_table, GetInteger(vaddr), size, perms);
|
||||
}
|
||||
|
||||
bool Memory::IsValidVirtualAddress(const Common::ProcessAddress vaddr) const {
|
||||
const Kernel::KProcess& process = *system.ApplicationProcess();
|
||||
const auto& page_table = process.GetPageTable().GetImpl();
|
||||
|
||||
@@ -97,17 +97,6 @@ public:
|
||||
*/
|
||||
void UnmapRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size);
|
||||
|
||||
/**
|
||||
* Protects a region of the emulated process address space with the new permissions.
|
||||
*
|
||||
* @param page_table The page table of the emulated process.
|
||||
* @param base The start address to re-protect. Must be page-aligned.
|
||||
* @param size The amount of bytes to protect. Must be page-aligned.
|
||||
* @param perms The permissions the address range is mapped.
|
||||
*/
|
||||
void ProtectRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size,
|
||||
Common::MemoryPermission perms);
|
||||
|
||||
/**
|
||||
* Checks whether or not the supplied address is a valid virtual
|
||||
* address for the current process.
|
||||
|
||||
@@ -68,7 +68,10 @@ u64 StandardVmCallbacks::HidKeysDown() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto press_state = applet_resource->GetNpad()->GetAndResetPressState();
|
||||
const auto press_state =
|
||||
applet_resource
|
||||
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)
|
||||
.GetAndResetPressState();
|
||||
return static_cast<u64>(press_state & HID::NpadButton::All);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
add_subdirectory(host_shaders)
|
||||
|
||||
if(LIBVA_FOUND)
|
||||
set_source_files_properties(host1x/ffmpeg/ffmpeg.cpp
|
||||
set_source_files_properties(host1x/codecs/codec.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS LIBVA_FOUND=1)
|
||||
list(APPEND FFmpeg_LIBRARIES ${LIBVA_LIBRARIES})
|
||||
endif()
|
||||
@@ -67,8 +67,6 @@ add_library(video_core STATIC
|
||||
host1x/codecs/vp9.cpp
|
||||
host1x/codecs/vp9.h
|
||||
host1x/codecs/vp9_types.h
|
||||
host1x/ffmpeg/ffmpeg.cpp
|
||||
host1x/ffmpeg/ffmpeg.h
|
||||
host1x/control.cpp
|
||||
host1x/control.h
|
||||
host1x/host1x.cpp
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "common/assert.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/settings.h"
|
||||
#include "video_core/host1x/codecs/codec.h"
|
||||
#include "video_core/host1x/codecs/h264.h"
|
||||
@@ -10,17 +14,242 @@
|
||||
#include "video_core/host1x/host1x.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
#include <libavutil/opt.h>
|
||||
#ifdef LIBVA_FOUND
|
||||
// for querying VAAPI driver information
|
||||
#include <libavutil/hwcontext_vaapi.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Tegra {
|
||||
namespace {
|
||||
constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12;
|
||||
constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P;
|
||||
constexpr std::array PREFERRED_GPU_DECODERS = {
|
||||
AV_HWDEVICE_TYPE_CUDA,
|
||||
#ifdef _WIN32
|
||||
AV_HWDEVICE_TYPE_D3D11VA,
|
||||
AV_HWDEVICE_TYPE_DXVA2,
|
||||
#elif defined(__unix__)
|
||||
AV_HWDEVICE_TYPE_VAAPI,
|
||||
AV_HWDEVICE_TYPE_VDPAU,
|
||||
#endif
|
||||
// last resort for Linux Flatpak (w/ NVIDIA)
|
||||
AV_HWDEVICE_TYPE_VULKAN,
|
||||
};
|
||||
|
||||
void AVPacketDeleter(AVPacket* ptr) {
|
||||
av_packet_free(&ptr);
|
||||
}
|
||||
|
||||
using AVPacketPtr = std::unique_ptr<AVPacket, decltype(&AVPacketDeleter)>;
|
||||
|
||||
AVPixelFormat GetGpuFormat(AVCodecContext* av_codec_ctx, const AVPixelFormat* pix_fmts) {
|
||||
for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
||||
if (*p == av_codec_ctx->pix_fmt) {
|
||||
return av_codec_ctx->pix_fmt;
|
||||
}
|
||||
}
|
||||
LOG_INFO(Service_NVDRV, "Could not find compatible GPU AV format, falling back to CPU");
|
||||
av_buffer_unref(&av_codec_ctx->hw_device_ctx);
|
||||
av_codec_ctx->pix_fmt = PREFERRED_CPU_FMT;
|
||||
return PREFERRED_CPU_FMT;
|
||||
}
|
||||
|
||||
// List all the currently available hwcontext in ffmpeg
|
||||
std::vector<AVHWDeviceType> ListSupportedContexts() {
|
||||
std::vector<AVHWDeviceType> contexts{};
|
||||
AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
|
||||
do {
|
||||
current_device_type = av_hwdevice_iterate_types(current_device_type);
|
||||
contexts.push_back(current_device_type);
|
||||
} while (current_device_type != AV_HWDEVICE_TYPE_NONE);
|
||||
return contexts;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AVFrameDeleter(AVFrame* ptr) {
|
||||
av_frame_free(&ptr);
|
||||
}
|
||||
|
||||
Codec::Codec(Host1x::Host1x& host1x_, const Host1x::NvdecCommon::NvdecRegisters& regs)
|
||||
: host1x(host1x_), state{regs}, h264_decoder(std::make_unique<Decoder::H264>(host1x)),
|
||||
vp8_decoder(std::make_unique<Decoder::VP8>(host1x)),
|
||||
vp9_decoder(std::make_unique<Decoder::VP9>(host1x)) {}
|
||||
|
||||
Codec::~Codec() = default;
|
||||
Codec::~Codec() {
|
||||
if (!initialized) {
|
||||
return;
|
||||
}
|
||||
// Free libav memory
|
||||
avcodec_free_context(&av_codec_ctx);
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
|
||||
if (filters_initialized) {
|
||||
avfilter_graph_free(&av_filter_graph);
|
||||
}
|
||||
}
|
||||
|
||||
bool Codec::CreateGpuAvDevice() {
|
||||
static constexpr auto HW_CONFIG_METHOD = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX;
|
||||
static const auto supported_contexts = ListSupportedContexts();
|
||||
for (const auto& type : PREFERRED_GPU_DECODERS) {
|
||||
if (std::none_of(supported_contexts.begin(), supported_contexts.end(),
|
||||
[&type](const auto& context) { return context == type; })) {
|
||||
LOG_DEBUG(Service_NVDRV, "{} explicitly unsupported", av_hwdevice_get_type_name(type));
|
||||
continue;
|
||||
}
|
||||
// Avoid memory leak from not cleaning up after av_hwdevice_ctx_create
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
const int hwdevice_res = av_hwdevice_ctx_create(&av_gpu_decoder, type, nullptr, nullptr, 0);
|
||||
if (hwdevice_res < 0) {
|
||||
LOG_DEBUG(Service_NVDRV, "{} av_hwdevice_ctx_create failed {}",
|
||||
av_hwdevice_get_type_name(type), hwdevice_res);
|
||||
continue;
|
||||
}
|
||||
#ifdef LIBVA_FOUND
|
||||
if (type == AV_HWDEVICE_TYPE_VAAPI) {
|
||||
// we need to determine if this is an impersonated VAAPI driver
|
||||
AVHWDeviceContext* hwctx =
|
||||
static_cast<AVHWDeviceContext*>(static_cast<void*>(av_gpu_decoder->data));
|
||||
AVVAAPIDeviceContext* vactx = static_cast<AVVAAPIDeviceContext*>(hwctx->hwctx);
|
||||
const char* vendor_name = vaQueryVendorString(vactx->display);
|
||||
if (strstr(vendor_name, "VDPAU backend")) {
|
||||
// VDPAU impersonated VAAPI impl's are super buggy, we need to skip them
|
||||
LOG_DEBUG(Service_NVDRV, "Skipping vdapu impersonated VAAPI driver");
|
||||
continue;
|
||||
} else {
|
||||
// according to some user testing, certain vaapi driver (Intel?) could be buggy
|
||||
// so let's log the driver name which may help the developers/supporters
|
||||
LOG_DEBUG(Service_NVDRV, "Using VAAPI driver: {}", vendor_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig* config = avcodec_get_hw_config(av_codec, i);
|
||||
if (!config) {
|
||||
LOG_DEBUG(Service_NVDRV, "{} decoder does not support device type {}.",
|
||||
av_codec->name, av_hwdevice_get_type_name(type));
|
||||
break;
|
||||
}
|
||||
if ((config->methods & HW_CONFIG_METHOD) != 0 && config->device_type == type) {
|
||||
LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type));
|
||||
av_codec_ctx->pix_fmt = config->pix_fmt;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Codec::InitializeAvCodecContext() {
|
||||
av_codec_ctx = avcodec_alloc_context3(av_codec);
|
||||
av_opt_set(av_codec_ctx->priv_data, "tune", "zerolatency", 0);
|
||||
av_codec_ctx->thread_count = 0;
|
||||
av_codec_ctx->thread_type &= ~FF_THREAD_FRAME;
|
||||
}
|
||||
|
||||
void Codec::InitializeGpuDecoder() {
|
||||
if (!CreateGpuAvDevice()) {
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
return;
|
||||
}
|
||||
auto* hw_device_ctx = av_buffer_ref(av_gpu_decoder);
|
||||
ASSERT_MSG(hw_device_ctx, "av_buffer_ref failed");
|
||||
av_codec_ctx->hw_device_ctx = hw_device_ctx;
|
||||
av_codec_ctx->get_format = GetGpuFormat;
|
||||
}
|
||||
|
||||
void Codec::InitializeAvFilters(AVFrame* frame) {
|
||||
const AVFilter* buffer_src = avfilter_get_by_name("buffer");
|
||||
const AVFilter* buffer_sink = avfilter_get_by_name("buffersink");
|
||||
AVFilterInOut* inputs = avfilter_inout_alloc();
|
||||
AVFilterInOut* outputs = avfilter_inout_alloc();
|
||||
SCOPE_EXIT({
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
});
|
||||
|
||||
// Don't know how to get the accurate time_base but it doesn't matter for yadif filter
|
||||
// so just use 1/1 to make buffer filter happy
|
||||
std::string args = fmt::format("video_size={}x{}:pix_fmt={}:time_base=1/1", frame->width,
|
||||
frame->height, frame->format);
|
||||
|
||||
av_filter_graph = avfilter_graph_alloc();
|
||||
int ret = avfilter_graph_create_filter(&av_filter_src_ctx, buffer_src, "in", args.c_str(),
|
||||
nullptr, av_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_create_filter source error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_create_filter(&av_filter_sink_ctx, buffer_sink, "out", nullptr, nullptr,
|
||||
av_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_create_filter sink error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
inputs->name = av_strdup("out");
|
||||
inputs->filter_ctx = av_filter_sink_ctx;
|
||||
inputs->pad_idx = 0;
|
||||
inputs->next = nullptr;
|
||||
|
||||
outputs->name = av_strdup("in");
|
||||
outputs->filter_ctx = av_filter_src_ctx;
|
||||
outputs->pad_idx = 0;
|
||||
outputs->next = nullptr;
|
||||
|
||||
const char* description = "yadif=1:-1:0";
|
||||
ret = avfilter_graph_parse_ptr(av_filter_graph, description, &inputs, &outputs, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_parse_ptr error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_config(av_filter_graph, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avfilter_graph_config error: {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
filters_initialized = true;
|
||||
}
|
||||
|
||||
void Codec::Initialize() {
|
||||
initialized = decode_api.Initialize(current_codec);
|
||||
const AVCodecID codec = [&] {
|
||||
switch (current_codec) {
|
||||
case Host1x::NvdecCommon::VideoCodec::H264:
|
||||
return AV_CODEC_ID_H264;
|
||||
case Host1x::NvdecCommon::VideoCodec::VP8:
|
||||
return AV_CODEC_ID_VP8;
|
||||
case Host1x::NvdecCommon::VideoCodec::VP9:
|
||||
return AV_CODEC_ID_VP9;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unknown codec {}", current_codec);
|
||||
return AV_CODEC_ID_NONE;
|
||||
}
|
||||
}();
|
||||
av_codec = avcodec_find_decoder(codec);
|
||||
|
||||
InitializeAvCodecContext();
|
||||
if (Settings::values.nvdec_emulation.GetValue() == Settings::NvdecEmulation::Gpu) {
|
||||
InitializeGpuDecoder();
|
||||
}
|
||||
if (const int res = avcodec_open2(av_codec_ctx, av_codec, nullptr); res < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed with result {}", res);
|
||||
avcodec_free_context(&av_codec_ctx);
|
||||
av_buffer_unref(&av_gpu_decoder);
|
||||
return;
|
||||
}
|
||||
if (!av_codec_ctx->hw_device_ctx) {
|
||||
LOG_INFO(Service_NVDRV, "Using FFmpeg software decoding");
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void Codec::SetTargetCodec(Host1x::NvdecCommon::VideoCodec codec) {
|
||||
@@ -35,18 +264,14 @@ void Codec::Decode() {
|
||||
if (is_first_frame) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Assemble bitstream.
|
||||
bool vp9_hidden_frame = false;
|
||||
size_t configuration_size = 0;
|
||||
const auto packet_data = [&]() {
|
||||
const auto& frame_data = [&]() {
|
||||
switch (current_codec) {
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::H264:
|
||||
return h264_decoder->ComposeFrame(state, &configuration_size, is_first_frame);
|
||||
return h264_decoder->ComposeFrame(state, is_first_frame);
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP8:
|
||||
return vp8_decoder->ComposeFrame(state);
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP9:
|
||||
@@ -58,35 +283,89 @@ void Codec::Decode() {
|
||||
return std::span<const u8>{};
|
||||
}
|
||||
}();
|
||||
|
||||
// Send assembled bitstream to decoder.
|
||||
if (!decode_api.SendPacket(packet_data, configuration_size)) {
|
||||
AVPacketPtr packet{av_packet_alloc(), AVPacketDeleter};
|
||||
if (!packet) {
|
||||
LOG_ERROR(Service_NVDRV, "av_packet_alloc failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Only receive/store visible frames.
|
||||
packet->data = const_cast<u8*>(frame_data.data());
|
||||
packet->size = static_cast<s32>(frame_data.size());
|
||||
if (const int res = avcodec_send_packet(av_codec_ctx, packet.get()); res != 0) {
|
||||
LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", res);
|
||||
return;
|
||||
}
|
||||
// Only receive/store visible frames
|
||||
if (vp9_hidden_frame) {
|
||||
return;
|
||||
}
|
||||
AVFramePtr initial_frame{av_frame_alloc(), AVFrameDeleter};
|
||||
AVFramePtr final_frame{nullptr, AVFrameDeleter};
|
||||
ASSERT_MSG(initial_frame, "av_frame_alloc initial_frame failed");
|
||||
if (const int ret = avcodec_receive_frame(av_codec_ctx, initial_frame.get()); ret) {
|
||||
LOG_DEBUG(Service_NVDRV, "avcodec_receive_frame error {}", ret);
|
||||
return;
|
||||
}
|
||||
if (initial_frame->width == 0 || initial_frame->height == 0) {
|
||||
LOG_WARNING(Service_NVDRV, "Zero width or height in frame");
|
||||
return;
|
||||
}
|
||||
bool is_interlaced = initial_frame->interlaced_frame != 0;
|
||||
if (av_codec_ctx->hw_device_ctx) {
|
||||
final_frame = AVFramePtr{av_frame_alloc(), AVFrameDeleter};
|
||||
ASSERT_MSG(final_frame, "av_frame_alloc final_frame failed");
|
||||
// Can't use AV_PIX_FMT_YUV420P and share code with software decoding in vic.cpp
|
||||
// because Intel drivers crash unless using AV_PIX_FMT_NV12
|
||||
final_frame->format = PREFERRED_GPU_FMT;
|
||||
const int ret = av_hwframe_transfer_data(final_frame.get(), initial_frame.get(), 0);
|
||||
ASSERT_MSG(!ret, "av_hwframe_transfer_data error {}", ret);
|
||||
} else {
|
||||
final_frame = std::move(initial_frame);
|
||||
}
|
||||
if (final_frame->format != PREFERRED_CPU_FMT && final_frame->format != PREFERRED_GPU_FMT) {
|
||||
UNIMPLEMENTED_MSG("Unexpected video format: {}", final_frame->format);
|
||||
return;
|
||||
}
|
||||
if (!is_interlaced) {
|
||||
av_frames.push(std::move(final_frame));
|
||||
} else {
|
||||
if (!filters_initialized) {
|
||||
InitializeAvFilters(final_frame.get());
|
||||
}
|
||||
if (const int ret = av_buffersrc_add_frame_flags(av_filter_src_ctx, final_frame.get(),
|
||||
AV_BUFFERSRC_FLAG_KEEP_REF);
|
||||
ret) {
|
||||
LOG_DEBUG(Service_NVDRV, "av_buffersrc_add_frame_flags error {}", ret);
|
||||
return;
|
||||
}
|
||||
while (true) {
|
||||
auto filter_frame = AVFramePtr{av_frame_alloc(), AVFrameDeleter};
|
||||
|
||||
// Receive output frames from decoder.
|
||||
decode_api.ReceiveFrames(frames);
|
||||
int ret = av_buffersink_get_frame(av_filter_sink_ctx, filter_frame.get());
|
||||
|
||||
while (frames.size() > 10) {
|
||||
LOG_DEBUG(HW_GPU, "ReceiveFrames overflow, dropped frame");
|
||||
frames.pop();
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR(AVERROR_EOF))
|
||||
break;
|
||||
if (ret < 0) {
|
||||
LOG_DEBUG(Service_NVDRV, "av_buffersink_get_frame error {}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
av_frames.push(std::move(filter_frame));
|
||||
}
|
||||
}
|
||||
while (av_frames.size() > 10) {
|
||||
LOG_TRACE(Service_NVDRV, "av_frames.push overflow dropped frame");
|
||||
av_frames.pop();
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<FFmpeg::Frame> Codec::GetCurrentFrame() {
|
||||
AVFramePtr Codec::GetCurrentFrame() {
|
||||
// Sometimes VIC will request more frames than have been decoded.
|
||||
// in this case, return a blank frame and don't overwrite previous data.
|
||||
if (frames.empty()) {
|
||||
return {};
|
||||
// in this case, return a nullptr and don't overwrite previous frame data
|
||||
if (av_frames.empty()) {
|
||||
return AVFramePtr{nullptr, AVFrameDeleter};
|
||||
}
|
||||
|
||||
auto frame = std::move(frames.front());
|
||||
frames.pop();
|
||||
AVFramePtr frame = std::move(av_frames.front());
|
||||
av_frames.pop();
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <queue>
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/host1x/ffmpeg/ffmpeg.h"
|
||||
#include "video_core/host1x/nvdec_common.h"
|
||||
|
||||
extern "C" {
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Tegra {
|
||||
|
||||
void AVFrameDeleter(AVFrame* ptr);
|
||||
using AVFramePtr = std::unique_ptr<AVFrame, decltype(&AVFrameDeleter)>;
|
||||
|
||||
namespace Decoder {
|
||||
class H264;
|
||||
class VP8;
|
||||
@@ -38,7 +51,7 @@ public:
|
||||
void Decode();
|
||||
|
||||
/// Returns next decoded frame
|
||||
[[nodiscard]] std::unique_ptr<FFmpeg::Frame> GetCurrentFrame();
|
||||
[[nodiscard]] AVFramePtr GetCurrentFrame();
|
||||
|
||||
/// Returns the value of current_codec
|
||||
[[nodiscard]] Host1x::NvdecCommon::VideoCodec GetCurrentCodec() const;
|
||||
@@ -47,9 +60,25 @@ public:
|
||||
[[nodiscard]] std::string_view GetCurrentCodecName() const;
|
||||
|
||||
private:
|
||||
void InitializeAvCodecContext();
|
||||
|
||||
void InitializeAvFilters(AVFrame* frame);
|
||||
|
||||
void InitializeGpuDecoder();
|
||||
|
||||
bool CreateGpuAvDevice();
|
||||
|
||||
bool initialized{};
|
||||
bool filters_initialized{};
|
||||
Host1x::NvdecCommon::VideoCodec current_codec{Host1x::NvdecCommon::VideoCodec::None};
|
||||
FFmpeg::DecodeApi decode_api;
|
||||
|
||||
const AVCodec* av_codec{nullptr};
|
||||
AVCodecContext* av_codec_ctx{nullptr};
|
||||
AVBufferRef* av_gpu_decoder{nullptr};
|
||||
|
||||
AVFilterContext* av_filter_src_ctx{nullptr};
|
||||
AVFilterContext* av_filter_sink_ctx{nullptr};
|
||||
AVFilterGraph* av_filter_graph{nullptr};
|
||||
|
||||
Host1x::Host1x& host1x;
|
||||
const Host1x::NvdecCommon::NvdecRegisters& state;
|
||||
@@ -57,7 +86,7 @@ private:
|
||||
std::unique_ptr<Decoder::VP8> vp8_decoder;
|
||||
std::unique_ptr<Decoder::VP9> vp9_decoder;
|
||||
|
||||
std::queue<std::unique_ptr<FFmpeg::Frame>> frames{};
|
||||
std::queue<AVFramePtr> av_frames{};
|
||||
};
|
||||
|
||||
} // namespace Tegra
|
||||
|
||||
@@ -30,7 +30,7 @@ H264::H264(Host1x::Host1x& host1x_) : host1x{host1x_} {}
|
||||
H264::~H264() = default;
|
||||
|
||||
std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state,
|
||||
size_t* out_configuration_size, bool is_first_frame) {
|
||||
bool is_first_frame) {
|
||||
H264DecoderContext context;
|
||||
host1x.MemoryManager().ReadBlock(state.picture_info_offset, &context,
|
||||
sizeof(H264DecoderContext));
|
||||
@@ -39,7 +39,6 @@ std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters
|
||||
if (!is_first_frame && frame_number != 0) {
|
||||
frame.resize_destructive(context.stream_len);
|
||||
host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size());
|
||||
*out_configuration_size = 0;
|
||||
return frame;
|
||||
}
|
||||
|
||||
@@ -158,7 +157,6 @@ std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters
|
||||
frame.resize(encoded_header.size() + context.stream_len);
|
||||
std::memcpy(frame.data(), encoded_header.data(), encoded_header.size());
|
||||
|
||||
*out_configuration_size = encoded_header.size();
|
||||
host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset,
|
||||
frame.data() + encoded_header.size(), context.stream_len);
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
|
||||
/// Compose the H264 frame for FFmpeg decoding
|
||||
[[nodiscard]] std::span<const u8> ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state,
|
||||
size_t* out_configuration_size,
|
||||
bool is_first_frame = false);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/settings.h"
|
||||
#include "video_core/host1x/ffmpeg/ffmpeg.h"
|
||||
|
||||
extern "C" {
|
||||
#ifdef LIBVA_FOUND
|
||||
// for querying VAAPI driver information
|
||||
#include <libavutil/hwcontext_vaapi.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace FFmpeg {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr AVPixelFormat PreferredGpuFormat = AV_PIX_FMT_NV12;
|
||||
constexpr AVPixelFormat PreferredCpuFormat = AV_PIX_FMT_YUV420P;
|
||||
constexpr std::array PreferredGpuDecoders = {
|
||||
AV_HWDEVICE_TYPE_CUDA,
|
||||
#ifdef _WIN32
|
||||
AV_HWDEVICE_TYPE_D3D11VA,
|
||||
AV_HWDEVICE_TYPE_DXVA2,
|
||||
#elif defined(__unix__)
|
||||
AV_HWDEVICE_TYPE_VAAPI,
|
||||
AV_HWDEVICE_TYPE_VDPAU,
|
||||
#endif
|
||||
// last resort for Linux Flatpak (w/ NVIDIA)
|
||||
AV_HWDEVICE_TYPE_VULKAN,
|
||||
};
|
||||
|
||||
AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* pix_fmts) {
|
||||
for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
||||
if (*p == codec_context->pix_fmt) {
|
||||
return codec_context->pix_fmt;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO(HW_GPU, "Could not find compatible GPU AV format, falling back to CPU");
|
||||
av_buffer_unref(&codec_context->hw_device_ctx);
|
||||
|
||||
codec_context->pix_fmt = PreferredCpuFormat;
|
||||
return codec_context->pix_fmt;
|
||||
}
|
||||
|
||||
std::string AVError(int errnum) {
|
||||
char errbuf[AV_ERROR_MAX_STRING_SIZE] = {};
|
||||
av_make_error_string(errbuf, sizeof(errbuf) - 1, errnum);
|
||||
return errbuf;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Packet::Packet(std::span<const u8> data) {
|
||||
m_packet = av_packet_alloc();
|
||||
m_packet->data = const_cast<u8*>(data.data());
|
||||
m_packet->size = static_cast<s32>(data.size());
|
||||
}
|
||||
|
||||
Packet::~Packet() {
|
||||
av_packet_free(&m_packet);
|
||||
}
|
||||
|
||||
Frame::Frame() {
|
||||
m_frame = av_frame_alloc();
|
||||
}
|
||||
|
||||
Frame::~Frame() {
|
||||
av_frame_free(&m_frame);
|
||||
}
|
||||
|
||||
Decoder::Decoder(Tegra::Host1x::NvdecCommon::VideoCodec codec) {
|
||||
const AVCodecID av_codec = [&] {
|
||||
switch (codec) {
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::H264:
|
||||
return AV_CODEC_ID_H264;
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP8:
|
||||
return AV_CODEC_ID_VP8;
|
||||
case Tegra::Host1x::NvdecCommon::VideoCodec::VP9:
|
||||
return AV_CODEC_ID_VP9;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unknown codec {}", codec);
|
||||
return AV_CODEC_ID_NONE;
|
||||
}
|
||||
}();
|
||||
|
||||
m_codec = avcodec_find_decoder(av_codec);
|
||||
}
|
||||
|
||||
bool Decoder::SupportsDecodingOnDevice(AVPixelFormat* out_pix_fmt, AVHWDeviceType type) const {
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig* config = avcodec_get_hw_config(m_codec, i);
|
||||
if (!config) {
|
||||
LOG_DEBUG(HW_GPU, "{} decoder does not support device type {}", m_codec->name,
|
||||
av_hwdevice_get_type_name(type));
|
||||
break;
|
||||
}
|
||||
if ((config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) != 0 &&
|
||||
config->device_type == type) {
|
||||
LOG_INFO(HW_GPU, "Using {} GPU decoder", av_hwdevice_get_type_name(type));
|
||||
*out_pix_fmt = config->pix_fmt;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<AVHWDeviceType> HardwareContext::GetSupportedDeviceTypes() {
|
||||
std::vector<AVHWDeviceType> types;
|
||||
AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
|
||||
|
||||
while (true) {
|
||||
current_device_type = av_hwdevice_iterate_types(current_device_type);
|
||||
if (current_device_type == AV_HWDEVICE_TYPE_NONE) {
|
||||
return types;
|
||||
}
|
||||
|
||||
types.push_back(current_device_type);
|
||||
}
|
||||
}
|
||||
|
||||
HardwareContext::~HardwareContext() {
|
||||
av_buffer_unref(&m_gpu_decoder);
|
||||
}
|
||||
|
||||
bool HardwareContext::InitializeForDecoder(DecoderContext& decoder_context,
|
||||
const Decoder& decoder) {
|
||||
const auto supported_types = GetSupportedDeviceTypes();
|
||||
for (const auto type : PreferredGpuDecoders) {
|
||||
AVPixelFormat hw_pix_fmt;
|
||||
|
||||
if (std::ranges::find(supported_types, type) == supported_types.end()) {
|
||||
LOG_DEBUG(HW_GPU, "{} explicitly unsupported", av_hwdevice_get_type_name(type));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this->InitializeWithType(type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (decoder.SupportsDecodingOnDevice(&hw_pix_fmt, type)) {
|
||||
decoder_context.InitializeHardwareDecoder(*this, hw_pix_fmt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HardwareContext::InitializeWithType(AVHWDeviceType type) {
|
||||
av_buffer_unref(&m_gpu_decoder);
|
||||
|
||||
if (const int ret = av_hwdevice_ctx_create(&m_gpu_decoder, type, nullptr, nullptr, 0);
|
||||
ret < 0) {
|
||||
LOG_DEBUG(HW_GPU, "av_hwdevice_ctx_create({}) failed: {}", av_hwdevice_get_type_name(type),
|
||||
AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef LIBVA_FOUND
|
||||
if (type == AV_HWDEVICE_TYPE_VAAPI) {
|
||||
// We need to determine if this is an impersonated VAAPI driver.
|
||||
auto* hwctx = reinterpret_cast<AVHWDeviceContext*>(m_gpu_decoder->data);
|
||||
auto* vactx = static_cast<AVVAAPIDeviceContext*>(hwctx->hwctx);
|
||||
const char* vendor_name = vaQueryVendorString(vactx->display);
|
||||
if (strstr(vendor_name, "VDPAU backend")) {
|
||||
// VDPAU impersonated VAAPI impls are super buggy, we need to skip them.
|
||||
LOG_DEBUG(HW_GPU, "Skipping VDPAU impersonated VAAPI driver");
|
||||
return false;
|
||||
} else {
|
||||
// According to some user testing, certain VAAPI drivers (Intel?) could be buggy.
|
||||
// Log the driver name just in case.
|
||||
LOG_DEBUG(HW_GPU, "Using VAAPI driver: {}", vendor_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DecoderContext::DecoderContext(const Decoder& decoder) {
|
||||
m_codec_context = avcodec_alloc_context3(decoder.GetCodec());
|
||||
av_opt_set(m_codec_context->priv_data, "tune", "zerolatency", 0);
|
||||
m_codec_context->thread_count = 0;
|
||||
m_codec_context->thread_type &= ~FF_THREAD_FRAME;
|
||||
}
|
||||
|
||||
DecoderContext::~DecoderContext() {
|
||||
av_buffer_unref(&m_codec_context->hw_device_ctx);
|
||||
avcodec_free_context(&m_codec_context);
|
||||
}
|
||||
|
||||
void DecoderContext::InitializeHardwareDecoder(const HardwareContext& context,
|
||||
AVPixelFormat hw_pix_fmt) {
|
||||
m_codec_context->hw_device_ctx = av_buffer_ref(context.GetBufferRef());
|
||||
m_codec_context->get_format = GetGpuFormat;
|
||||
m_codec_context->pix_fmt = hw_pix_fmt;
|
||||
}
|
||||
|
||||
bool DecoderContext::OpenContext(const Decoder& decoder) {
|
||||
if (const int ret = avcodec_open2(m_codec_context, decoder.GetCodec(), nullptr); ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avcodec_open2 error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_codec_context->hw_device_ctx) {
|
||||
LOG_INFO(HW_GPU, "Using FFmpeg software decoding");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DecoderContext::SendPacket(const Packet& packet) {
|
||||
if (const int ret = avcodec_send_packet(m_codec_context, packet.GetPacket()); ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avcodec_send_packet error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Frame> DecoderContext::ReceiveFrame(bool* out_is_interlaced) {
|
||||
auto dst_frame = std::make_unique<Frame>();
|
||||
|
||||
const auto ReceiveImpl = [&](AVFrame* frame) {
|
||||
if (const int ret = avcodec_receive_frame(m_codec_context, frame); ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avcodec_receive_frame error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
*out_is_interlaced = frame->interlaced_frame != 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
if (m_codec_context->hw_device_ctx) {
|
||||
// If we have a hardware context, make a separate frame here to receive the
|
||||
// hardware result before sending it to the output.
|
||||
Frame intermediate_frame;
|
||||
|
||||
if (!ReceiveImpl(intermediate_frame.GetFrame())) {
|
||||
return {};
|
||||
}
|
||||
|
||||
dst_frame->SetFormat(PreferredGpuFormat);
|
||||
if (const int ret =
|
||||
av_hwframe_transfer_data(dst_frame->GetFrame(), intermediate_frame.GetFrame(), 0);
|
||||
ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "av_hwframe_transfer_data error: {}", AVError(ret));
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
// Otherwise, decode the frame as normal.
|
||||
if (!ReceiveImpl(dst_frame->GetFrame())) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return dst_frame;
|
||||
}
|
||||
|
||||
DeinterlaceFilter::DeinterlaceFilter(const Frame& frame) {
|
||||
const AVFilter* buffer_src = avfilter_get_by_name("buffer");
|
||||
const AVFilter* buffer_sink = avfilter_get_by_name("buffersink");
|
||||
AVFilterInOut* inputs = avfilter_inout_alloc();
|
||||
AVFilterInOut* outputs = avfilter_inout_alloc();
|
||||
SCOPE_EXIT({
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
});
|
||||
|
||||
// Don't know how to get the accurate time_base but it doesn't matter for yadif filter
|
||||
// so just use 1/1 to make buffer filter happy
|
||||
std::string args = fmt::format("video_size={}x{}:pix_fmt={}:time_base=1/1", frame.GetWidth(),
|
||||
frame.GetHeight(), static_cast<int>(frame.GetPixelFormat()));
|
||||
|
||||
m_filter_graph = avfilter_graph_alloc();
|
||||
int ret = avfilter_graph_create_filter(&m_source_context, buffer_src, "in", args.c_str(),
|
||||
nullptr, m_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_create_filter source error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_create_filter(&m_sink_context, buffer_sink, "out", nullptr, nullptr,
|
||||
m_filter_graph);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_create_filter sink error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
inputs->name = av_strdup("out");
|
||||
inputs->filter_ctx = m_sink_context;
|
||||
inputs->pad_idx = 0;
|
||||
inputs->next = nullptr;
|
||||
|
||||
outputs->name = av_strdup("in");
|
||||
outputs->filter_ctx = m_source_context;
|
||||
outputs->pad_idx = 0;
|
||||
outputs->next = nullptr;
|
||||
|
||||
const char* description = "yadif=1:-1:0";
|
||||
ret = avfilter_graph_parse_ptr(m_filter_graph, description, &inputs, &outputs, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_parse_ptr error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_config(m_filter_graph, nullptr);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "avfilter_graph_config error: {}", AVError(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
bool DeinterlaceFilter::AddSourceFrame(const Frame& frame) {
|
||||
if (const int ret = av_buffersrc_add_frame_flags(m_source_context, frame.GetFrame(),
|
||||
AV_BUFFERSRC_FLAG_KEEP_REF);
|
||||
ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "av_buffersrc_add_frame_flags error: {}", AVError(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Frame> DeinterlaceFilter::DrainSinkFrame() {
|
||||
auto dst_frame = std::make_unique<Frame>();
|
||||
const int ret = av_buffersink_get_frame(m_sink_context, dst_frame->GetFrame());
|
||||
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR(AVERROR_EOF)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(HW_GPU, "av_buffersink_get_frame error: {}", AVError(ret));
|
||||
return {};
|
||||
}
|
||||
|
||||
return dst_frame;
|
||||
}
|
||||
|
||||
DeinterlaceFilter::~DeinterlaceFilter() {
|
||||
avfilter_graph_free(&m_filter_graph);
|
||||
}
|
||||
|
||||
void DecodeApi::Reset() {
|
||||
m_deinterlace_filter.reset();
|
||||
m_hardware_context.reset();
|
||||
m_decoder_context.reset();
|
||||
m_decoder.reset();
|
||||
}
|
||||
|
||||
bool DecodeApi::Initialize(Tegra::Host1x::NvdecCommon::VideoCodec codec) {
|
||||
this->Reset();
|
||||
m_decoder.emplace(codec);
|
||||
m_decoder_context.emplace(*m_decoder);
|
||||
|
||||
// Enable GPU decoding if requested.
|
||||
if (Settings::values.nvdec_emulation.GetValue() == Settings::NvdecEmulation::Gpu) {
|
||||
m_hardware_context.emplace();
|
||||
m_hardware_context->InitializeForDecoder(*m_decoder_context, *m_decoder);
|
||||
}
|
||||
|
||||
// Open the decoder context.
|
||||
if (!m_decoder_context->OpenContext(*m_decoder)) {
|
||||
this->Reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DecodeApi::SendPacket(std::span<const u8> packet_data, size_t configuration_size) {
|
||||
FFmpeg::Packet packet(packet_data);
|
||||
return m_decoder_context->SendPacket(packet);
|
||||
}
|
||||
|
||||
void DecodeApi::ReceiveFrames(std::queue<std::unique_ptr<Frame>>& frame_queue) {
|
||||
// Receive raw frame from decoder.
|
||||
bool is_interlaced;
|
||||
auto frame = m_decoder_context->ReceiveFrame(&is_interlaced);
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_interlaced) {
|
||||
// If the frame is not interlaced, we can pend it now.
|
||||
frame_queue.push(std::move(frame));
|
||||
} else {
|
||||
// Create the deinterlacer if needed.
|
||||
if (!m_deinterlace_filter) {
|
||||
m_deinterlace_filter.emplace(*frame);
|
||||
}
|
||||
|
||||
// Add the frame we just received.
|
||||
if (!m_deinterlace_filter->AddSourceFrame(*frame)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Pend output fields.
|
||||
while (true) {
|
||||
auto filter_frame = m_deinterlace_filter->DrainSinkFrame();
|
||||
if (!filter_frame) {
|
||||
break;
|
||||
}
|
||||
|
||||
frame_queue.push(std::move(filter_frame));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace FFmpeg
|
||||
@@ -1,213 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/host1x/nvdec_common.h"
|
||||
|
||||
extern "C" {
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/opt.h>
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace FFmpeg {
|
||||
|
||||
class Packet;
|
||||
class Frame;
|
||||
class Decoder;
|
||||
class HardwareContext;
|
||||
class DecoderContext;
|
||||
class DeinterlaceFilter;
|
||||
|
||||
// Wraps an AVPacket, a container for compressed bitstream data.
|
||||
class Packet {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(Packet);
|
||||
YUZU_NON_MOVEABLE(Packet);
|
||||
|
||||
explicit Packet(std::span<const u8> data);
|
||||
~Packet();
|
||||
|
||||
AVPacket* GetPacket() const {
|
||||
return m_packet;
|
||||
}
|
||||
|
||||
private:
|
||||
AVPacket* m_packet{};
|
||||
};
|
||||
|
||||
// Wraps an AVFrame, a container for audio and video stream data.
|
||||
class Frame {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(Frame);
|
||||
YUZU_NON_MOVEABLE(Frame);
|
||||
|
||||
explicit Frame();
|
||||
~Frame();
|
||||
|
||||
int GetWidth() const {
|
||||
return m_frame->width;
|
||||
}
|
||||
|
||||
int GetHeight() const {
|
||||
return m_frame->height;
|
||||
}
|
||||
|
||||
AVPixelFormat GetPixelFormat() const {
|
||||
return static_cast<AVPixelFormat>(m_frame->format);
|
||||
}
|
||||
|
||||
int GetStride(int plane) const {
|
||||
return m_frame->linesize[plane];
|
||||
}
|
||||
|
||||
int* GetStrides() const {
|
||||
return m_frame->linesize;
|
||||
}
|
||||
|
||||
u8* GetData(int plane) const {
|
||||
return m_frame->data[plane];
|
||||
}
|
||||
|
||||
u8** GetPlanes() const {
|
||||
return m_frame->data;
|
||||
}
|
||||
|
||||
void SetFormat(int format) {
|
||||
m_frame->format = format;
|
||||
}
|
||||
|
||||
AVFrame* GetFrame() const {
|
||||
return m_frame;
|
||||
}
|
||||
|
||||
private:
|
||||
AVFrame* m_frame{};
|
||||
};
|
||||
|
||||
// Wraps an AVCodec, a type containing information about a codec.
|
||||
class Decoder {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(Decoder);
|
||||
YUZU_NON_MOVEABLE(Decoder);
|
||||
|
||||
explicit Decoder(Tegra::Host1x::NvdecCommon::VideoCodec codec);
|
||||
~Decoder() = default;
|
||||
|
||||
bool SupportsDecodingOnDevice(AVPixelFormat* out_pix_fmt, AVHWDeviceType type) const;
|
||||
|
||||
const AVCodec* GetCodec() const {
|
||||
return m_codec;
|
||||
}
|
||||
|
||||
private:
|
||||
const AVCodec* m_codec{};
|
||||
};
|
||||
|
||||
// Wraps AVBufferRef for an accelerated decoder.
|
||||
class HardwareContext {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(HardwareContext);
|
||||
YUZU_NON_MOVEABLE(HardwareContext);
|
||||
|
||||
static std::vector<AVHWDeviceType> GetSupportedDeviceTypes();
|
||||
|
||||
explicit HardwareContext() = default;
|
||||
~HardwareContext();
|
||||
|
||||
bool InitializeForDecoder(DecoderContext& decoder_context, const Decoder& decoder);
|
||||
|
||||
AVBufferRef* GetBufferRef() const {
|
||||
return m_gpu_decoder;
|
||||
}
|
||||
|
||||
private:
|
||||
bool InitializeWithType(AVHWDeviceType type);
|
||||
|
||||
AVBufferRef* m_gpu_decoder{};
|
||||
};
|
||||
|
||||
// Wraps an AVCodecContext.
|
||||
class DecoderContext {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(DecoderContext);
|
||||
YUZU_NON_MOVEABLE(DecoderContext);
|
||||
|
||||
explicit DecoderContext(const Decoder& decoder);
|
||||
~DecoderContext();
|
||||
|
||||
void InitializeHardwareDecoder(const HardwareContext& context, AVPixelFormat hw_pix_fmt);
|
||||
bool OpenContext(const Decoder& decoder);
|
||||
bool SendPacket(const Packet& packet);
|
||||
std::unique_ptr<Frame> ReceiveFrame(bool* out_is_interlaced);
|
||||
|
||||
AVCodecContext* GetCodecContext() const {
|
||||
return m_codec_context;
|
||||
}
|
||||
|
||||
private:
|
||||
AVCodecContext* m_codec_context{};
|
||||
};
|
||||
|
||||
// Wraps an AVFilterGraph.
|
||||
class DeinterlaceFilter {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(DeinterlaceFilter);
|
||||
YUZU_NON_MOVEABLE(DeinterlaceFilter);
|
||||
|
||||
explicit DeinterlaceFilter(const Frame& frame);
|
||||
~DeinterlaceFilter();
|
||||
|
||||
bool AddSourceFrame(const Frame& frame);
|
||||
std::unique_ptr<Frame> DrainSinkFrame();
|
||||
|
||||
private:
|
||||
AVFilterGraph* m_filter_graph{};
|
||||
AVFilterContext* m_source_context{};
|
||||
AVFilterContext* m_sink_context{};
|
||||
bool m_initialized{};
|
||||
};
|
||||
|
||||
class DecodeApi {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(DecodeApi);
|
||||
YUZU_NON_MOVEABLE(DecodeApi);
|
||||
|
||||
DecodeApi() = default;
|
||||
~DecodeApi() = default;
|
||||
|
||||
bool Initialize(Tegra::Host1x::NvdecCommon::VideoCodec codec);
|
||||
void Reset();
|
||||
|
||||
bool SendPacket(std::span<const u8> packet_data, size_t configuration_size);
|
||||
void ReceiveFrames(std::queue<std::unique_ptr<Frame>>& frame_queue);
|
||||
|
||||
private:
|
||||
std::optional<FFmpeg::Decoder> m_decoder;
|
||||
std::optional<FFmpeg::DecoderContext> m_decoder_context;
|
||||
std::optional<FFmpeg::HardwareContext> m_hardware_context;
|
||||
std::optional<FFmpeg::DeinterlaceFilter> m_deinterlace_filter;
|
||||
};
|
||||
|
||||
} // namespace FFmpeg
|
||||
@@ -28,7 +28,7 @@ void Nvdec::ProcessMethod(u32 method, u32 argument) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<FFmpeg::Frame> Nvdec::GetFrame() {
|
||||
AVFramePtr Nvdec::GetFrame() {
|
||||
return codec->GetCurrentFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
void ProcessMethod(u32 method, u32 argument);
|
||||
|
||||
/// Return most recently decoded frame
|
||||
[[nodiscard]] std::unique_ptr<FFmpeg::Frame> GetFrame();
|
||||
[[nodiscard]] AVFramePtr GetFrame();
|
||||
|
||||
private:
|
||||
/// Invoke codec to decode a frame
|
||||
|
||||
@@ -82,26 +82,27 @@ void Vic::Execute() {
|
||||
return;
|
||||
}
|
||||
const VicConfig config{host1x.MemoryManager().Read<u64>(config_struct_address + 0x20)};
|
||||
auto frame = nvdec_processor->GetFrame();
|
||||
const AVFramePtr frame_ptr = nvdec_processor->GetFrame();
|
||||
const auto* frame = frame_ptr.get();
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
const u64 surface_width = config.surface_width_minus1 + 1;
|
||||
const u64 surface_height = config.surface_height_minus1 + 1;
|
||||
if (static_cast<u64>(frame->GetWidth()) != surface_width ||
|
||||
static_cast<u64>(frame->GetHeight()) != surface_height) {
|
||||
if (static_cast<u64>(frame->width) != surface_width ||
|
||||
static_cast<u64>(frame->height) != surface_height) {
|
||||
// TODO: Properly support multiple video streams with differing frame dimensions
|
||||
LOG_WARNING(Service_NVDRV, "Frame dimensions {}x{} don't match surface dimensions {}x{}",
|
||||
frame->GetWidth(), frame->GetHeight(), surface_width, surface_height);
|
||||
frame->width, frame->height, surface_width, surface_height);
|
||||
}
|
||||
switch (config.pixel_format) {
|
||||
case VideoPixelFormat::RGBA8:
|
||||
case VideoPixelFormat::BGRA8:
|
||||
case VideoPixelFormat::RGBX8:
|
||||
WriteRGBFrame(std::move(frame), config);
|
||||
WriteRGBFrame(frame, config);
|
||||
break;
|
||||
case VideoPixelFormat::YUV420:
|
||||
WriteYUVFrame(std::move(frame), config);
|
||||
WriteYUVFrame(frame, config);
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unknown video pixel format {:X}", config.pixel_format.Value());
|
||||
@@ -109,14 +110,10 @@ void Vic::Execute() {
|
||||
}
|
||||
}
|
||||
|
||||
void Vic::WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config) {
|
||||
void Vic::WriteRGBFrame(const AVFrame* frame, const VicConfig& config) {
|
||||
LOG_TRACE(Service_NVDRV, "Writing RGB Frame");
|
||||
|
||||
const auto frame_width = frame->GetWidth();
|
||||
const auto frame_height = frame->GetHeight();
|
||||
const auto frame_format = frame->GetPixelFormat();
|
||||
|
||||
if (!scaler_ctx || frame_width != scaler_width || frame_height != scaler_height) {
|
||||
if (!scaler_ctx || frame->width != scaler_width || frame->height != scaler_height) {
|
||||
const AVPixelFormat target_format = [pixel_format = config.pixel_format]() {
|
||||
switch (pixel_format) {
|
||||
case VideoPixelFormat::RGBA8:
|
||||
@@ -132,26 +129,27 @@ void Vic::WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
|
||||
sws_freeContext(scaler_ctx);
|
||||
// Frames are decoded into either YUV420 or NV12 formats. Convert to desired RGB format
|
||||
scaler_ctx = sws_getContext(frame_width, frame_height, frame_format, frame_width,
|
||||
frame_height, target_format, 0, nullptr, nullptr, nullptr);
|
||||
scaler_width = frame_width;
|
||||
scaler_height = frame_height;
|
||||
scaler_ctx = sws_getContext(frame->width, frame->height,
|
||||
static_cast<AVPixelFormat>(frame->format), frame->width,
|
||||
frame->height, target_format, 0, nullptr, nullptr, nullptr);
|
||||
scaler_width = frame->width;
|
||||
scaler_height = frame->height;
|
||||
converted_frame_buffer.reset();
|
||||
}
|
||||
if (!converted_frame_buffer) {
|
||||
const size_t frame_size = frame_width * frame_height * 4;
|
||||
const size_t frame_size = frame->width * frame->height * 4;
|
||||
converted_frame_buffer = AVMallocPtr{static_cast<u8*>(av_malloc(frame_size)), av_free};
|
||||
}
|
||||
const std::array<int, 4> converted_stride{frame_width * 4, frame_height * 4, 0, 0};
|
||||
const std::array<int, 4> converted_stride{frame->width * 4, frame->height * 4, 0, 0};
|
||||
u8* const converted_frame_buf_addr{converted_frame_buffer.get()};
|
||||
sws_scale(scaler_ctx, frame->GetPlanes(), frame->GetStrides(), 0, frame_height,
|
||||
&converted_frame_buf_addr, converted_stride.data());
|
||||
sws_scale(scaler_ctx, frame->data, frame->linesize, 0, frame->height, &converted_frame_buf_addr,
|
||||
converted_stride.data());
|
||||
|
||||
// Use the minimum of surface/frame dimensions to avoid buffer overflow.
|
||||
const u32 surface_width = static_cast<u32>(config.surface_width_minus1) + 1;
|
||||
const u32 surface_height = static_cast<u32>(config.surface_height_minus1) + 1;
|
||||
const u32 width = std::min(surface_width, static_cast<u32>(frame_width));
|
||||
const u32 height = std::min(surface_height, static_cast<u32>(frame_height));
|
||||
const u32 width = std::min(surface_width, static_cast<u32>(frame->width));
|
||||
const u32 height = std::min(surface_height, static_cast<u32>(frame->height));
|
||||
const u32 blk_kind = static_cast<u32>(config.block_linear_kind);
|
||||
if (blk_kind != 0) {
|
||||
// swizzle pitch linear to block linear
|
||||
@@ -171,23 +169,23 @@ void Vic::WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
}
|
||||
}
|
||||
|
||||
void Vic::WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config) {
|
||||
void Vic::WriteYUVFrame(const AVFrame* frame, const VicConfig& config) {
|
||||
LOG_TRACE(Service_NVDRV, "Writing YUV420 Frame");
|
||||
|
||||
const std::size_t surface_width = config.surface_width_minus1 + 1;
|
||||
const std::size_t surface_height = config.surface_height_minus1 + 1;
|
||||
const std::size_t aligned_width = (surface_width + 0xff) & ~0xffUL;
|
||||
// Use the minimum of surface/frame dimensions to avoid buffer overflow.
|
||||
const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->GetWidth()));
|
||||
const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->GetHeight()));
|
||||
const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width));
|
||||
const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height));
|
||||
|
||||
const auto stride = static_cast<size_t>(frame->GetStride(0));
|
||||
const auto stride = static_cast<size_t>(frame->linesize[0]);
|
||||
|
||||
luma_buffer.resize_destructive(aligned_width * surface_height);
|
||||
chroma_buffer.resize_destructive(aligned_width * surface_height / 2);
|
||||
|
||||
// Populate luma buffer
|
||||
const u8* luma_src = frame->GetData(0);
|
||||
const u8* luma_src = frame->data[0];
|
||||
for (std::size_t y = 0; y < frame_height; ++y) {
|
||||
const std::size_t src = y * stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
@@ -198,16 +196,16 @@ void Vic::WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
|
||||
// Chroma
|
||||
const std::size_t half_height = frame_height / 2;
|
||||
const auto half_stride = static_cast<size_t>(frame->GetStride(1));
|
||||
const auto half_stride = static_cast<size_t>(frame->linesize[1]);
|
||||
|
||||
switch (frame->GetPixelFormat()) {
|
||||
switch (frame->format) {
|
||||
case AV_PIX_FMT_YUV420P: {
|
||||
// Frame from FFmpeg software
|
||||
// Populate chroma buffer from both channels with interleaving.
|
||||
const std::size_t half_width = frame_width / 2;
|
||||
u8* chroma_buffer_data = chroma_buffer.data();
|
||||
const u8* chroma_b_src = frame->GetData(1);
|
||||
const u8* chroma_r_src = frame->GetData(2);
|
||||
const u8* chroma_b_src = frame->data[1];
|
||||
const u8* chroma_r_src = frame->data[2];
|
||||
for (std::size_t y = 0; y < half_height; ++y) {
|
||||
const std::size_t src = y * half_stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
@@ -221,7 +219,7 @@ void Vic::WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& c
|
||||
case AV_PIX_FMT_NV12: {
|
||||
// Frame from VA-API hardware
|
||||
// This is already interleaved so just copy
|
||||
const u8* chroma_src = frame->GetData(1);
|
||||
const u8* chroma_src = frame->data[1];
|
||||
for (std::size_t y = 0; y < half_height; ++y) {
|
||||
const std::size_t src = y * stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
|
||||
@@ -39,9 +39,9 @@ public:
|
||||
private:
|
||||
void Execute();
|
||||
|
||||
void WriteRGBFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config);
|
||||
void WriteRGBFrame(const AVFrame* frame, const VicConfig& config);
|
||||
|
||||
void WriteYUVFrame(std::unique_ptr<FFmpeg::Frame> frame, const VicConfig& config);
|
||||
void WriteYUVFrame(const AVFrame* frame, const VicConfig& config);
|
||||
|
||||
Host1x& host1x;
|
||||
std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor;
|
||||
|
||||
@@ -266,7 +266,7 @@ void QueryCacheBase<Traits>::CounterReport(GPUVAddr addr, QueryType counter_type
|
||||
return;
|
||||
}
|
||||
if (False(query_base->flags & QueryFlagBits::IsFinalValueSynced)) [[unlikely]] {
|
||||
ASSERT(false);
|
||||
UNREACHABLE();
|
||||
return;
|
||||
}
|
||||
query_base->value += streamer->GetAmmendValue();
|
||||
|
||||
@@ -1785,22 +1785,8 @@ ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo& info,
|
||||
: VideoCommon::ImageViewBase{info, view_info, gpu_addr_},
|
||||
buffer_size{VideoCommon::CalculateGuestSizeInBytes(info)} {}
|
||||
|
||||
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::NullImageViewParams& params)
|
||||
: VideoCommon::ImageViewBase{params}, device{&runtime.device} {
|
||||
if (device->HasNullDescriptor()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle fallback for devices without nullDescriptor
|
||||
ImageInfo info{};
|
||||
info.format = PixelFormat::A8B8G8R8_UNORM;
|
||||
|
||||
null_image = MakeImage(*device, runtime.memory_allocator, info, {});
|
||||
image_handle = *null_image;
|
||||
for (u32 i = 0; i < Shader::NUM_TEXTURE_TYPES; i++) {
|
||||
image_views[i] = MakeView(VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
}
|
||||
}
|
||||
ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::NullImageViewParams& params)
|
||||
: VideoCommon::ImageViewBase{params} {}
|
||||
|
||||
ImageView::~ImageView() = default;
|
||||
|
||||
|
||||
@@ -267,7 +267,6 @@ private:
|
||||
vk::ImageView depth_view;
|
||||
vk::ImageView stencil_view;
|
||||
vk::ImageView color_view;
|
||||
vk::Image null_image;
|
||||
VkImage image_handle = VK_NULL_HANDLE;
|
||||
VkImageView render_target = VK_NULL_HANDLE;
|
||||
VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
|
||||
@@ -252,7 +252,6 @@ file(GLOB_RECURSE THEMES ${PROJECT_SOURCE_DIR}/dist/qt_themes/*)
|
||||
if (ENABLE_QT_TRANSLATION)
|
||||
set(YUZU_QT_LANGUAGES "${PROJECT_SOURCE_DIR}/dist/languages" CACHE PATH "Path to the translation bundle for the Qt frontend")
|
||||
option(GENERATE_QT_TRANSLATION "Generate en.ts as the translation source file" OFF)
|
||||
option(WORKAROUND_BROKEN_LUPDATE "Run lupdate directly through CMake if Qt's convenience wrappers don't work" OFF)
|
||||
|
||||
# Update source TS file if enabled
|
||||
if (GENERATE_QT_TRANSLATION)
|
||||
@@ -260,51 +259,19 @@ if (ENABLE_QT_TRANSLATION)
|
||||
# these calls to qt_create_translation also creates a rule to generate en.qm which conflicts with providing english plurals
|
||||
# so we have to set a OUTPUT_LOCATION so that we don't have multiple rules to generate en.qm
|
||||
set_source_files_properties(${YUZU_QT_LANGUAGES}/en.ts PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
|
||||
if (WORKAROUND_BROKEN_LUPDATE)
|
||||
add_custom_command(OUTPUT ${YUZU_QT_LANGUAGES}/en.ts
|
||||
COMMAND lupdate
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
${SRCS}
|
||||
${UIS}
|
||||
-ts ${YUZU_QT_LANGUAGES}/en.ts
|
||||
DEPENDS
|
||||
${SRCS}
|
||||
${UIS}
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
else()
|
||||
qt_create_translation(QM_FILES
|
||||
${SRCS}
|
||||
${UIS}
|
||||
${YUZU_QT_LANGUAGES}/en.ts
|
||||
OPTIONS
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
)
|
||||
endif()
|
||||
qt_create_translation(QM_FILES
|
||||
${SRCS}
|
||||
${UIS}
|
||||
${YUZU_QT_LANGUAGES}/en.ts
|
||||
OPTIONS
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
)
|
||||
|
||||
# Generate plurals into dist/english_plurals/generated_en.ts so it can be used to revise dist/english_plurals/en.ts
|
||||
set(GENERATED_PLURALS_FILE ${PROJECT_SOURCE_DIR}/dist/english_plurals/generated_en.ts)
|
||||
set_source_files_properties(${GENERATED_PLURALS_FILE} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/plurals")
|
||||
if (WORKAROUND_BROKEN_LUPDATE)
|
||||
add_custom_command(OUTPUT ${GENERATED_PLURALS_FILE}
|
||||
COMMAND lupdate
|
||||
-source-language en_US
|
||||
-target-language en_US
|
||||
${SRCS}
|
||||
${UIS}
|
||||
-ts ${GENERATED_PLURALS_FILE}
|
||||
DEPENDS
|
||||
${SRCS}
|
||||
${UIS}
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
else()
|
||||
qt_create_translation(QM_FILES ${SRCS} ${UIS} ${GENERATED_PLURALS_FILE} OPTIONS -pluralonly -source-language en_US -target-language en_US)
|
||||
endif()
|
||||
qt_create_translation(QM_FILES ${SRCS} ${UIS} ${GENERATED_PLURALS_FILE} OPTIONS -pluralonly -source-language en_US -target-language en_US)
|
||||
|
||||
add_custom_target(translation ALL DEPENDS ${YUZU_QT_LANGUAGES}/en.ts ${GENERATED_PLURALS_FILE})
|
||||
endif()
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/time_zone.h"
|
||||
#include "yuzu/configuration/shared_translation.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <QCoreApplication>
|
||||
#include <QWidget>
|
||||
#include "common/settings.h"
|
||||
#include "common/settings_enums.h"
|
||||
#include "common/settings_setting.h"
|
||||
#include "common/time_zone.h"
|
||||
#include "yuzu/uisettings.h"
|
||||
|
||||
namespace ConfigurationShared {
|
||||
@@ -22,135 +21,123 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
const auto& tr = [parent](const char* text) -> QString { return parent->tr(text); };
|
||||
|
||||
#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \
|
||||
translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{(NAME), (TOOLTIP)}})
|
||||
translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{tr((NAME)), tr((TOOLTIP))}})
|
||||
|
||||
// A setting can be ignored by giving it a blank name
|
||||
|
||||
// Audio
|
||||
INSERT(Settings, sink_id, tr("Output Engine:"), QStringLiteral());
|
||||
INSERT(Settings, audio_output_device_id, tr("Output Device:"), QStringLiteral());
|
||||
INSERT(Settings, audio_input_device_id, tr("Input Device:"), QStringLiteral());
|
||||
INSERT(Settings, audio_muted, tr("Mute audio"), QStringLiteral());
|
||||
INSERT(Settings, volume, tr("Volume:"), QStringLiteral());
|
||||
INSERT(Settings, dump_audio_commands, QStringLiteral(), QStringLiteral());
|
||||
INSERT(UISettings, mute_when_in_background, tr("Mute audio when in background"),
|
||||
QStringLiteral());
|
||||
INSERT(Settings, sink_id, "Output Engine:", "");
|
||||
INSERT(Settings, audio_output_device_id, "Output Device:", "");
|
||||
INSERT(Settings, audio_input_device_id, "Input Device:", "");
|
||||
INSERT(Settings, audio_muted, "Mute audio", "");
|
||||
INSERT(Settings, volume, "Volume:", "");
|
||||
INSERT(Settings, dump_audio_commands, "", "");
|
||||
INSERT(UISettings, mute_when_in_background, "Mute audio when in background", "");
|
||||
|
||||
// Core
|
||||
INSERT(Settings, use_multi_core, tr("Multicore CPU Emulation"), QStringLiteral());
|
||||
INSERT(Settings, memory_layout_mode, tr("Memory Layout"), QStringLiteral());
|
||||
INSERT(Settings, use_speed_limit, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, speed_limit, tr("Limit Speed Percent"), QStringLiteral());
|
||||
INSERT(Settings, use_multi_core, "Multicore CPU Emulation", "");
|
||||
INSERT(Settings, memory_layout_mode, "Memory Layout", "");
|
||||
INSERT(Settings, use_speed_limit, "", "");
|
||||
INSERT(Settings, speed_limit, "Limit Speed Percent", "");
|
||||
|
||||
// Cpu
|
||||
INSERT(Settings, cpu_accuracy, tr("Accuracy:"), QStringLiteral());
|
||||
INSERT(Settings, cpu_accuracy, "Accuracy:", "");
|
||||
|
||||
// Cpu Debug
|
||||
|
||||
// Cpu Unsafe
|
||||
INSERT(Settings, cpuopt_unsafe_unfuse_fma,
|
||||
"Unfuse FMA (improve performance on CPUs without FMA)",
|
||||
"This option improves speed by reducing accuracy of fused-multiply-add instructions on "
|
||||
"CPUs without native FMA support.");
|
||||
INSERT(Settings, cpuopt_unsafe_reduce_fp_error, "Faster FRSQRTE and FRECPE",
|
||||
"This option improves the speed of some approximate floating-point functions by using "
|
||||
"less accurate native approximations.");
|
||||
INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr, "Faster ASIMD instructions (32 bits only)",
|
||||
"This option improves the speed of 32 bits ASIMD floating-point functions by running "
|
||||
"with incorrect rounding modes.");
|
||||
INSERT(Settings, cpuopt_unsafe_inaccurate_nan, "Inaccurate NaN handling",
|
||||
"This option improves speed by removing NaN checking. Please note this also reduces "
|
||||
"accuracy of certain floating-point instructions.");
|
||||
INSERT(
|
||||
Settings, cpuopt_unsafe_unfuse_fma,
|
||||
tr("Unfuse FMA (improve performance on CPUs without FMA)"),
|
||||
tr("This option improves speed by reducing accuracy of fused-multiply-add instructions on "
|
||||
"CPUs without native FMA support."));
|
||||
INSERT(
|
||||
Settings, cpuopt_unsafe_reduce_fp_error, tr("Faster FRSQRTE and FRECPE"),
|
||||
tr("This option improves the speed of some approximate floating-point functions by using "
|
||||
"less accurate native approximations."));
|
||||
INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr,
|
||||
tr("Faster ASIMD instructions (32 bits only)"),
|
||||
tr("This option improves the speed of 32 bits ASIMD floating-point functions by running "
|
||||
"with incorrect rounding modes."));
|
||||
INSERT(Settings, cpuopt_unsafe_inaccurate_nan, tr("Inaccurate NaN handling"),
|
||||
tr("This option improves speed by removing NaN checking. Please note this also reduces "
|
||||
"accuracy of certain floating-point instructions."));
|
||||
INSERT(Settings, cpuopt_unsafe_fastmem_check, tr("Disable address space checks"),
|
||||
tr("This option improves speed by eliminating a safety check before every memory "
|
||||
"read/write "
|
||||
"in guest. Disabling it may allow a game to read/write the emulator's memory."));
|
||||
INSERT(
|
||||
Settings, cpuopt_unsafe_ignore_global_monitor, tr("Ignore global monitor"),
|
||||
tr("This option improves speed by relying only on the semantics of cmpxchg to ensure "
|
||||
Settings, cpuopt_unsafe_fastmem_check, "Disable address space checks",
|
||||
"This option improves speed by eliminating a safety check before every memory read/write "
|
||||
"in guest. Disabling it may allow a game to read/write the emulator's memory.");
|
||||
INSERT(Settings, cpuopt_unsafe_ignore_global_monitor, "Ignore global monitor",
|
||||
"This option improves speed by relying only on the semantics of cmpxchg to ensure "
|
||||
"safety of exclusive access instructions. Please note this may result in deadlocks and "
|
||||
"other race conditions."));
|
||||
"other race conditions.");
|
||||
|
||||
// Renderer
|
||||
INSERT(Settings, renderer_backend, tr("API:"), QStringLiteral());
|
||||
INSERT(Settings, vulkan_device, tr("Device:"), QStringLiteral());
|
||||
INSERT(Settings, shader_backend, tr("Shader Backend:"), QStringLiteral());
|
||||
INSERT(Settings, resolution_setup, tr("Resolution:"), QStringLiteral());
|
||||
INSERT(Settings, scaling_filter, tr("Window Adapting Filter:"), QStringLiteral());
|
||||
INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"), QStringLiteral());
|
||||
INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"), QStringLiteral());
|
||||
INSERT(Settings, fullscreen_mode, tr("Fullscreen Mode:"), QStringLiteral());
|
||||
INSERT(Settings, aspect_ratio, tr("Aspect Ratio:"), QStringLiteral());
|
||||
INSERT(Settings, use_disk_shader_cache, tr("Use disk pipeline cache"), QStringLiteral());
|
||||
INSERT(Settings, use_asynchronous_gpu_emulation, tr("Use asynchronous GPU emulation"),
|
||||
QStringLiteral());
|
||||
INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"), QStringLiteral());
|
||||
INSERT(Settings, accelerate_astc, tr("ASTC Decoding Method:"), QStringLiteral());
|
||||
INSERT(Settings, astc_recompression, tr("ASTC Recompression Method:"), QStringLiteral());
|
||||
INSERT(
|
||||
Settings, vsync_mode, tr("VSync Mode:"),
|
||||
tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen "
|
||||
INSERT(Settings, renderer_backend, "API:", "");
|
||||
INSERT(Settings, vulkan_device, "Device:", "");
|
||||
INSERT(Settings, shader_backend, "Shader Backend:", "");
|
||||
INSERT(Settings, resolution_setup, "Resolution:", "");
|
||||
INSERT(Settings, scaling_filter, "Window Adapting Filter:", "");
|
||||
INSERT(Settings, fsr_sharpening_slider, "FSR Sharpness:", "");
|
||||
INSERT(Settings, anti_aliasing, "Anti-Aliasing Method:", "");
|
||||
INSERT(Settings, fullscreen_mode, "Fullscreen Mode:", "");
|
||||
INSERT(Settings, aspect_ratio, "Aspect Ratio:", "");
|
||||
INSERT(Settings, use_disk_shader_cache, "Use disk pipeline cache", "");
|
||||
INSERT(Settings, use_asynchronous_gpu_emulation, "Use asynchronous GPU emulation", "");
|
||||
INSERT(Settings, nvdec_emulation, "NVDEC emulation:", "");
|
||||
INSERT(Settings, accelerate_astc, "ASTC Decoding Method:", "");
|
||||
INSERT(Settings, astc_recompression, "ASTC Recompression Method:", "");
|
||||
INSERT(Settings, vsync_mode, "VSync Mode:",
|
||||
"FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen "
|
||||
"refresh rate.\nFIFO Relaxed is similar to FIFO but allows tearing as it recovers from "
|
||||
"a slow down.\nMailbox can have lower latency than FIFO and does not tear but may drop "
|
||||
"frames.\nImmediate (no synchronization) just presents whatever is available and can "
|
||||
"exhibit tearing."));
|
||||
INSERT(Settings, bg_red, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, bg_green, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, bg_blue, QStringLiteral(), QStringLiteral());
|
||||
"exhibit tearing.");
|
||||
INSERT(Settings, bg_red, "", "");
|
||||
INSERT(Settings, bg_green, "", "");
|
||||
INSERT(Settings, bg_blue, "", "");
|
||||
|
||||
// Renderer (Advanced Graphics)
|
||||
INSERT(Settings, async_presentation, tr("Enable asynchronous presentation (Vulkan only)"),
|
||||
QStringLiteral());
|
||||
INSERT(
|
||||
Settings, renderer_force_max_clock, tr("Force maximum clocks (Vulkan only)"),
|
||||
tr("Runs work in the background while waiting for graphics commands to keep the GPU from "
|
||||
"lowering its clock speed."));
|
||||
INSERT(Settings, max_anisotropy, tr("Anisotropic Filtering:"), QStringLiteral());
|
||||
INSERT(Settings, gpu_accuracy, tr("Accuracy Level:"), QStringLiteral());
|
||||
INSERT(
|
||||
Settings, use_asynchronous_shaders, tr("Use asynchronous shader building (Hack)"),
|
||||
tr("Enables asynchronous shader compilation, which may reduce shader stutter. This feature "
|
||||
"is experimental."));
|
||||
INSERT(Settings, use_fast_gpu_time, tr("Use Fast GPU Time (Hack)"),
|
||||
tr("Enables Fast GPU Time. This option will force most games to run at their highest "
|
||||
"native resolution."));
|
||||
INSERT(Settings, use_vulkan_driver_pipeline_cache, tr("Use Vulkan pipeline cache"),
|
||||
tr("Enables GPU vendor-specific pipeline cache. This option can improve shader loading "
|
||||
"time significantly in cases where the Vulkan driver does not store pipeline cache "
|
||||
"files internally."));
|
||||
INSERT(
|
||||
Settings, enable_compute_pipelines, tr("Enable Compute Pipelines (Intel Vulkan Only)"),
|
||||
tr("Enable compute pipelines, required by some games.\nThis setting only exists for Intel "
|
||||
INSERT(Settings, async_presentation, "Enable asynchronous presentation (Vulkan only)", "");
|
||||
INSERT(Settings, renderer_force_max_clock, "Force maximum clocks (Vulkan only)",
|
||||
"Runs work in the background while waiting for graphics commands to keep the GPU from "
|
||||
"lowering its clock speed.");
|
||||
INSERT(Settings, max_anisotropy, "Anisotropic Filtering:", "");
|
||||
INSERT(Settings, gpu_accuracy, "Accuracy Level:", "");
|
||||
INSERT(Settings, use_asynchronous_shaders, "Use asynchronous shader building (Hack)",
|
||||
"Enables asynchronous shader compilation, which may reduce shader stutter. This feature "
|
||||
"is experimental.");
|
||||
INSERT(Settings, use_fast_gpu_time, "Use Fast GPU Time (Hack)",
|
||||
"Enables Fast GPU Time. This option will force most games to run at their highest "
|
||||
"native resolution.");
|
||||
INSERT(Settings, use_vulkan_driver_pipeline_cache, "Use Vulkan pipeline cache",
|
||||
"Enables GPU vendor-specific pipeline cache. This option can improve shader loading "
|
||||
"time significantly in cases where the Vulkan driver does not store pipeline cache "
|
||||
"files internally.");
|
||||
INSERT(Settings, enable_compute_pipelines, "Enable Compute Pipelines (Intel Vulkan Only)",
|
||||
"Enable compute pipelines, required by some games.\nThis setting only exists for Intel "
|
||||
"proprietary drivers, and may crash if enabled.\nCompute pipelines are always enabled "
|
||||
"on all other drivers."));
|
||||
INSERT(
|
||||
Settings, use_reactive_flushing, tr("Enable Reactive Flushing"),
|
||||
tr("Uses reactive flushing instead of predictive flushing, allowing more accurate memory "
|
||||
"syncing."));
|
||||
INSERT(Settings, use_video_framerate, tr("Sync to framerate of video playback"),
|
||||
tr("Run the game at normal speed during video playback, even when the framerate is "
|
||||
"unlocked."));
|
||||
INSERT(Settings, barrier_feedback_loops, tr("Barrier feedback loops"),
|
||||
tr("Improves rendering of transparency effects in specific games."));
|
||||
"on all other drivers.");
|
||||
INSERT(Settings, use_reactive_flushing, "Enable Reactive Flushing",
|
||||
"Uses reactive flushing instead of predictive flushing, allowing more accurate memory "
|
||||
"syncing.");
|
||||
INSERT(Settings, use_video_framerate, "Sync to framerate of video playback",
|
||||
"Run the game at normal speed during video playback, even when the framerate is "
|
||||
"unlocked.");
|
||||
INSERT(Settings, barrier_feedback_loops, "Barrier feedback loops",
|
||||
"Improves rendering of transparency effects in specific games.");
|
||||
|
||||
// Renderer (Debug)
|
||||
|
||||
// System
|
||||
INSERT(Settings, rng_seed, tr("RNG Seed"), QStringLiteral());
|
||||
INSERT(Settings, rng_seed_enabled, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, device_name, tr("Device Name"), QStringLiteral());
|
||||
INSERT(Settings, custom_rtc, tr("Custom RTC"), QStringLiteral());
|
||||
INSERT(Settings, custom_rtc_enabled, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, language_index, tr("Language:"),
|
||||
tr("Note: this can be overridden when region setting is auto-select"));
|
||||
INSERT(Settings, region_index, tr("Region:"), QStringLiteral());
|
||||
INSERT(Settings, time_zone_index, tr("Time Zone:"), QStringLiteral());
|
||||
INSERT(Settings, sound_index, tr("Sound Output Mode:"), QStringLiteral());
|
||||
INSERT(Settings, use_docked_mode, tr("Console Mode:"), QStringLiteral());
|
||||
INSERT(Settings, current_user, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, rng_seed, "RNG Seed", "");
|
||||
INSERT(Settings, rng_seed_enabled, "", "");
|
||||
INSERT(Settings, device_name, "Device Name", "");
|
||||
INSERT(Settings, custom_rtc, "Custom RTC", "");
|
||||
INSERT(Settings, custom_rtc_enabled, "", "");
|
||||
INSERT(Settings, language_index,
|
||||
"Language:", "Note: this can be overridden when region setting is auto-select");
|
||||
INSERT(Settings, region_index, "Region:", "");
|
||||
INSERT(Settings, time_zone_index, "Time Zone:", "");
|
||||
INSERT(Settings, sound_index, "Sound Output Mode:", "");
|
||||
INSERT(Settings, use_docked_mode, "Console Mode:", "");
|
||||
INSERT(Settings, current_user, "", "");
|
||||
|
||||
// Controls
|
||||
|
||||
@@ -167,14 +154,11 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
// Ui
|
||||
|
||||
// Ui General
|
||||
INSERT(UISettings, select_user_on_boot, tr("Prompt for user on game boot"), QStringLiteral());
|
||||
INSERT(UISettings, pause_when_in_background, tr("Pause emulation when in background"),
|
||||
QStringLiteral());
|
||||
INSERT(UISettings, confirm_before_stopping, tr("Confirm before stopping emulation"),
|
||||
QStringLiteral());
|
||||
INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), QStringLiteral());
|
||||
INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"),
|
||||
QStringLiteral());
|
||||
INSERT(UISettings, select_user_on_boot, "Prompt for user on game boot", "");
|
||||
INSERT(UISettings, pause_when_in_background, "Pause emulation when in background", "");
|
||||
INSERT(UISettings, confirm_before_stopping, "Confirm before stopping emulation", "");
|
||||
INSERT(UISettings, hide_mouse, "Hide mouse on inactivity", "");
|
||||
INSERT(UISettings, controller_applet_disabled, "Disable controller applet", "");
|
||||
|
||||
// Ui Debugging
|
||||
|
||||
@@ -194,141 +178,140 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
|
||||
return parent->tr(text, context);
|
||||
};
|
||||
|
||||
#define PAIR(ENUM, VALUE, TRANSLATION) {static_cast<u32>(Settings::ENUM::VALUE), (TRANSLATION)}
|
||||
#define PAIR(ENUM, VALUE, TRANSLATION) \
|
||||
{ static_cast<u32>(Settings::ENUM::VALUE), tr(TRANSLATION) }
|
||||
#define CTX_PAIR(ENUM, VALUE, TRANSLATION, CONTEXT) \
|
||||
{ static_cast<u32>(Settings::ENUM::VALUE), tr(TRANSLATION, CONTEXT) }
|
||||
|
||||
// Intentionally skipping VSyncMode to let the UI fill that one out
|
||||
|
||||
translations->insert({Settings::EnumMetadata<Settings::AstcDecodeMode>::Index(),
|
||||
{
|
||||
PAIR(AstcDecodeMode, Cpu, tr("CPU")),
|
||||
PAIR(AstcDecodeMode, Gpu, tr("GPU")),
|
||||
PAIR(AstcDecodeMode, CpuAsynchronous, tr("CPU Asynchronous")),
|
||||
PAIR(AstcDecodeMode, Cpu, "CPU"),
|
||||
PAIR(AstcDecodeMode, Gpu, "GPU"),
|
||||
PAIR(AstcDecodeMode, CpuAsynchronous, "CPU Asynchronous"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AstcRecompression>::Index(),
|
||||
{
|
||||
PAIR(AstcRecompression, Uncompressed, "Uncompressed (Best quality)"),
|
||||
PAIR(AstcRecompression, Bc1, "BC1 (Low quality)"),
|
||||
PAIR(AstcRecompression, Bc3, "BC3 (Medium quality)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::AstcRecompression>::Index(),
|
||||
{
|
||||
PAIR(AstcRecompression, Uncompressed, tr("Uncompressed (Best quality)")),
|
||||
PAIR(AstcRecompression, Bc1, tr("BC1 (Low quality)")),
|
||||
PAIR(AstcRecompression, Bc3, tr("BC3 (Medium quality)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::RendererBackend>::Index(),
|
||||
{
|
||||
#ifdef HAS_OPENGL
|
||||
PAIR(RendererBackend, OpenGL, tr("OpenGL")),
|
||||
PAIR(RendererBackend, OpenGL, "OpenGL"),
|
||||
#endif
|
||||
PAIR(RendererBackend, Vulkan, tr("Vulkan")),
|
||||
PAIR(RendererBackend, Null, tr("Null")),
|
||||
PAIR(RendererBackend, Vulkan, "Vulkan"),
|
||||
PAIR(RendererBackend, Null, "Null"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
|
||||
{
|
||||
PAIR(ShaderBackend, Glsl, "GLSL"),
|
||||
PAIR(ShaderBackend, Glasm, "GLASM (Assembly Shaders, NVIDIA Only)"),
|
||||
PAIR(ShaderBackend, SpirV, "SPIR-V (Experimental, Mesa Only)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
|
||||
{
|
||||
PAIR(ShaderBackend, Glsl, tr("GLSL")),
|
||||
PAIR(ShaderBackend, Glasm, tr("GLASM (Assembly Shaders, NVIDIA Only)")),
|
||||
PAIR(ShaderBackend, SpirV, tr("SPIR-V (Experimental, Mesa Only)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::GpuAccuracy>::Index(),
|
||||
{
|
||||
PAIR(GpuAccuracy, Normal, tr("Normal")),
|
||||
PAIR(GpuAccuracy, High, tr("High")),
|
||||
PAIR(GpuAccuracy, Extreme, tr("Extreme")),
|
||||
PAIR(GpuAccuracy, Normal, "Normal"),
|
||||
PAIR(GpuAccuracy, High, "High"),
|
||||
PAIR(GpuAccuracy, Extreme, "Extreme"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
|
||||
{
|
||||
PAIR(CpuAccuracy, Auto, "Auto"),
|
||||
PAIR(CpuAccuracy, Accurate, "Accurate"),
|
||||
PAIR(CpuAccuracy, Unsafe, "Unsafe"),
|
||||
PAIR(CpuAccuracy, Paranoid, "Paranoid (disables most optimizations)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
|
||||
{
|
||||
PAIR(CpuAccuracy, Auto, tr("Auto")),
|
||||
PAIR(CpuAccuracy, Accurate, tr("Accurate")),
|
||||
PAIR(CpuAccuracy, Unsafe, tr("Unsafe")),
|
||||
PAIR(CpuAccuracy, Paranoid, tr("Paranoid (disables most optimizations)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::FullscreenMode>::Index(),
|
||||
{
|
||||
PAIR(FullscreenMode, Borderless, tr("Borderless Windowed")),
|
||||
PAIR(FullscreenMode, Exclusive, tr("Exclusive Fullscreen")),
|
||||
PAIR(FullscreenMode, Borderless, "Borderless Windowed"),
|
||||
PAIR(FullscreenMode, Exclusive, "Exclusive Fullscreen"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::NvdecEmulation>::Index(),
|
||||
{
|
||||
PAIR(NvdecEmulation, Off, tr("No Video Output")),
|
||||
PAIR(NvdecEmulation, Cpu, tr("CPU Video Decoding")),
|
||||
PAIR(NvdecEmulation, Gpu, tr("GPU Video Decoding (Default)")),
|
||||
PAIR(NvdecEmulation, Off, "No Video Output"),
|
||||
PAIR(NvdecEmulation, Cpu, "CPU Video Decoding"),
|
||||
PAIR(NvdecEmulation, Gpu, "GPU Video Decoding (Default)"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ResolutionSetup>::Index(),
|
||||
{
|
||||
PAIR(ResolutionSetup, Res1_2X, "0.5X (360p/540p) [EXPERIMENTAL]"),
|
||||
PAIR(ResolutionSetup, Res3_4X, "0.75X (540p/810p) [EXPERIMENTAL]"),
|
||||
PAIR(ResolutionSetup, Res1X, "1X (720p/1080p)"),
|
||||
PAIR(ResolutionSetup, Res3_2X, "1.5X (1080p/1620p) [EXPERIMENTAL]"),
|
||||
PAIR(ResolutionSetup, Res2X, "2X (1440p/2160p)"),
|
||||
PAIR(ResolutionSetup, Res3X, "3X (2160p/3240p)"),
|
||||
PAIR(ResolutionSetup, Res4X, "4X (2880p/4320p)"),
|
||||
PAIR(ResolutionSetup, Res5X, "5X (3600p/5400p)"),
|
||||
PAIR(ResolutionSetup, Res6X, "6X (4320p/6480p)"),
|
||||
PAIR(ResolutionSetup, Res7X, "7X (5040p/7560p)"),
|
||||
PAIR(ResolutionSetup, Res8X, "8X (5760p/8640p)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ResolutionSetup>::Index(),
|
||||
{
|
||||
PAIR(ResolutionSetup, Res1_2X, tr("0.5X (360p/540p) [EXPERIMENTAL]")),
|
||||
PAIR(ResolutionSetup, Res3_4X, tr("0.75X (540p/810p) [EXPERIMENTAL]")),
|
||||
PAIR(ResolutionSetup, Res1X, tr("1X (720p/1080p)")),
|
||||
PAIR(ResolutionSetup, Res3_2X, tr("1.5X (1080p/1620p) [EXPERIMENTAL]")),
|
||||
PAIR(ResolutionSetup, Res2X, tr("2X (1440p/2160p)")),
|
||||
PAIR(ResolutionSetup, Res3X, tr("3X (2160p/3240p)")),
|
||||
PAIR(ResolutionSetup, Res4X, tr("4X (2880p/4320p)")),
|
||||
PAIR(ResolutionSetup, Res5X, tr("5X (3600p/5400p)")),
|
||||
PAIR(ResolutionSetup, Res6X, tr("6X (4320p/6480p)")),
|
||||
PAIR(ResolutionSetup, Res7X, tr("7X (5040p/7560p)")),
|
||||
PAIR(ResolutionSetup, Res8X, tr("8X (5760p/8640p)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ScalingFilter>::Index(),
|
||||
{
|
||||
PAIR(ScalingFilter, NearestNeighbor, tr("Nearest Neighbor")),
|
||||
PAIR(ScalingFilter, Bilinear, tr("Bilinear")),
|
||||
PAIR(ScalingFilter, Bicubic, tr("Bicubic")),
|
||||
PAIR(ScalingFilter, Gaussian, tr("Gaussian")),
|
||||
PAIR(ScalingFilter, ScaleForce, tr("ScaleForce")),
|
||||
PAIR(ScalingFilter, Fsr, tr("AMD FidelityFX™️ Super Resolution")),
|
||||
PAIR(ScalingFilter, NearestNeighbor, "Nearest Neighbor"),
|
||||
PAIR(ScalingFilter, Bilinear, "Bilinear"),
|
||||
PAIR(ScalingFilter, Bicubic, "Bicubic"),
|
||||
PAIR(ScalingFilter, Gaussian, "Gaussian"),
|
||||
PAIR(ScalingFilter, ScaleForce, "ScaleForce"),
|
||||
PAIR(ScalingFilter, Fsr, "AMD FidelityFX™️ Super Resolution"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AntiAliasing>::Index(),
|
||||
{
|
||||
PAIR(AntiAliasing, None, tr("None")),
|
||||
PAIR(AntiAliasing, Fxaa, tr("FXAA")),
|
||||
PAIR(AntiAliasing, Smaa, tr("SMAA")),
|
||||
PAIR(AntiAliasing, None, "None"),
|
||||
PAIR(AntiAliasing, Fxaa, "FXAA"),
|
||||
PAIR(AntiAliasing, Smaa, "SMAA"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AspectRatio>::Index(),
|
||||
{
|
||||
PAIR(AspectRatio, R16_9, tr("Default (16:9)")),
|
||||
PAIR(AspectRatio, R4_3, tr("Force 4:3")),
|
||||
PAIR(AspectRatio, R21_9, tr("Force 21:9")),
|
||||
PAIR(AspectRatio, R16_10, tr("Force 16:10")),
|
||||
PAIR(AspectRatio, Stretch, tr("Stretch to Window")),
|
||||
PAIR(AspectRatio, R16_9, "Default (16:9)"),
|
||||
PAIR(AspectRatio, R4_3, "Force 4:3"),
|
||||
PAIR(AspectRatio, R21_9, "Force 21:9"),
|
||||
PAIR(AspectRatio, R16_10, "Force 16:10"),
|
||||
PAIR(AspectRatio, Stretch, "Stretch to Window"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AnisotropyMode>::Index(),
|
||||
{
|
||||
PAIR(AnisotropyMode, Automatic, tr("Automatic")),
|
||||
PAIR(AnisotropyMode, Default, tr("Default")),
|
||||
PAIR(AnisotropyMode, X2, tr("2x")),
|
||||
PAIR(AnisotropyMode, X4, tr("4x")),
|
||||
PAIR(AnisotropyMode, X8, tr("8x")),
|
||||
PAIR(AnisotropyMode, X16, tr("16x")),
|
||||
PAIR(AnisotropyMode, Automatic, "Automatic"),
|
||||
PAIR(AnisotropyMode, Default, "Default"),
|
||||
PAIR(AnisotropyMode, X2, "2x"),
|
||||
PAIR(AnisotropyMode, X4, "4x"),
|
||||
PAIR(AnisotropyMode, X8, "8x"),
|
||||
PAIR(AnisotropyMode, X16, "16x"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::Language>::Index(),
|
||||
{
|
||||
PAIR(Language, Japanese, tr("Japanese (日本語)")),
|
||||
PAIR(Language, EnglishAmerican, tr("American English")),
|
||||
PAIR(Language, French, tr("French (français)")),
|
||||
PAIR(Language, German, tr("German (Deutsch)")),
|
||||
PAIR(Language, Italian, tr("Italian (italiano)")),
|
||||
PAIR(Language, Spanish, tr("Spanish (español)")),
|
||||
PAIR(Language, Chinese, tr("Chinese")),
|
||||
PAIR(Language, Korean, tr("Korean (한국어)")),
|
||||
PAIR(Language, Dutch, tr("Dutch (Nederlands)")),
|
||||
PAIR(Language, Portuguese, tr("Portuguese (português)")),
|
||||
PAIR(Language, Russian, tr("Russian (Русский)")),
|
||||
PAIR(Language, Taiwanese, tr("Taiwanese")),
|
||||
PAIR(Language, EnglishBritish, tr("British English")),
|
||||
PAIR(Language, FrenchCanadian, tr("Canadian French")),
|
||||
PAIR(Language, SpanishLatin, tr("Latin American Spanish")),
|
||||
PAIR(Language, ChineseSimplified, tr("Simplified Chinese")),
|
||||
PAIR(Language, ChineseTraditional, tr("Traditional Chinese (正體中文)")),
|
||||
PAIR(Language, PortugueseBrazilian, tr("Brazilian Portuguese (português do Brasil)")),
|
||||
PAIR(Language, Japanese, "Japanese (日本語)"),
|
||||
PAIR(Language, EnglishAmerican, "American English"),
|
||||
PAIR(Language, French, "French (français)"),
|
||||
PAIR(Language, German, "German (Deutsch)"),
|
||||
PAIR(Language, Italian, "Italian (italiano)"),
|
||||
PAIR(Language, Spanish, "Spanish (español)"),
|
||||
PAIR(Language, Chinese, "Chinese"),
|
||||
PAIR(Language, Korean, "Korean (한국어)"),
|
||||
PAIR(Language, Dutch, "Dutch (Nederlands)"),
|
||||
PAIR(Language, Portuguese, "Portuguese (português)"),
|
||||
PAIR(Language, Russian, "Russian (Русский)"),
|
||||
PAIR(Language, Taiwanese, "Taiwanese"),
|
||||
PAIR(Language, EnglishBritish, "British English"),
|
||||
PAIR(Language, FrenchCanadian, "Canadian French"),
|
||||
PAIR(Language, SpanishLatin, "Latin American Spanish"),
|
||||
PAIR(Language, ChineseSimplified, "Simplified Chinese"),
|
||||
PAIR(Language, ChineseTraditional, "Traditional Chinese (正體中文)"),
|
||||
PAIR(Language, PortugueseBrazilian, "Brazilian Portuguese (português do Brasil)"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::Region>::Index(),
|
||||
{
|
||||
PAIR(Region, Japan, tr("Japan")),
|
||||
PAIR(Region, Usa, tr("USA")),
|
||||
PAIR(Region, Europe, tr("Europe")),
|
||||
PAIR(Region, Australia, tr("Australia")),
|
||||
PAIR(Region, China, tr("China")),
|
||||
PAIR(Region, Korea, tr("Korea")),
|
||||
PAIR(Region, Taiwan, tr("Taiwan")),
|
||||
PAIR(Region, Japan, "Japan"),
|
||||
PAIR(Region, Usa, "USA"),
|
||||
PAIR(Region, Europe, "Europe"),
|
||||
PAIR(Region, Australia, "Australia"),
|
||||
PAIR(Region, China, "China"),
|
||||
PAIR(Region, Korea, "Korea"),
|
||||
PAIR(Region, Taiwan, "Taiwan"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::TimeZone>::Index(),
|
||||
@@ -340,74 +323,72 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
|
||||
{static_cast<u32>(Settings::TimeZone::Default),
|
||||
tr("Default (%1)", "Default time zone")
|
||||
.arg(QString::fromStdString(Common::TimeZone::GetDefaultTimeZone()))},
|
||||
PAIR(TimeZone, Cet, tr("CET")),
|
||||
PAIR(TimeZone, Cst6Cdt, tr("CST6CDT")),
|
||||
PAIR(TimeZone, Cuba, tr("Cuba")),
|
||||
PAIR(TimeZone, Eet, tr("EET")),
|
||||
PAIR(TimeZone, Egypt, tr("Egypt")),
|
||||
PAIR(TimeZone, Eire, tr("Eire")),
|
||||
PAIR(TimeZone, Est, tr("EST")),
|
||||
PAIR(TimeZone, Est5Edt, tr("EST5EDT")),
|
||||
PAIR(TimeZone, Gb, tr("GB")),
|
||||
PAIR(TimeZone, GbEire, tr("GB-Eire")),
|
||||
PAIR(TimeZone, Gmt, tr("GMT")),
|
||||
PAIR(TimeZone, GmtPlusZero, tr("GMT+0")),
|
||||
PAIR(TimeZone, GmtMinusZero, tr("GMT-0")),
|
||||
PAIR(TimeZone, GmtZero, tr("GMT0")),
|
||||
PAIR(TimeZone, Greenwich, tr("Greenwich")),
|
||||
PAIR(TimeZone, Hongkong, tr("Hongkong")),
|
||||
PAIR(TimeZone, Hst, tr("HST")),
|
||||
PAIR(TimeZone, Iceland, tr("Iceland")),
|
||||
PAIR(TimeZone, Iran, tr("Iran")),
|
||||
PAIR(TimeZone, Israel, tr("Israel")),
|
||||
PAIR(TimeZone, Jamaica, tr("Jamaica")),
|
||||
PAIR(TimeZone, Japan, tr("Japan")),
|
||||
PAIR(TimeZone, Kwajalein, tr("Kwajalein")),
|
||||
PAIR(TimeZone, Libya, tr("Libya")),
|
||||
PAIR(TimeZone, Met, tr("MET")),
|
||||
PAIR(TimeZone, Mst, tr("MST")),
|
||||
PAIR(TimeZone, Mst7Mdt, tr("MST7MDT")),
|
||||
PAIR(TimeZone, Navajo, tr("Navajo")),
|
||||
PAIR(TimeZone, Nz, tr("NZ")),
|
||||
PAIR(TimeZone, NzChat, tr("NZ-CHAT")),
|
||||
PAIR(TimeZone, Poland, tr("Poland")),
|
||||
PAIR(TimeZone, Portugal, tr("Portugal")),
|
||||
PAIR(TimeZone, Prc, tr("PRC")),
|
||||
PAIR(TimeZone, Pst8Pdt, tr("PST8PDT")),
|
||||
PAIR(TimeZone, Roc, tr("ROC")),
|
||||
PAIR(TimeZone, Rok, tr("ROK")),
|
||||
PAIR(TimeZone, Singapore, tr("Singapore")),
|
||||
PAIR(TimeZone, Turkey, tr("Turkey")),
|
||||
PAIR(TimeZone, Uct, tr("UCT")),
|
||||
PAIR(TimeZone, Universal, tr("Universal")),
|
||||
PAIR(TimeZone, Utc, tr("UTC")),
|
||||
PAIR(TimeZone, WSu, tr("W-SU")),
|
||||
PAIR(TimeZone, Wet, tr("WET")),
|
||||
PAIR(TimeZone, Zulu, tr("Zulu")),
|
||||
PAIR(TimeZone, Cet, "CET"),
|
||||
PAIR(TimeZone, Cst6Cdt, "CST6CDT"),
|
||||
PAIR(TimeZone, Cuba, "Cuba"),
|
||||
PAIR(TimeZone, Eet, "EET"),
|
||||
PAIR(TimeZone, Egypt, "Egypt"),
|
||||
PAIR(TimeZone, Eire, "Eire"),
|
||||
PAIR(TimeZone, Est, "EST"),
|
||||
PAIR(TimeZone, Est5Edt, "EST5EDT"),
|
||||
PAIR(TimeZone, Gb, "GB"),
|
||||
PAIR(TimeZone, GbEire, "GB-Eire"),
|
||||
PAIR(TimeZone, Gmt, "GMT"),
|
||||
PAIR(TimeZone, GmtPlusZero, "GMT+0"),
|
||||
PAIR(TimeZone, GmtMinusZero, "GMT-0"),
|
||||
PAIR(TimeZone, GmtZero, "GMT0"),
|
||||
PAIR(TimeZone, Greenwich, "Greenwich"),
|
||||
PAIR(TimeZone, Hongkong, "Hongkong"),
|
||||
PAIR(TimeZone, Hst, "HST"),
|
||||
PAIR(TimeZone, Iceland, "Iceland"),
|
||||
PAIR(TimeZone, Iran, "Iran"),
|
||||
PAIR(TimeZone, Israel, "Israel"),
|
||||
PAIR(TimeZone, Jamaica, "Jamaica"),
|
||||
PAIR(TimeZone, Japan, "Japan"),
|
||||
PAIR(TimeZone, Kwajalein, "Kwajalein"),
|
||||
PAIR(TimeZone, Libya, "Libya"),
|
||||
PAIR(TimeZone, Met, "MET"),
|
||||
PAIR(TimeZone, Mst, "MST"),
|
||||
PAIR(TimeZone, Mst7Mdt, "MST7MDT"),
|
||||
PAIR(TimeZone, Navajo, "Navajo"),
|
||||
PAIR(TimeZone, Nz, "NZ"),
|
||||
PAIR(TimeZone, NzChat, "NZ-CHAT"),
|
||||
PAIR(TimeZone, Poland, "Poland"),
|
||||
PAIR(TimeZone, Portugal, "Portugal"),
|
||||
PAIR(TimeZone, Prc, "PRC"),
|
||||
PAIR(TimeZone, Pst8Pdt, "PST8PDT"),
|
||||
PAIR(TimeZone, Roc, "ROC"),
|
||||
PAIR(TimeZone, Rok, "ROK"),
|
||||
PAIR(TimeZone, Singapore, "Singapore"),
|
||||
PAIR(TimeZone, Turkey, "Turkey"),
|
||||
PAIR(TimeZone, Uct, "UCT"),
|
||||
PAIR(TimeZone, Universal, "Universal"),
|
||||
PAIR(TimeZone, Utc, "UTC"),
|
||||
PAIR(TimeZone, WSu, "W-SU"),
|
||||
PAIR(TimeZone, Wet, "WET"),
|
||||
PAIR(TimeZone, Zulu, "Zulu"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AudioMode>::Index(),
|
||||
{
|
||||
PAIR(AudioMode, Mono, tr("Mono")),
|
||||
PAIR(AudioMode, Stereo, tr("Stereo")),
|
||||
PAIR(AudioMode, Surround, tr("Surround")),
|
||||
PAIR(AudioMode, Mono, "Mono"),
|
||||
PAIR(AudioMode, Stereo, "Stereo"),
|
||||
PAIR(AudioMode, Surround, "Surround"),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::MemoryLayout>::Index(),
|
||||
{
|
||||
PAIR(MemoryLayout, Memory_4Gb, tr("4GB DRAM (Default)")),
|
||||
PAIR(MemoryLayout, Memory_6Gb, tr("6GB DRAM (Unsafe)")),
|
||||
PAIR(MemoryLayout, Memory_8Gb, tr("8GB DRAM (Unsafe)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ConsoleMode>::Index(),
|
||||
{
|
||||
PAIR(ConsoleMode, Docked, tr("Docked")),
|
||||
PAIR(ConsoleMode, Handheld, tr("Handheld")),
|
||||
PAIR(MemoryLayout, Memory_4Gb, "4GB DRAM (Default)"),
|
||||
PAIR(MemoryLayout, Memory_6Gb, "6GB DRAM (Unsafe)"),
|
||||
PAIR(MemoryLayout, Memory_8Gb, "8GB DRAM (Unsafe)"),
|
||||
}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ConsoleMode>::Index(),
|
||||
{PAIR(ConsoleMode, Docked, "Docked"), PAIR(ConsoleMode, Handheld, "Handheld")}});
|
||||
translations->insert(
|
||||
{Settings::EnumMetadata<Settings::ConfirmStop>::Index(),
|
||||
{
|
||||
PAIR(ConfirmStop, Ask_Always, tr("Always ask (Default)")),
|
||||
PAIR(ConfirmStop, Ask_Based_On_Game, tr("Only if game specifies not to stop")),
|
||||
PAIR(ConfirmStop, Ask_Never, tr("Never ask")),
|
||||
PAIR(ConfirmStop, Ask_Always, "Always ask (Default)"),
|
||||
PAIR(ConfirmStop, Ask_Based_On_Game, "Only if game specifies not to stop"),
|
||||
PAIR(ConfirmStop, Ask_Never, "Never ask"),
|
||||
}});
|
||||
|
||||
#undef PAIR
|
||||
|
||||
@@ -194,7 +194,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
|
||||
return group;
|
||||
}
|
||||
|
||||
const auto get_selected = [this]() -> int {
|
||||
const auto get_selected = [=]() -> int {
|
||||
for (const auto& [id, button] : radio_buttons) {
|
||||
if (button->isChecked()) {
|
||||
return id;
|
||||
@@ -203,7 +203,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
|
||||
return -1;
|
||||
};
|
||||
|
||||
const auto set_index = [this](u32 value) {
|
||||
const auto set_index = [=](u32 value) {
|
||||
for (const auto& [id, button] : radio_buttons) {
|
||||
button->setChecked(id == value);
|
||||
}
|
||||
|
||||
@@ -479,6 +479,6 @@ void GameListWorker::run() {
|
||||
}
|
||||
}
|
||||
|
||||
RecordEvent([this](GameList* game_list) { game_list->DonePopulating(watch_list); });
|
||||
RecordEvent([=](GameList* game_list) { game_list->DonePopulating(watch_list); });
|
||||
processing_completed.Set();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user