forked from suyu/suyu
core: hid: Fix input regressions
This commit is contained in:
parent
6d6b7bdbc3
commit
1c08d532e0
6 changed files with 56 additions and 41 deletions
|
@ -107,6 +107,8 @@ void EmulatedController::ReloadFromSettings() {
|
||||||
.button = GetNpadColor(player.button_color_right),
|
.button = GetNpadColor(player.button_color_right),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
|
||||||
|
|
||||||
// Other or debug controller should always be a pro controller
|
// Other or debug controller should always be a pro controller
|
||||||
if (npad_id_type != NpadIdType::Other) {
|
if (npad_id_type != NpadIdType::Other) {
|
||||||
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
||||||
|
@ -144,14 +146,15 @@ void EmulatedController::LoadDevices() {
|
||||||
battery_params[RightIndex].Set("battery", true);
|
battery_params[RightIndex].Set("battery", true);
|
||||||
|
|
||||||
camera_params = Common::ParamPackage{"engine:camera,camera:1"};
|
camera_params = Common::ParamPackage{"engine:camera,camera:1"};
|
||||||
nfc_params = right_joycon;
|
ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"};
|
||||||
nfc_params.Set("nfc", true);
|
nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"};
|
||||||
ring_params = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"};
|
nfc_params[1] = right_joycon;
|
||||||
|
nfc_params[1].Set("nfc", true);
|
||||||
|
|
||||||
output_params[LeftIndex] = left_joycon;
|
output_params[LeftIndex] = left_joycon;
|
||||||
output_params[RightIndex] = right_joycon;
|
output_params[RightIndex] = right_joycon;
|
||||||
output_params[2] = camera_params;
|
output_params[2] = camera_params;
|
||||||
output_params[3] = nfc_params;
|
output_params[3] = nfc_params[0];
|
||||||
output_params[LeftIndex].Set("output", true);
|
output_params[LeftIndex].Set("output", true);
|
||||||
output_params[RightIndex].Set("output", true);
|
output_params[RightIndex].Set("output", true);
|
||||||
output_params[2].Set("output", true);
|
output_params[2].Set("output", true);
|
||||||
|
@ -169,8 +172,9 @@ void EmulatedController::LoadDevices() {
|
||||||
Common::Input::CreateInputDevice);
|
Common::Input::CreateInputDevice);
|
||||||
std::ranges::transform(color_params, color_devices.begin(), Common::Input::CreateInputDevice);
|
std::ranges::transform(color_params, color_devices.begin(), Common::Input::CreateInputDevice);
|
||||||
camera_devices = Common::Input::CreateInputDevice(camera_params);
|
camera_devices = Common::Input::CreateInputDevice(camera_params);
|
||||||
ring_analog_device = Common::Input::CreateInputDevice(ring_params);
|
std::ranges::transform(ring_params, ring_analog_devices.begin(),
|
||||||
nfc_devices = Common::Input::CreateInputDevice(nfc_params);
|
Common::Input::CreateInputDevice);
|
||||||
|
std::ranges::transform(nfc_params, nfc_devices.begin(), Common::Input::CreateInputDevice);
|
||||||
std::ranges::transform(output_params, output_devices.begin(),
|
std::ranges::transform(output_params, output_devices.begin(),
|
||||||
Common::Input::CreateOutputDevice);
|
Common::Input::CreateOutputDevice);
|
||||||
|
|
||||||
|
@ -366,21 +370,26 @@ void EmulatedController::ReloadInput() {
|
||||||
camera_devices->ForceUpdate();
|
camera_devices->ForceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ring_analog_device) {
|
for (std::size_t index = 0; index < ring_analog_devices.size(); ++index) {
|
||||||
ring_analog_device->SetCallback({
|
if (!ring_analog_devices[index]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ring_analog_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); },
|
[this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); },
|
||||||
});
|
});
|
||||||
|
ring_analog_devices[index]->ForceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nfc_devices) {
|
for (std::size_t index = 0; index < nfc_devices.size(); ++index) {
|
||||||
if (npad_id_type == NpadIdType::Handheld || npad_id_type == NpadIdType::Player1) {
|
if (!nfc_devices[index]) {
|
||||||
nfc_devices->SetCallback({
|
continue;
|
||||||
.on_change =
|
|
||||||
[this](const Common::Input::CallbackStatus& callback) { SetNfc(callback); },
|
|
||||||
});
|
|
||||||
nfc_devices->ForceUpdate();
|
|
||||||
}
|
}
|
||||||
|
nfc_devices[index]->SetCallback({
|
||||||
|
.on_change =
|
||||||
|
[this](const Common::Input::CallbackStatus& callback) { SetNfc(callback); },
|
||||||
|
});
|
||||||
|
nfc_devices[index]->ForceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register TAS devices. No need to force update
|
// Register TAS devices. No need to force update
|
||||||
|
@ -469,8 +478,12 @@ void EmulatedController::UnloadInput() {
|
||||||
stick.reset();
|
stick.reset();
|
||||||
}
|
}
|
||||||
camera_devices.reset();
|
camera_devices.reset();
|
||||||
ring_analog_device.reset();
|
for (auto& ring : ring_analog_devices) {
|
||||||
nfc_devices.reset();
|
ring.reset();
|
||||||
|
}
|
||||||
|
for (auto& nfc : nfc_devices) {
|
||||||
|
nfc.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::EnableConfiguration() {
|
void EmulatedController::EnableConfiguration() {
|
||||||
|
@ -540,7 +553,9 @@ void EmulatedController::SaveCurrentConfig() {
|
||||||
for (std::size_t index = 0; index < player.motions.size(); ++index) {
|
for (std::size_t index = 0; index < player.motions.size(); ++index) {
|
||||||
player.motions[index] = motion_params[index].Serialize();
|
player.motions[index] = motion_params[index].Serialize();
|
||||||
}
|
}
|
||||||
Settings::values.ringcon_analogs = ring_params.Serialize();
|
if (npad_id_type == NpadIdType::Player1) {
|
||||||
|
Settings::values.ringcon_analogs = ring_params[0].Serialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::RestoreConfig() {
|
void EmulatedController::RestoreConfig() {
|
||||||
|
@ -1215,11 +1230,11 @@ bool EmulatedController::SetCameraFormat(
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ParamPackage EmulatedController::GetRingParam() const {
|
Common::ParamPackage EmulatedController::GetRingParam() const {
|
||||||
return ring_params;
|
return ring_params[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetRingParam(Common::ParamPackage param) {
|
void EmulatedController::SetRingParam(Common::ParamPackage param) {
|
||||||
ring_params = std::move(param);
|
ring_params[0] = std::move(param);
|
||||||
ReloadInput();
|
ReloadInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,10 @@ using ColorDevices =
|
||||||
using BatteryDevices =
|
using BatteryDevices =
|
||||||
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
|
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
|
||||||
using CameraDevices = std::unique_ptr<Common::Input::InputDevice>;
|
using CameraDevices = std::unique_ptr<Common::Input::InputDevice>;
|
||||||
using RingAnalogDevice = std::unique_ptr<Common::Input::InputDevice>;
|
using RingAnalogDevices =
|
||||||
using NfcDevices = std::unique_ptr<Common::Input::InputDevice>;
|
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
|
||||||
|
using NfcDevices =
|
||||||
|
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
|
||||||
using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>;
|
using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>;
|
||||||
|
|
||||||
using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>;
|
using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>;
|
||||||
|
@ -51,8 +53,8 @@ using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::
|
||||||
using ColorParams = std::array<Common::ParamPackage, max_emulated_controllers>;
|
using ColorParams = std::array<Common::ParamPackage, max_emulated_controllers>;
|
||||||
using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>;
|
using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>;
|
||||||
using CameraParams = Common::ParamPackage;
|
using CameraParams = Common::ParamPackage;
|
||||||
using RingAnalogParams = Common::ParamPackage;
|
using RingAnalogParams = std::array<Common::ParamPackage, max_emulated_controllers>;
|
||||||
using NfcParams = Common::ParamPackage;
|
using NfcParams = std::array<Common::ParamPackage, max_emulated_controllers>;
|
||||||
using OutputParams = std::array<Common::ParamPackage, output_devices_size>;
|
using OutputParams = std::array<Common::ParamPackage, output_devices_size>;
|
||||||
|
|
||||||
using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>;
|
using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>;
|
||||||
|
@ -538,7 +540,7 @@ private:
|
||||||
BatteryDevices battery_devices;
|
BatteryDevices battery_devices;
|
||||||
ColorDevices color_devices;
|
ColorDevices color_devices;
|
||||||
CameraDevices camera_devices;
|
CameraDevices camera_devices;
|
||||||
RingAnalogDevice ring_analog_device;
|
RingAnalogDevices ring_analog_devices;
|
||||||
NfcDevices nfc_devices;
|
NfcDevices nfc_devices;
|
||||||
OutputDevices output_devices;
|
OutputDevices output_devices;
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,7 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||||
controller.is_connected = true;
|
controller.is_connected = true;
|
||||||
controller.device->Connect();
|
controller.device->Connect();
|
||||||
controller.device->SetLedPattern();
|
controller.device->SetLedPattern();
|
||||||
|
controller.device->SetPollingMode(Common::Input::PollingMode::Active);
|
||||||
SignalStyleSetChangedEvent(npad_id);
|
SignalStyleSetChangedEvent(npad_id);
|
||||||
WriteEmptyEntry(controller.shared_memory);
|
WriteEmptyEntry(controller.shared_memory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,13 +297,13 @@ void HidBus::EnableExternalDevice(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
||||||
const auto parameters{rp.PopRaw<Parameters>()};
|
const auto parameters{rp.PopRaw<Parameters>()};
|
||||||
|
|
||||||
LOG_INFO(Service_HID,
|
LOG_DEBUG(Service_HID,
|
||||||
"called, enable={}, abstracted_pad_id={}, bus_type={}, internal_index={}, "
|
"called, enable={}, abstracted_pad_id={}, bus_type={}, internal_index={}, "
|
||||||
"player_number={}, is_valid={}, inval={}, applet_resource_user_id{}",
|
"player_number={}, is_valid={}, inval={}, applet_resource_user_id{}",
|
||||||
parameters.enable, parameters.bus_handle.abstracted_pad_id,
|
parameters.enable, parameters.bus_handle.abstracted_pad_id,
|
||||||
parameters.bus_handle.bus_type, parameters.bus_handle.internal_index,
|
parameters.bus_handle.bus_type, parameters.bus_handle.internal_index,
|
||||||
parameters.bus_handle.player_number, parameters.bus_handle.is_valid, parameters.inval,
|
parameters.bus_handle.player_number, parameters.bus_handle.is_valid, parameters.inval,
|
||||||
parameters.applet_resource_user_id);
|
parameters.applet_resource_user_id);
|
||||||
|
|
||||||
const auto device_index = GetDeviceIndexFromHandle(parameters.bus_handle);
|
const auto device_index = GetDeviceIndexFromHandle(parameters.bus_handle);
|
||||||
|
|
||||||
|
@ -326,11 +326,11 @@ void HidBus::GetExternalDeviceId(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto bus_handle_{rp.PopRaw<BusHandle>()};
|
const auto bus_handle_{rp.PopRaw<BusHandle>()};
|
||||||
|
|
||||||
LOG_INFO(Service_HID,
|
LOG_DEBUG(Service_HID,
|
||||||
"called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, "
|
"called, abstracted_pad_id={}, bus_type={}, internal_index={}, player_number={}, "
|
||||||
"is_valid={}",
|
"is_valid={}",
|
||||||
bus_handle_.abstracted_pad_id, bus_handle_.bus_type, bus_handle_.internal_index,
|
bus_handle_.abstracted_pad_id, bus_handle_.bus_type, bus_handle_.internal_index,
|
||||||
bus_handle_.player_number, bus_handle_.is_valid);
|
bus_handle_.player_number, bus_handle_.is_valid);
|
||||||
|
|
||||||
const auto device_index = GetDeviceIndexFromHandle(bus_handle_);
|
const auto device_index = GetDeviceIndexFromHandle(bus_handle_);
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,7 @@ DriverResult JoyconDriver::SetActiveMode() {
|
||||||
|
|
||||||
DriverResult JoyconDriver::SetNfcMode() {
|
DriverResult JoyconDriver::SetNfcMode() {
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{mutex};
|
||||||
motion_enabled = false;
|
motion_enabled = true;
|
||||||
hidbus_enabled = false;
|
hidbus_enabled = false;
|
||||||
nfc_enabled = true;
|
nfc_enabled = true;
|
||||||
passive_enabled = false;
|
passive_enabled = false;
|
||||||
|
|
|
@ -55,9 +55,6 @@ DriverResult RingConProtocol::StartRingconPolling() {
|
||||||
DriverResult result{DriverResult::Success};
|
DriverResult result{DriverResult::Success};
|
||||||
SetBlocking();
|
SetBlocking();
|
||||||
|
|
||||||
if (result == DriverResult::Success) {
|
|
||||||
result = WaitSetMCUMode(ReportMode::STANDARD_FULL_60HZ, MCUMode::Standby);
|
|
||||||
}
|
|
||||||
if (result == DriverResult::Success) {
|
if (result == DriverResult::Success) {
|
||||||
result = IsRingConnected(is_connected);
|
result = IsRingConnected(is_connected);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue