early-access version 2673

This commit is contained in:
pineappleEA 2022-04-13 21:35:46 +02:00
parent 70fb7aec08
commit df8b847719
21 changed files with 813 additions and 197 deletions

View file

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

View file

@ -590,9 +590,6 @@ struct Values {
BasicSetting<int> touch_from_button_map_index{0, "touch_from_button_map"};
std::vector<TouchFromButtonMap> touch_from_button_maps;
BasicSetting<bool> enable_ring_controller{true, "enable_ring_controller"};
RingconRaw ringcon_analogs;
// Data Storage
BasicSetting<bool> use_virtual_sd{true, "use_virtual_sd"};
BasicSetting<bool> gamecard_inserted{false, "gamecard_inserted"};

View file

@ -357,7 +357,6 @@ constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>;
using RingconRaw = std::string;
constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;

View file

@ -434,8 +434,6 @@ add_library(core STATIC
hle/service/grc/grc.h
hle/service/hid/hid.cpp
hle/service/hid/hid.h
hle/service/hid/hidbus.cpp
hle/service/hid/hidbus.h
hle/service/hid/irs.cpp
hle/service/hid/irs.h
hle/service/hid/ring_lifo.h
@ -462,14 +460,8 @@ add_library(core STATIC
hle/service/hid/controllers/touchscreen.h
hle/service/hid/controllers/xpad.cpp
hle/service/hid/controllers/xpad.h
hle/service/hid/hidbus/hidbus_base.cpp
hle/service/hid/hidbus/hidbus_base.h
hle/service/hid/hidbus/ringcon.cpp
hle/service/hid/hidbus/ringcon.h
hle/service/hid/hidbus/starlink.cpp
hle/service/hid/hidbus/starlink.h
hle/service/hid/hidbus/stubbed.cpp
hle/service/hid/hidbus/stubbed.h
hle/service/jit/jit_context.cpp
hle/service/jit/jit_context.h
hle/service/jit/jit.cpp
hle/service/jit/jit.h
hle/service/lbl/lbl.cpp

View file

@ -15,7 +15,6 @@ EmulatedDevices::EmulatedDevices() = default;
EmulatedDevices::~EmulatedDevices() = default;
void EmulatedDevices::ReloadFromSettings() {
ring_params = Common::ParamPackage(Settings::values.ringcon_analogs);
ReloadInput();
}
@ -67,8 +66,6 @@ void EmulatedDevices::ReloadInput() {
key_index++;
}
ring_analog_device = Common::Input::CreateDevice<Common::Input::InputDevice>(ring_params);
for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) {
if (!mouse_button_devices[index]) {
continue;
@ -123,13 +120,6 @@ void EmulatedDevices::ReloadInput() {
},
});
}
if (ring_analog_device) {
ring_analog_device->SetCallback({
.on_change =
[this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); },
});
}
}
void EmulatedDevices::UnloadInput() {
@ -165,7 +155,6 @@ void EmulatedDevices::SaveCurrentConfig() {
if (!is_configuring) {
return;
}
Settings::values.ringcon_analogs = ring_params.Serialize();
}
void EmulatedDevices::RestoreConfig() {
@ -175,15 +164,6 @@ void EmulatedDevices::RestoreConfig() {
ReloadFromSettings();
}
Common::ParamPackage EmulatedDevices::GetRingParam() const {
return ring_params;
}
void EmulatedDevices::SetRingParam(Common::ParamPackage param) {
ring_params = std::move(param);
ReloadInput();
}
void EmulatedDevices::SetKeyboardButton(const Common::Input::CallbackStatus& callback,
std::size_t index) {
if (index >= device_status.keyboard_values.size()) {
@ -430,23 +410,6 @@ void EmulatedDevices::SetMouseStick(const Common::Input::CallbackStatus& callbac
TriggerOnChange(DeviceTriggerType::Mouse);
}
void EmulatedDevices::SetRingAnalog(const Common::Input::CallbackStatus& callback) {
std::lock_guard lock{mutex};
const auto force_value = TransformToStick(callback);
device_status.ring_analog_value = force_value.x;
if (is_configuring) {
device_status.ring_analog_value = {};
TriggerOnChange(DeviceTriggerType::RingController);
return;
}
device_status.ring_analog_state.force = force_value.x.value;
TriggerOnChange(DeviceTriggerType::RingController);
}
KeyboardValues EmulatedDevices::GetKeyboardValues() const {
std::scoped_lock lock{mutex};
return device_status.keyboard_values;
@ -462,10 +425,6 @@ MouseButtonValues EmulatedDevices::GetMouseButtonsValues() const {
return device_status.mouse_button_values;
}
RingAnalogValue EmulatedDevices::GetRingSensorValues() const {
return device_status.ring_analog_value;
}
KeyboardKey EmulatedDevices::GetKeyboard() const {
std::scoped_lock lock{mutex};
return device_status.keyboard_state;
@ -491,10 +450,6 @@ AnalogStickState EmulatedDevices::GetMouseWheel() const {
return device_status.mouse_wheel_state;
}
RingSensorForce EmulatedDevices::GetRingSensorForce() const {
return device_status.ring_analog_state;
}
void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) {
std::scoped_lock lock{callback_mutex};
for (const auto& poller_pair : callback_list) {

View file

@ -26,11 +26,9 @@ using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice
using MouseAnalogDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
Settings::NativeMouseWheel::NumMouseWheels>;
using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>;
using RingAnalogDevice = std::unique_ptr<Common::Input::InputDevice>;
using MouseButtonParams =
std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>;
using RingAnalogParams = Common::ParamPackage;
using KeyboardValues =
std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardKeys>;
@ -41,17 +39,12 @@ using MouseButtonValues =
using MouseAnalogValues =
std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>;
using MouseStickValue = Common::Input::TouchStatus;
using RingAnalogValue = Common::Input::AnalogStatus;
struct MousePosition {
f32 x;
f32 y;
};
struct RingSensorForce {
f32 force;
};
struct DeviceStatus {
// Data from input_common
KeyboardValues keyboard_values{};
@ -59,7 +52,6 @@ struct DeviceStatus {
MouseButtonValues mouse_button_values{};
MouseAnalogValues mouse_analog_values{};
MouseStickValue mouse_stick_value{};
RingAnalogValue ring_analog_value{};
// Data for HID serices
KeyboardKey keyboard_state{};
@ -67,14 +59,12 @@ struct DeviceStatus {
MouseButton mouse_button_state{};
MousePosition mouse_position_state{};
AnalogStickState mouse_wheel_state{};
RingSensorForce ring_analog_state{};
};
enum class DeviceTriggerType {
Keyboard,
KeyboardModdifier,
Mouse,
RingController,
};
struct InterfaceUpdateCallback {
@ -120,15 +110,6 @@ public:
/// Reverts any mapped changes made that weren't saved
void RestoreConfig();
// Returns the current mapped ring device
Common::ParamPackage GetRingParam() const;
/**
* Updates the current mapped ring device
* @param param ParamPackage with ring sensor data to be mapped
*/
void SetRingParam(Common::ParamPackage param);
/// Returns the latest status of button input from the keyboard with parameters
KeyboardValues GetKeyboardValues() const;
@ -138,9 +119,6 @@ public:
/// Returns the latest status of button input from the mouse with parameters
MouseButtonValues GetMouseButtonsValues() const;
/// Returns the latest status of analog input from the ring sensor with parameters
RingAnalogValue GetRingSensorValues() const;
/// Returns the latest status of button input from the keyboard
KeyboardKey GetKeyboard() const;
@ -156,9 +134,6 @@ public:
/// Returns the latest mouse wheel change
AnalogStickState GetMouseWheel() const;
/// Returns the latest ringcon force sensor value
RingSensorForce GetRingSensorForce() const;
/**
* Adds a callback to the list of events
* @param update_callback InterfaceUpdateCallback that will be triggered
@ -210,12 +185,6 @@ private:
*/
void SetMouseStick(const Common::Input::CallbackStatus& callback);
/**
* Updates the ring analog sensor status of the ring controller
* @param callback A CallbackStatus containing the force status
*/
void SetRingAnalog(const Common::Input::CallbackStatus& callback);
/**
* Triggers a callback that something has changed on the device status
* @param type Input type of the event to trigger
@ -224,14 +193,11 @@ private:
bool is_configuring{false};
RingAnalogParams ring_params;
KeyboardDevices keyboard_devices;
KeyboardModifierDevices keyboard_modifier_devices;
MouseButtonDevices mouse_button_devices;
MouseAnalogDevices mouse_analog_devices;
MouseStickDevice mouse_stick_device;
RingAnalogDevice ring_analog_device;
mutable std::mutex mutex;
mutable std::mutex callback_mutex;

View file

@ -35,9 +35,14 @@ ResultCode KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr
R_TRY(page_table.LockForCodeMemory(addr, size))
// Clear the memory.
for (const auto& block : m_page_group.Nodes()) {
std::memset(device_memory.GetPointer(block.GetAddress()), 0xFF, block.GetSize());
}
//
// FIXME: this ends up clobbering address ranges outside the scope of the mapping within
// guest memory, and is not specifically required if the guest program is correctly
// written, so disable until this is further investigated.
//
// for (const auto& block : m_page_group.Nodes()) {
// std::memset(device_memory.GetPointer(block.GetAddress()), 0xFF, block.GetSize());
// }
// Set remaining tracking members.
m_address = addr;

View file

@ -140,7 +140,6 @@ struct KernelCore::Impl {
CleanupObject(font_shared_mem);
CleanupObject(irs_shared_mem);
CleanupObject(time_shared_mem);
CleanupObject(hidbus_shared_mem);
CleanupObject(system_resource_limit);
for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
@ -623,20 +622,16 @@ struct KernelCore::Impl {
constexpr std::size_t font_size{0x1100000};
constexpr std::size_t irs_size{0x8000};
constexpr std::size_t time_size{0x1000};
constexpr std::size_t hidbus_size{0x1000};
const PAddr hid_phys_addr{system_pool.GetAddress()};
const PAddr font_phys_addr{system_pool.GetAddress() + hid_size};
const PAddr irs_phys_addr{system_pool.GetAddress() + hid_size + font_size};
const PAddr time_phys_addr{system_pool.GetAddress() + hid_size + font_size + irs_size};
const PAddr hidbus_phys_addr{system_pool.GetAddress() + hid_size + font_size + irs_size +
time_size};
hid_shared_mem = KSharedMemory::Create(system.Kernel());
font_shared_mem = KSharedMemory::Create(system.Kernel());
irs_shared_mem = KSharedMemory::Create(system.Kernel());
time_shared_mem = KSharedMemory::Create(system.Kernel());
hidbus_shared_mem = KSharedMemory::Create(system.Kernel());
hid_shared_mem->Initialize(system.DeviceMemory(), nullptr,
{hid_phys_addr, hid_size / PageSize},
@ -654,10 +649,6 @@ struct KernelCore::Impl {
{time_phys_addr, time_size / PageSize},
Svc::MemoryPermission::None, Svc::MemoryPermission::Read,
time_phys_addr, time_size, "Time:SharedMemory");
hidbus_shared_mem->Initialize(system.DeviceMemory(), nullptr,
{hidbus_phys_addr, hidbus_size / PageSize},
Svc::MemoryPermission::None, Svc::MemoryPermission::Read,
hidbus_phys_addr, hidbus_size, "HidBus:SharedMemory");
}
KClientPort* CreateNamedServicePort(std::string name) {
@ -757,7 +748,6 @@ struct KernelCore::Impl {
Kernel::KSharedMemory* font_shared_mem{};
Kernel::KSharedMemory* irs_shared_mem{};
Kernel::KSharedMemory* time_shared_mem{};
Kernel::KSharedMemory* hidbus_shared_mem{};
// Memory layout
std::unique_ptr<KMemoryLayout> memory_layout;
@ -1057,14 +1047,6 @@ const Kernel::KSharedMemory& KernelCore::GetTimeSharedMem() const {
return *impl->time_shared_mem;
}
Kernel::KSharedMemory& KernelCore::GetHidBusSharedMem() {
return *impl->hidbus_shared_mem;
}
const Kernel::KSharedMemory& KernelCore::GetHidBusSharedMem() const {
return *impl->hidbus_shared_mem;
}
void KernelCore::Suspend(bool in_suspention) {
const bool should_suspend = exception_exited || in_suspention;
{

View file

@ -264,12 +264,6 @@ public:
/// Gets the shared memory object for Time services.
const Kernel::KSharedMemory& GetTimeSharedMem() const;
/// Gets the shared memory object for HIDBus services.
Kernel::KSharedMemory& GetHidBusSharedMem();
/// Gets the shared memory object for HIDBus services.
const Kernel::KSharedMemory& GetHidBusSharedMem() const;
/// Suspend/unsuspend the OS.
void Suspend(bool in_suspention);

View file

@ -16,7 +16,6 @@
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/hid/errors.h"
#include "core/hle/service/hid/hid.h"
#include "core/hle/service/hid/hidbus.h"
#include "core/hle/service/hid/irs.h"
#include "core/hle/service/hid/xcd.h"
#include "core/memory.h"
@ -2129,6 +2128,32 @@ public:
}
};
class HidBus final : public ServiceFramework<HidBus> {
public:
explicit HidBus(Core::System& system_) : ServiceFramework{system_, "hidbus"} {
// clang-format off
static const FunctionInfo functions[] = {
{1, nullptr, "GetBusHandle"},
{2, nullptr, "IsExternalDeviceConnected"},
{3, nullptr, "Initialize"},
{4, nullptr, "Finalize"},
{5, nullptr, "EnableExternalDevice"},
{6, nullptr, "GetExternalDeviceId"},
{7, nullptr, "SendCommandAsync"},
{8, nullptr, "GetSendCommandAsynceResult"},
{9, nullptr, "SetEventForSendCommandAsycResult"},
{10, nullptr, "GetSharedMemoryHandle"},
{11, nullptr, "EnableJoyPollingReceiveMode"},
{12, nullptr, "DisableJoyPollingReceiveMode"},
{13, nullptr, "GetPollingData"},
{14, nullptr, "SetStatusManagerType"},
};
// clang-format on
RegisterHandlers(functions);
}
};
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
std::make_shared<Hid>(system)->InstallAsService(service_manager);
std::make_shared<HidBus>(system)->InstallAsService(service_manager);

View file

@ -2,27 +2,256 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/arm/symbols.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/k_code_memory.h"
#include "core/hle/kernel/k_transfer_memory.h"
#include "core/hle/result.h"
#include "core/hle/service/jit/jit.h"
#include "core/hle/service/jit/jit_context.h"
#include "core/hle/service/service.h"
#include "core/memory.h"
namespace Service::JIT {
struct CodeRange {
u64 offset;
u64 size;
};
class IJitEnvironment final : public ServiceFramework<IJitEnvironment> {
public:
explicit IJitEnvironment(Core::System& system_) : ServiceFramework{system_, "IJitEnvironment"} {
explicit IJitEnvironment(Core::System& system_, CodeRange user_rx, CodeRange user_ro)
: ServiceFramework{system_, "IJitEnvironment", ServiceThreadType::CreateNew},
context{system_.Memory()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "GenerateCode"},
{1, nullptr, "Control"},
{1000, nullptr, "LoadPlugin"},
{1001, nullptr, "GetCodeAddress"},
{0, &IJitEnvironment::GenerateCode, "GenerateCode"},
{1, &IJitEnvironment::Control, "Control"},
{1000, &IJitEnvironment::LoadPlugin, "LoadPlugin"},
{1001, &IJitEnvironment::GetCodeAddress, "GetCodeAddress"},
};
// clang-format on
RegisterHandlers(functions);
// Identity map user code range into sysmodule context
configuration.user_ro_memory = user_ro;
configuration.user_rx_memory = user_rx;
configuration.sys_ro_memory = user_ro;
configuration.sys_rx_memory = user_rx;
}
void GenerateCode(Kernel::HLERequestContext& ctx) {
struct Parameters {
u32 data_size;
u64 command;
CodeRange cr1;
CodeRange cr2;
Struct32 data;
};
IPC::RequestParser rp{ctx};
const auto parameters{rp.PopRaw<Parameters>()};
std::vector<u8> input_buffer{ctx.CanReadBuffer() ? ctx.ReadBuffer() : std::vector<u8>()};
std::vector<u8> output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0);
const VAddr return_ptr{context.AddHeap(0u)};
const VAddr cr1_in_ptr{context.AddHeap(parameters.cr1)};
const VAddr cr2_in_ptr{context.AddHeap(parameters.cr2)};
const VAddr cr1_out_ptr{
context.AddHeap(CodeRange{.offset = parameters.cr1.offset, .size = 0})};
const VAddr cr2_out_ptr{
context.AddHeap(CodeRange{.offset = parameters.cr2.offset, .size = 0})};
const VAddr input_ptr{context.AddHeap(input_buffer.data(), input_buffer.size())};
const VAddr output_ptr{context.AddHeap(output_buffer.data(), output_buffer.size())};
const VAddr data_ptr{context.AddHeap(parameters.data)};
const VAddr configuration_ptr{context.AddHeap(configuration)};
context.CallFunction(callbacks.GenerateCode, return_ptr, cr1_out_ptr, cr2_out_ptr,
configuration_ptr, parameters.command, input_ptr, input_buffer.size(),
cr1_in_ptr, cr2_in_ptr, data_ptr, parameters.data_size, output_ptr,
output_buffer.size());
const s32 return_value{context.GetHeap<s32>(return_ptr)};
if (return_value == 0) {
system.InvalidateCpuInstructionCacheRange(configuration.user_rx_memory.offset,
configuration.user_rx_memory.size);
if (ctx.CanWriteBuffer()) {
context.GetHeap(output_ptr, output_buffer.data(), output_buffer.size());
ctx.WriteBuffer(output_buffer.data(), output_buffer.size());
}
const auto cr1_out{context.GetHeap<CodeRange>(cr1_out_ptr)};
const auto cr2_out{context.GetHeap<CodeRange>(cr2_out_ptr)};
IPC::ResponseBuilder rb{ctx, 8};
rb.Push(ResultSuccess);
rb.Push<u64>(return_value);
rb.PushRaw(cr1_out);
rb.PushRaw(cr2_out);
} else {
LOG_WARNING(Service_JIT, "plugin GenerateCode callback failed");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
}
};
void Control(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto command{rp.PopRaw<u64>()};
const auto input_buffer{ctx.ReadBuffer()};
std::vector<u8> output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0);
const VAddr return_ptr{context.AddHeap(0u)};
const VAddr configuration_ptr{context.AddHeap(configuration)};
const VAddr input_ptr{context.AddHeap(input_buffer.data(), input_buffer.size())};
const VAddr output_ptr{context.AddHeap(output_buffer.data(), output_buffer.size())};
const u64 wrapper_value{
context.CallFunction(callbacks.Control, return_ptr, configuration_ptr, command,
input_ptr, input_buffer.size(), output_ptr, output_buffer.size())};
const s32 return_value{context.GetHeap<s32>(return_ptr)};
if (wrapper_value == 0 && return_value == 0) {
if (ctx.CanWriteBuffer()) {
context.GetHeap(output_ptr, output_buffer.data(), output_buffer.size());
ctx.WriteBuffer(output_buffer.data(), output_buffer.size());
}
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(return_value);
} else {
LOG_WARNING(Service_JIT, "plugin Control callback failed");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
}
}
void LoadPlugin(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto tmem_size{rp.PopRaw<u64>()};
if (tmem_size == 0) {
LOG_ERROR(Service_JIT, "attempted to load plugin with empty transfer memory");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
const auto tmem_handle{ctx.GetCopyHandle(0)};
auto tmem{system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
tmem_handle)};
if (tmem.IsNull()) {
LOG_ERROR(Service_JIT, "attempted to load plugin with invalid transfer memory handle");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
configuration.work_memory.offset = tmem->GetSourceAddress();
configuration.work_memory.size = tmem_size;
const auto nro_plugin{ctx.ReadBuffer(1)};
auto symbols{Core::Symbols::GetSymbols(nro_plugin, true)};
const auto GetSymbol{[&](std::string name) { return symbols[name].first; }};
callbacks =
GuestCallbacks{.rtld_fini = GetSymbol("_fini"),
.rtld_init = GetSymbol("_init"),
.Control = GetSymbol("nnjitpluginControl"),
.ResolveBasicSymbols = GetSymbol("nnjitpluginResolveBasicSymbols"),
.SetupDiagnostics = GetSymbol("nnjitpluginSetupDiagnostics"),
.Configure = GetSymbol("nnjitpluginConfigure"),
.GenerateCode = GetSymbol("nnjitpluginGenerateCode"),
.GetVersion = GetSymbol("nnjitpluginGetVersion"),
.Keeper = GetSymbol("nnjitpluginKeeper"),
.OnPrepared = GetSymbol("nnjitpluginOnPrepared")};
if (callbacks.GetVersion == 0 || callbacks.Configure == 0 || callbacks.GenerateCode == 0 ||
callbacks.OnPrepared == 0) {
LOG_ERROR(Service_JIT, "plugin does not implement all necessary functionality");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
if (!context.LoadNRO(nro_plugin)) {
LOG_ERROR(Service_JIT, "failed to load plugin");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
context.MapProcessMemory(configuration.sys_ro_memory.offset,
configuration.sys_ro_memory.size);
context.MapProcessMemory(configuration.sys_rx_memory.offset,
configuration.sys_rx_memory.size);
context.MapProcessMemory(configuration.work_memory.offset, configuration.work_memory.size);
if (callbacks.rtld_init != 0) {
context.CallFunction(callbacks.rtld_init);
}
const auto version{context.CallFunction(callbacks.GetVersion)};
if (version != 1) {
LOG_ERROR(Service_JIT, "unknown plugin version {}", version);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
const auto resolve{context.GetHelper("_resolve")};
if (callbacks.ResolveBasicSymbols != 0) {
context.CallFunction(callbacks.ResolveBasicSymbols, resolve);
}
const auto resolve_ptr{context.AddHeap(resolve)};
if (callbacks.SetupDiagnostics != 0) {
context.CallFunction(callbacks.SetupDiagnostics, 0u, resolve_ptr);
}
context.CallFunction(callbacks.Configure, 0u);
const auto configuration_ptr{context.AddHeap(configuration)};
context.CallFunction(callbacks.OnPrepared, configuration_ptr);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void GetCodeAddress(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 6};
rb.Push(ResultSuccess);
rb.Push(configuration.user_rx_memory.offset);
rb.Push(configuration.user_ro_memory.offset);
}
private:
using Struct32 = std::array<u8, 32>;
struct GuestCallbacks {
VAddr rtld_fini;
VAddr rtld_init;
VAddr Control;
VAddr ResolveBasicSymbols;
VAddr SetupDiagnostics;
VAddr Configure;
VAddr GenerateCode;
VAddr GetVersion;
VAddr Keeper;
VAddr OnPrepared;
};
struct JITConfiguration {
CodeRange user_rx_memory;
CodeRange user_ro_memory;
CodeRange work_memory;
CodeRange sys_rx_memory;
CodeRange sys_ro_memory;
};
GuestCallbacks callbacks;
JITConfiguration configuration;
JITContext context;
};
class JITU final : public ServiceFramework<JITU> {
@ -40,9 +269,59 @@ public:
void CreateJitEnvironment(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_JIT, "called");
struct Parameters {
u64 rx_size;
u64 ro_size;
};
IPC::RequestParser rp{ctx};
const auto parameters{rp.PopRaw<Parameters>()};
const auto executable_mem_handle{ctx.GetCopyHandle(1)};
const auto readable_mem_handle{ctx.GetCopyHandle(2)};
if (parameters.rx_size == 0 || parameters.ro_size == 0) {
LOG_ERROR(Service_JIT, "attempted to init with empty code regions");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
// The copy handle at index 0 is the process handle, but handle tables are
// per-process, so there is no point reading it here until we are multiprocess
const auto& process{*system.CurrentProcess()};
auto executable_mem{
process.GetHandleTable().GetObject<Kernel::KCodeMemory>(executable_mem_handle)};
if (executable_mem.IsNull()) {
LOG_ERROR(Service_JIT, "executable_mem is null for handle=0x{:08X}",
executable_mem_handle);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
auto readable_mem{
process.GetHandleTable().GetObject<Kernel::KCodeMemory>(readable_mem_handle)};
if (readable_mem.IsNull()) {
LOG_ERROR(Service_JIT, "readable_mem is null for handle=0x{:08X}", readable_mem_handle);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown);
return;
}
const CodeRange user_rx{
.offset = executable_mem->GetSourceAddress(),
.size = parameters.rx_size,
};
const CodeRange user_ro{
.offset = readable_mem->GetSourceAddress(),
.size = parameters.ro_size,
};
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<IJitEnvironment>(system);
rb.PushIpcInterface<IJitEnvironment>(system, user_rx, user_ro);
}
};

View file

@ -0,0 +1,424 @@
// Copyright 2022 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <array>
#include <map>
#include <span>
#include <boost/icl/interval_set.hpp>
#include <dynarmic/interface/A64/a64.h>
#include <dynarmic/interface/A64/config.h>
#include "common/alignment.h"
#include "common/common_funcs.h"
#include "common/div_ceil.h"
#include "common/logging/log.h"
#include "core/hle/service/jit/jit_context.h"
#include "core/memory.h"
namespace Service::JIT {
constexpr std::array<u8, 4> STOP_ARM64 = {
0x01, 0x00, 0x00, 0xd4, // svc #0
};
constexpr std::array<u8, 8> RESOLVE_ARM64 = {
0x21, 0x00, 0x00, 0xd4, // svc #1
0xc0, 0x03, 0x5f, 0xd6, // ret
};
constexpr std::array<u8, 4> PANIC_ARM64 = {
0x41, 0x00, 0x00, 0xd4, // svc #2
};
constexpr std::array<u8, 60> MEMMOVE_ARM64 = {
0x1f, 0x00, 0x01, 0xeb, // cmp x0, x1
0x83, 0x01, 0x00, 0x54, // b.lo #+34
0x42, 0x04, 0x00, 0xd1, // sub x2, x2, 1
0x22, 0x01, 0xf8, 0xb7, // tbnz x2, #63, #+36
0x23, 0x68, 0x62, 0x38, // ldrb w3, [x1, x2]
0x03, 0x68, 0x22, 0x38, // strb w3, [x0, x2]
0xfc, 0xff, 0xff, 0x17, // b #-16
0x24, 0x68, 0x63, 0x38, // ldrb w4, [x1, x3]
0x04, 0x68, 0x23, 0x38, // strb w4, [x0, x3]
0x63, 0x04, 0x00, 0x91, // add x3, x3, 1
0x7f, 0x00, 0x02, 0xeb, // cmp x3, x2
0x8b, 0xff, 0xff, 0x54, // b.lt #-16
0xc0, 0x03, 0x5f, 0xd6, // ret
0x03, 0x00, 0x80, 0xd2, // mov x3, 0
0xfc, 0xff, 0xff, 0x17, // b #-16
};
constexpr std::array<u8, 28> MEMSET_ARM64 = {
0x03, 0x00, 0x80, 0xd2, // mov x3, 0
0x7f, 0x00, 0x02, 0xeb, // cmp x3, x2
0x4b, 0x00, 0x00, 0x54, // b.lt #+8
0xc0, 0x03, 0x5f, 0xd6, // ret
0x01, 0x68, 0x23, 0x38, // strb w1, [x0, x3]
0x63, 0x04, 0x00, 0x91, // add x3, x3, 1
0xfb, 0xff, 0xff, 0x17, // b #-20
};
struct HelperFunction {
const char* name;
const std::span<const u8> data;
};
constexpr std::array<HelperFunction, 6> HELPER_FUNCTIONS{{
{"_stop", STOP_ARM64},
{"_resolve", RESOLVE_ARM64},
{"_panic", PANIC_ARM64},
{"memcpy", MEMMOVE_ARM64},
{"memmove", MEMMOVE_ARM64},
{"memset", MEMSET_ARM64},
}};
struct Elf64_Dyn {
u64 d_tag;
u64 d_un;
};
struct Elf64_Rela {
u64 r_offset;
u64 r_info;
s64 r_addend;
};
static constexpr u32 Elf64_RelaType(const Elf64_Rela* rela) {
return static_cast<u32>(rela->r_info);
}
constexpr int DT_RELA = 7; /* Address of Rela relocs */
constexpr int DT_RELASZ = 8; /* Total size of Rela relocs */
constexpr int R_AARCH64_RELATIVE = 1027; /* Adjust by program base. */
constexpr size_t STACK_ALIGN = 16;
class JITContextImpl;
using IntervalSet = boost::icl::interval_set<VAddr>::type;
using IntervalType = boost::icl::interval_set<VAddr>::interval_type;
class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks {
public:
explicit DynarmicCallbacks64(Core::Memory::Memory& memory_, std::vector<u8>& local_memory_,
IntervalSet& mapped_ranges_, JITContextImpl& parent_)
: memory{memory_}, local_memory{local_memory_},
mapped_ranges{mapped_ranges_}, parent{parent_} {}
u8 MemoryRead8(u64 vaddr) override {
return ReadMemory<u8>(vaddr);
}
u16 MemoryRead16(u64 vaddr) override {
return ReadMemory<u16>(vaddr);
}
u32 MemoryRead32(u64 vaddr) override {
return ReadMemory<u32>(vaddr);
}
u64 MemoryRead64(u64 vaddr) override {
return ReadMemory<u64>(vaddr);
}
u128 MemoryRead128(u64 vaddr) override {
return ReadMemory<u128>(vaddr);
}
std::string MemoryReadCString(u64 vaddr) {
std::string result;
u8 next;
while ((next = MemoryRead8(vaddr++)) != 0) {
result += next;
}
return result;
}
void MemoryWrite8(u64 vaddr, u8 value) override {
WriteMemory<u8>(vaddr, value);
}
void MemoryWrite16(u64 vaddr, u16 value) override {
WriteMemory<u16>(vaddr, value);
}
void MemoryWrite32(u64 vaddr, u32 value) override {
WriteMemory<u32>(vaddr, value);
}
void MemoryWrite64(u64 vaddr, u64 value) override {
WriteMemory<u64>(vaddr, value);
}
void MemoryWrite128(u64 vaddr, u128 value) override {
WriteMemory<u128>(vaddr, value);
}
bool MemoryWriteExclusive8(u64 vaddr, u8 value, u8) override {
return WriteMemory<u8>(vaddr, value);
}
bool MemoryWriteExclusive16(u64 vaddr, u16 value, u16) override {
return WriteMemory<u16>(vaddr, value);
}
bool MemoryWriteExclusive32(u64 vaddr, u32 value, u32) override {
return WriteMemory<u32>(vaddr, value);
}
bool MemoryWriteExclusive64(u64 vaddr, u64 value, u64) override {
return WriteMemory<u64>(vaddr, value);
}
bool MemoryWriteExclusive128(u64 vaddr, u128 value, u128) override {
return WriteMemory<u128>(vaddr, value);
}
void CallSVC(u32 swi) override;
void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override;
void InterpreterFallback(u64 pc, size_t num_instructions) override;
void AddTicks(u64 ticks) override {}
u64 GetTicksRemaining() override {
return std::numeric_limits<u32>::max();
}
u64 GetCNTPCT() override {
return 0;
}
template <class T>
T ReadMemory(u64 vaddr) {
T ret{};
if (boost::icl::contains(mapped_ranges, vaddr)) {
memory.ReadBlock(vaddr, &ret, sizeof(T));
} else if (vaddr + sizeof(T) > local_memory.size()) {
LOG_CRITICAL(Service_JIT, "plugin: unmapped read @ 0x{:016x}", vaddr);
} else {
std::memcpy(&ret, local_memory.data() + vaddr, sizeof(T));
}
return ret;
}
template <class T>
bool WriteMemory(u64 vaddr, const T value) {
if (boost::icl::contains(mapped_ranges, vaddr)) {
memory.WriteBlock(vaddr, &value, sizeof(T));
} else if (vaddr + sizeof(T) > local_memory.size()) {
LOG_CRITICAL(Service_JIT, "plugin: unmapped write @ 0x{:016x}", vaddr);
} else {
std::memcpy(local_memory.data() + vaddr, &value, sizeof(T));
}
return true;
}
private:
Core::Memory::Memory& memory;
std::vector<u8>& local_memory;
IntervalSet& mapped_ranges;
JITContextImpl& parent;
};
class JITContextImpl {
public:
explicit JITContextImpl(Core::Memory::Memory& memory_) : memory{memory_} {
callbacks =
std::make_unique<DynarmicCallbacks64>(memory, local_memory, mapped_ranges, *this);
user_config.callbacks = callbacks.get();
jit = std::make_unique<Dynarmic::A64::Jit>(user_config);
}
bool LoadNRO(std::span<const u8> data) {
local_memory.clear();
local_memory.insert(local_memory.end(), data.begin(), data.end());
if (FixupRelocations()) {
InsertHelperFunctions();
InsertStack();
return true;
} else {
return false;
}
}
bool FixupRelocations() {
const VAddr mod_offset{callbacks->MemoryRead32(4)};
if (callbacks->MemoryRead32(mod_offset) != Common::MakeMagic('M', 'O', 'D', '0')) {
return false;
}
VAddr dynamic_offset{mod_offset + callbacks->MemoryRead32(mod_offset + 4)};
VAddr rela_dyn = 0;
size_t num_rela = 0;
while (true) {
const auto dyn{callbacks->ReadMemory<Elf64_Dyn>(dynamic_offset)};
dynamic_offset += sizeof(Elf64_Dyn);
if (!dyn.d_tag) {
break;
}
if (dyn.d_tag == DT_RELA) {
rela_dyn = dyn.d_un;
}
if (dyn.d_tag == DT_RELASZ) {
num_rela = dyn.d_un / sizeof(Elf64_Rela);
}
}
for (size_t i = 0; i < num_rela; i++) {
const auto rela{callbacks->ReadMemory<Elf64_Rela>(rela_dyn + i * sizeof(Elf64_Rela))};
if (Elf64_RelaType(&rela) != R_AARCH64_RELATIVE) {
continue;
}
const VAddr contents{callbacks->MemoryRead64(rela.r_offset)};
callbacks->MemoryWrite64(rela.r_offset, contents + rela.r_addend);
}
return true;
}
void InsertHelperFunctions() {
for (const auto& [name, contents] : HELPER_FUNCTIONS) {
helpers[name] = local_memory.size();
local_memory.insert(local_memory.end(), contents.begin(), contents.end());
}
}
void InsertStack() {
const u64 pad_amount{Common::AlignUp(local_memory.size(), STACK_ALIGN) -
local_memory.size()};
local_memory.insert(local_memory.end(), 0x10000 + pad_amount, 0);
top_of_stack = local_memory.size();
heap_pointer = top_of_stack;
}
void MapProcessMemory(VAddr dest_address, std::size_t size) {
mapped_ranges.add(IntervalType{dest_address, dest_address + size});
}
void PushArgument(const void* data, size_t size) {
const size_t num_words = Common::DivCeil(size, sizeof(u64));
const size_t current_pos = argument_stack.size();
argument_stack.insert(argument_stack.end(), num_words, 0);
std::memcpy(argument_stack.data() + current_pos, data, size);
}
void SetupArguments() {
for (size_t i = 0; i < 8 && i < argument_stack.size(); i++) {
jit->SetRegister(i, argument_stack[i]);
}
if (argument_stack.size() > 8) {
const VAddr new_sp = Common::AlignDown(
top_of_stack - (argument_stack.size() - 8) * sizeof(u64), STACK_ALIGN);
for (size_t i = 8; i < argument_stack.size(); i++) {
callbacks->MemoryWrite64(new_sp + (i - 8) * sizeof(u64), argument_stack[i]);
}
jit->SetSP(new_sp);
}
argument_stack.clear();
heap_pointer = top_of_stack;
}
u64 CallFunction(VAddr func) {
jit->SetRegister(30, helpers["_stop"]);
jit->SetSP(top_of_stack);
SetupArguments();
jit->SetPC(func);
jit->Run();
return jit->GetRegister(0);
}
VAddr GetHelper(const std::string& name) {
return helpers[name];
}
VAddr AddHeap(const void* data, size_t size) {
const size_t num_bytes{Common::AlignUp(size, STACK_ALIGN)};
if (heap_pointer + num_bytes > local_memory.size()) {
local_memory.insert(local_memory.end(),
(heap_pointer + num_bytes) - local_memory.size(), 0);
}
const VAddr location{heap_pointer};
std::memcpy(local_memory.data() + location, data, size);
heap_pointer += num_bytes;
return location;
}
void GetHeap(VAddr location, void* data, size_t size) {
std::memcpy(data, local_memory.data() + location, size);
}
std::unique_ptr<DynarmicCallbacks64> callbacks;
std::vector<u8> local_memory;
std::vector<u64> argument_stack;
IntervalSet mapped_ranges;
Dynarmic::A64::UserConfig user_config;
std::unique_ptr<Dynarmic::A64::Jit> jit;
std::map<std::string, VAddr, std::less<>> helpers;
Core::Memory::Memory& memory;
VAddr top_of_stack;
VAddr heap_pointer;
};
void DynarmicCallbacks64::CallSVC(u32 swi) {
switch (swi) {
case 0:
parent.jit->HaltExecution();
break;
case 1: {
// X0 contains a char* for a symbol to resolve
std::string name{MemoryReadCString(parent.jit->GetRegister(0))};
const auto helper{parent.helpers[name]};
if (helper != 0) {
parent.jit->SetRegister(0, helper);
} else {
LOG_WARNING(Service_JIT, "plugin requested unknown function {}", name);
parent.jit->SetRegister(0, parent.helpers["_panic"]);
}
break;
}
case 2:
default:
LOG_CRITICAL(Service_JIT, "plugin panicked!");
parent.jit->HaltExecution();
break;
}
}
void DynarmicCallbacks64::ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) {
LOG_CRITICAL(Service_JIT, "Illegal operation PC @ {:08x}", pc);
parent.jit->HaltExecution();
}
void DynarmicCallbacks64::InterpreterFallback(u64 pc, size_t num_instructions) {
LOG_CRITICAL(Service_JIT, "Unimplemented instruction PC @ {:08x}", pc);
parent.jit->HaltExecution();
}
JITContext::JITContext(Core::Memory::Memory& memory)
: impl{std::make_unique<JITContextImpl>(memory)} {}
JITContext::~JITContext() {}
bool JITContext::LoadNRO(std::span<const u8> data) {
return impl->LoadNRO(data);
}
void JITContext::MapProcessMemory(VAddr dest_address, std::size_t size) {
impl->MapProcessMemory(dest_address, size);
}
u64 JITContext::CallFunction(VAddr func) {
return impl->CallFunction(func);
}
void JITContext::PushArgument(const void* data, size_t size) {
impl->PushArgument(data, size);
}
VAddr JITContext::GetHelper(const std::string& name) {
return impl->GetHelper(name);
}
VAddr JITContext::AddHeap(const void* data, size_t size) {
return impl->AddHeap(data, size);
}
void JITContext::GetHeap(VAddr location, void* data, size_t size) {
impl->GetHeap(location, data, size);
}
} // namespace Service::JIT

View file

@ -0,0 +1,65 @@
// Copyright 2022 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <span>
#include <string>
#include "common/common_types.h"
namespace Core::Memory {
class Memory;
}
namespace Service::JIT {
class JITContextImpl;
class JITContext {
public:
explicit JITContext(Core::Memory::Memory& memory);
~JITContext();
[[nodiscard]] bool LoadNRO(std::span<const u8> data);
void MapProcessMemory(VAddr dest_address, std::size_t size);
template <typename T, typename... Ts>
u64 CallFunction(VAddr func, T argument, Ts... rest) {
static_assert(std::is_trivially_copyable_v<T>);
PushArgument(&argument, sizeof(argument));
if constexpr (sizeof...(rest) > 0) {
return CallFunction(func, rest...);
} else {
return CallFunction(func);
}
}
u64 CallFunction(VAddr func);
VAddr GetHelper(const std::string& name);
template <typename T>
VAddr AddHeap(T argument) {
return AddHeap(&argument, sizeof(argument));
}
VAddr AddHeap(const void* data, size_t size);
template <typename T>
T GetHeap(VAddr location) {
static_assert(std::is_trivially_copyable_v<T>);
T result;
GetHeap(location, &result, sizeof(result));
return result;
}
void GetHeap(VAddr location, void* data, size_t size);
private:
std::unique_ptr<JITContextImpl> impl;
void PushArgument(const void* data, size_t size);
};
} // namespace Service::JIT

View file

@ -99,9 +99,6 @@ add_executable(yuzu
configuration/configure_profile_manager.cpp
configuration/configure_profile_manager.h
configuration/configure_profile_manager.ui
configuration/configure_ringcon.cpp
configuration/configure_ringcon.h
configuration/configure_ringcon.ui
configuration/configure_network.cpp
configuration/configure_network.h
configuration/configure_network.ui

View file

@ -60,11 +60,6 @@ const std::array<int, 2> Config::default_stick_mod = {
0,
};
const std::array<int, 2> Config::default_ringcon_analogs{{
Qt::Key_A,
Qt::Key_D,
}};
// This shouldn't have anything except static initializers (no functions). So
// QKeySequence(...).toString() is NOT ALLOWED HERE.
// This must be in alphabetical order according to action name as it must have the same order as
@ -351,23 +346,6 @@ void Config::ReadTouchscreenValues() {
ReadSetting(QStringLiteral("touchscreen_diameter_y"), 15).toUInt();
}
void Config::ReadHidbusValues() {
Settings::values.enable_ring_controller =
ReadSetting(QStringLiteral("enable_ring_controller"), true).toBool();
const std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
0, 0, default_ringcon_analogs[0], default_ringcon_analogs[1], 0, 0.05f);
auto& ringcon_analogs = Settings::values.ringcon_analogs;
ringcon_analogs =
qt_config->value(QStringLiteral("ring_controller"), QString::fromStdString(default_param))
.toString()
.toStdString();
if (ringcon_analogs.empty()) {
ringcon_analogs = default_param;
}
}
void Config::ReadAudioValues() {
qt_config->beginGroup(QStringLiteral("Audio"));
@ -391,7 +369,6 @@ void Config::ReadControlValues() {
ReadMouseValues();
ReadTouchscreenValues();
ReadMotionTouchValues();
ReadHidbusValues();
#ifdef _WIN32
ReadBasicSetting(Settings::values.enable_raw_input);
@ -985,16 +962,6 @@ void Config::SaveMotionTouchValues() {
qt_config->endArray();
}
void Config::SaveHidbusValues() {
WriteBasicSetting(Settings::values.enable_ring_controller);
const std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
0, 0, default_ringcon_analogs[0], default_ringcon_analogs[1], 0, 0.05f);
WriteSetting(QStringLiteral("ring_controller"),
QString::fromStdString(Settings::values.ringcon_analogs),
QString::fromStdString(default_param));
}
void Config::SaveValues() {
if (global) {
SaveControlValues();
@ -1035,7 +1002,6 @@ void Config::SaveControlValues() {
SaveMouseValues();
SaveTouchscreenValues();
SaveMotionTouchValues();
SaveHidbusValues();
WriteGlobalSetting(Settings::values.use_docked_mode);
WriteGlobalSetting(Settings::values.vibration_enabled);

View file

@ -42,7 +42,6 @@ public:
static const std::array<int, Settings::NativeMotion::NumMotions> default_motions;
static const std::array<std::array<int, 4>, Settings::NativeAnalog::NumAnalogs> default_analogs;
static const std::array<int, 2> default_stick_mod;
static const std::array<int, 2> default_ringcon_analogs;
static const std::array<int, Settings::NativeMouseButton::NumMouseButtons>
default_mouse_buttons;
static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys;
@ -67,7 +66,6 @@ private:
void ReadMouseValues();
void ReadTouchscreenValues();
void ReadMotionTouchValues();
void ReadHidbusValues();
// Read functions bases off the respective config section names.
void ReadAudioValues();
@ -95,7 +93,6 @@ private:
void SaveMouseValues();
void SaveTouchscreenValues();
void SaveMotionTouchValues();
void SaveHidbusValues();
// Save functions based off the respective config section names.
void SaveAudioValues();

View file

@ -20,7 +20,6 @@
#include "yuzu/configuration/configure_input_advanced.h"
#include "yuzu/configuration/configure_input_player.h"
#include "yuzu/configuration/configure_motion_touch.h"
#include "yuzu/configuration/configure_ringcon.h"
#include "yuzu/configuration/configure_touchscreen_advanced.h"
#include "yuzu/configuration/configure_vibration.h"
#include "yuzu/configuration/input_profiles.h"
@ -159,10 +158,6 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
[this, input_subsystem] {
CallConfigureDialog<ConfigureMotionTouch>(*this, input_subsystem);
});
connect(advanced, &ConfigureInputAdvanced::CallRingControllerDialog,
[this, input_subsystem, &hid_core] {
CallConfigureDialog<ConfigureRingController>(*this, input_subsystem, hid_core);
});
connect(ui->vibrationButton, &QPushButton::clicked,
[this, &hid_core] { CallConfigureDialog<ConfigureVibration>(*this, hid_core); });

View file

@ -79,17 +79,13 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent)
&ConfigureInputAdvanced::UpdateUIEnabled);
connect(ui->touchscreen_enabled, &QCheckBox::stateChanged, this,
&ConfigureInputAdvanced::UpdateUIEnabled);
connect(ui->enable_ring_controller, &QCheckBox::stateChanged, this,
&ConfigureInputAdvanced::UpdateUIEnabled);
connect(ui->debug_configure, &QPushButton::clicked, this,
[this] { CallDebugControllerDialog(); });
connect(ui->touchscreen_advanced, &QPushButton::clicked, this,
[this] { CallTouchscreenConfigDialog(); });
connect(ui->buttonMotionTouch, &QPushButton::clicked, this,
[this] { CallMotionTouchConfigDialog(); });
connect(ui->ring_controller_configure, &QPushButton::clicked, this,
[this] { CallRingControllerDialog(); });
&ConfigureInputAdvanced::CallMotionTouchConfigDialog);
#ifndef _WIN32
ui->enable_raw_input->setVisible(false);
@ -136,7 +132,6 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
Settings::values.enable_raw_input = ui->enable_raw_input->isChecked();
Settings::values.enable_udp_controller = ui->enable_udp_controller->isChecked();
Settings::values.controller_navigation = ui->controller_navigation->isChecked();
Settings::values.enable_ring_controller = ui->enable_ring_controller->isChecked();
}
void ConfigureInputAdvanced::LoadConfiguration() {
@ -169,7 +164,6 @@ void ConfigureInputAdvanced::LoadConfiguration() {
ui->enable_raw_input->setChecked(Settings::values.enable_raw_input.GetValue());
ui->enable_udp_controller->setChecked(Settings::values.enable_udp_controller.GetValue());
ui->controller_navigation->setChecked(Settings::values.controller_navigation.GetValue());
ui->enable_ring_controller->setChecked(Settings::values.enable_ring_controller.GetValue());
UpdateUIEnabled();
}
@ -191,5 +185,4 @@ void ConfigureInputAdvanced::UpdateUIEnabled() {
ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked());
ui->mouse_panning->setEnabled(!ui->mouse_enabled->isChecked());
ui->mouse_panning_sensitivity->setEnabled(!ui->mouse_enabled->isChecked());
ui->ring_controller_configure->setEnabled(ui->enable_ring_controller->isChecked());
}

View file

@ -29,7 +29,6 @@ signals:
void CallMouseConfigDialog();
void CallTouchscreenConfigDialog();
void CallMotionTouchConfigDialog();
void CallRingControllerDialog();
private:
void changeEvent(QEvent* event) override;

View file

@ -2603,20 +2603,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="enable_ring_controller">
<property name="text">
<string>Ring Controller</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="ring_controller_configure">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -1407,10 +1407,10 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) {
}
void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
event->ignore();
if (!input_setter || !event) {
return;
}
event->ignore();
if (event->key() != Qt::Key_Escape) {
input_subsystem->GetKeyboard()->PressKey(event->key());
}