early-access version 2659

This commit is contained in:
pineappleEA 2022-04-07 21:06:49 +02:00
parent af9d4874e5
commit eebb1e910d
18 changed files with 231 additions and 69 deletions

View file

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

View file

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

View file

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

View file

@ -432,6 +432,8 @@ add_library(core STATIC
hle/service/grc/grc.h hle/service/grc/grc.h
hle/service/hid/hid.cpp hle/service/hid/hid.cpp
hle/service/hid/hid.h hle/service/hid/hid.h
hle/service/hid/hidbus.cpp
hle/service/hid/hidbus.h
hle/service/hid/irs.cpp hle/service/hid/irs.cpp
hle/service/hid/irs.h hle/service/hid/irs.h
hle/service/hid/ring_lifo.h hle/service/hid/ring_lifo.h
@ -458,6 +460,14 @@ add_library(core STATIC
hle/service/hid/controllers/touchscreen.h hle/service/hid/controllers/touchscreen.h
hle/service/hid/controllers/xpad.cpp hle/service/hid/controllers/xpad.cpp
hle/service/hid/controllers/xpad.h 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.cpp hle/service/jit/jit.cpp
hle/service/jit/jit.h hle/service/jit/jit.h
hle/service/lbl/lbl.cpp hle/service/lbl/lbl.cpp

View file

@ -998,36 +998,38 @@ void EmulatedController::Connect(bool use_temporary_value) {
LOG_ERROR(Service_HID, "Controller type {} is not supported", type); LOG_ERROR(Service_HID, "Controller type {} is not supported", type);
return; return;
} }
{
std::lock_guard lock{mutex};
if (is_configuring) {
tmp_is_connected = true;
TriggerOnChange(ControllerTriggerType::Connected, false);
return;
}
if (is_connected) { std::unique_lock lock{mutex};
return; if (is_configuring) {
} tmp_is_connected = true;
is_connected = true; TriggerOnChange(ControllerTriggerType::Connected, false);
return;
} }
if (is_connected) {
return;
}
is_connected = true;
lock.unlock();
TriggerOnChange(ControllerTriggerType::Connected, true); TriggerOnChange(ControllerTriggerType::Connected, true);
} }
void EmulatedController::Disconnect() { void EmulatedController::Disconnect() {
{ std::unique_lock lock{mutex};
std::lock_guard lock{mutex}; if (is_configuring) {
if (is_configuring) { tmp_is_connected = false;
tmp_is_connected = false; lock.unlock();
TriggerOnChange(ControllerTriggerType::Disconnected, false); TriggerOnChange(ControllerTriggerType::Disconnected, false);
return; return;
}
if (!is_connected) {
return;
}
is_connected = false;
} }
if (!is_connected) {
return;
}
is_connected = false;
lock.unlock();
TriggerOnChange(ControllerTriggerType::Disconnected, true); TriggerOnChange(ControllerTriggerType::Disconnected, true);
} }
@ -1059,27 +1061,28 @@ NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) c
} }
void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) { void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) {
{ std::unique_lock lock{mutex};
std::lock_guard lock{mutex};
if (is_configuring) { if (is_configuring) {
if (tmp_npad_type == npad_type_) { if (tmp_npad_type == npad_type_) {
return;
}
tmp_npad_type = npad_type_;
TriggerOnChange(ControllerTriggerType::Type, false);
return; return;
} }
tmp_npad_type = npad_type_;
if (npad_type == npad_type_) { lock.unlock();
return; TriggerOnChange(ControllerTriggerType::Type, false);
} return;
if (is_connected) {
LOG_WARNING(Service_HID, "Controller {} type changed while it's connected",
NpadIdTypeToIndex(npad_id_type));
}
npad_type = npad_type_;
} }
if (npad_type == npad_type_) {
return;
}
if (is_connected) {
LOG_WARNING(Service_HID, "Controller {} type changed while it's connected",
NpadIdTypeToIndex(npad_id_type));
}
npad_type = npad_type_;
lock.unlock();
TriggerOnChange(ControllerTriggerType::Type, true); TriggerOnChange(ControllerTriggerType::Type, true);
} }

View file

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

View file

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

View file

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

View file

@ -264,6 +264,12 @@ public:
/// Gets the shared memory object for Time services. /// Gets the shared memory object for Time services.
const Kernel::KSharedMemory& GetTimeSharedMem() const; 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. /// Suspend/unsuspend the OS.
void Suspend(bool in_suspention); void Suspend(bool in_suspention);

View file

@ -16,6 +16,7 @@
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/service/hid/errors.h" #include "core/hle/service/hid/errors.h"
#include "core/hle/service/hid/hid.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/irs.h"
#include "core/hle/service/hid/xcd.h" #include "core/hle/service/hid/xcd.h"
#include "core/memory.h" #include "core/memory.h"
@ -2128,32 +2129,6 @@ 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) { void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
std::make_shared<Hid>(system)->InstallAsService(service_manager); std::make_shared<Hid>(system)->InstallAsService(service_manager);
std::make_shared<HidBus>(system)->InstallAsService(service_manager); std::make_shared<HidBus>(system)->InstallAsService(service_manager);

View file

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

View file

@ -60,6 +60,11 @@ const std::array<int, 2> Config::default_stick_mod = {
0, 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 // This shouldn't have anything except static initializers (no functions). So
// QKeySequence(...).toString() is NOT ALLOWED HERE. // QKeySequence(...).toString() is NOT ALLOWED HERE.
// This must be in alphabetical order according to action name as it must have the same order as // This must be in alphabetical order according to action name as it must have the same order as
@ -346,6 +351,23 @@ void Config::ReadTouchscreenValues() {
ReadSetting(QStringLiteral("touchscreen_diameter_y"), 15).toUInt(); 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() { void Config::ReadAudioValues() {
qt_config->beginGroup(QStringLiteral("Audio")); qt_config->beginGroup(QStringLiteral("Audio"));
@ -369,6 +391,7 @@ void Config::ReadControlValues() {
ReadMouseValues(); ReadMouseValues();
ReadTouchscreenValues(); ReadTouchscreenValues();
ReadMotionTouchValues(); ReadMotionTouchValues();
ReadHidbusValues();
#ifdef _WIN32 #ifdef _WIN32
ReadBasicSetting(Settings::values.enable_raw_input); ReadBasicSetting(Settings::values.enable_raw_input);
@ -962,6 +985,16 @@ void Config::SaveMotionTouchValues() {
qt_config->endArray(); 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() { void Config::SaveValues() {
if (global) { if (global) {
SaveControlValues(); SaveControlValues();
@ -1002,6 +1035,7 @@ void Config::SaveControlValues() {
SaveMouseValues(); SaveMouseValues();
SaveTouchscreenValues(); SaveTouchscreenValues();
SaveMotionTouchValues(); SaveMotionTouchValues();
SaveHidbusValues();
WriteGlobalSetting(Settings::values.use_docked_mode); WriteGlobalSetting(Settings::values.use_docked_mode);
WriteGlobalSetting(Settings::values.vibration_enabled); WriteGlobalSetting(Settings::values.vibration_enabled);

View file

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

View file

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

View file

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

View file

@ -2603,6 +2603,20 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
</item> </item>

View file

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