summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-12-28 22:21:12 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-01-20 01:05:22 +0100
commit459fb2b21337bae60194a2a99ce68c87aaed522d (patch)
treea7522832fa60f283e076df34c85380c5d4bc49d3 /src/core
parentyuzu: Add ring controller test button (diff)
downloadyuzu-459fb2b21337bae60194a2a99ce68c87aaed522d.tar
yuzu-459fb2b21337bae60194a2a99ce68c87aaed522d.tar.gz
yuzu-459fb2b21337bae60194a2a99ce68c87aaed522d.tar.bz2
yuzu-459fb2b21337bae60194a2a99ce68c87aaed522d.tar.lz
yuzu-459fb2b21337bae60194a2a99ce68c87aaed522d.tar.xz
yuzu-459fb2b21337bae60194a2a99ce68c87aaed522d.tar.zst
yuzu-459fb2b21337bae60194a2a99ce68c87aaed522d.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hid/emulated_controller.cpp21
-rw-r--r--src/core/hid/emulated_controller.h5
-rw-r--r--src/core/hle/service/hid/irs.cpp11
3 files changed, 28 insertions, 9 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 915ffa490..faf9e7c4e 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -145,7 +145,9 @@ void EmulatedController::LoadDevices() {
battery_params[LeftIndex].Set("battery", true);
battery_params[RightIndex].Set("battery", true);
- camera_params = Common::ParamPackage{"engine:camera,camera:1"};
+ camera_params[0] = right_joycon;
+ camera_params[0].Set("camera", true);
+ camera_params[1] = Common::ParamPackage{"engine:camera,camera:1"};
ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"};
nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"};
nfc_params[1] = right_joycon;
@@ -153,7 +155,7 @@ void EmulatedController::LoadDevices() {
output_params[LeftIndex] = left_joycon;
output_params[RightIndex] = right_joycon;
- output_params[2] = camera_params;
+ output_params[2] = camera_params[1];
output_params[3] = nfc_params[0];
output_params[LeftIndex].Set("output", true);
output_params[RightIndex].Set("output", true);
@@ -171,7 +173,7 @@ void EmulatedController::LoadDevices() {
std::ranges::transform(battery_params, battery_devices.begin(),
Common::Input::CreateInputDevice);
std::ranges::transform(color_params, color_devices.begin(), Common::Input::CreateInputDevice);
- camera_devices = Common::Input::CreateInputDevice(camera_params);
+ std::ranges::transform(camera_params, camera_devices.begin(), Common::Input::CreateInputDevice);
std::ranges::transform(ring_params, ring_analog_devices.begin(),
Common::Input::CreateInputDevice);
std::ranges::transform(nfc_params, nfc_devices.begin(), Common::Input::CreateInputDevice);
@@ -362,12 +364,15 @@ void EmulatedController::ReloadInput() {
motion_devices[index]->ForceUpdate();
}
- if (camera_devices) {
- camera_devices->SetCallback({
+ for (std::size_t index = 0; index < camera_devices.size(); ++index) {
+ if (!camera_devices[index]) {
+ continue;
+ }
+ camera_devices[index]->SetCallback({
.on_change =
[this](const Common::Input::CallbackStatus& callback) { SetCamera(callback); },
});
- camera_devices->ForceUpdate();
+ camera_devices[index]->ForceUpdate();
}
for (std::size_t index = 0; index < ring_analog_devices.size(); ++index) {
@@ -477,7 +482,9 @@ void EmulatedController::UnloadInput() {
for (auto& stick : virtual_stick_devices) {
stick.reset();
}
- camera_devices.reset();
+ for (auto& camera : camera_devices) {
+ camera.reset();
+ }
for (auto& ring : ring_analog_devices) {
ring.reset();
}
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index fb931fc0a..edebfc15c 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -39,7 +39,8 @@ using ColorDevices =
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
using BatteryDevices =
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
-using CameraDevices = std::unique_ptr<Common::Input::InputDevice>;
+using CameraDevices =
+ std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
using RingAnalogDevices =
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
using NfcDevices =
@@ -52,7 +53,7 @@ using ControllerMotionParams = std::array<Common::ParamPackage, Settings::Native
using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>;
using ColorParams = std::array<Common::ParamPackage, max_emulated_controllers>;
using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>;
-using CameraParams = Common::ParamPackage;
+using CameraParams = std::array<Common::ParamPackage, max_emulated_controllers>;
using RingAnalogParams = std::array<Common::ParamPackage, max_emulated_controllers>;
using NfcParams = std::array<Common::ParamPackage, max_emulated_controllers>;
using OutputParams = std::array<Common::ParamPackage, output_devices_size>;
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp
index 6a3453457..3c1fa2274 100644
--- a/src/core/hle/service/hid/irs.cpp
+++ b/src/core/hle/service/hid/irs.cpp
@@ -74,6 +74,8 @@ void IRS::DeactivateIrsensor(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",
applet_resource_user_id);
+ npad_device->SetPollingMode(Common::Input::PollingMode::Active);
+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
@@ -108,6 +110,7 @@ void IRS::StopImageProcessor(Kernel::HLERequestContext& ctx) {
auto result = IsIrCameraHandleValid(parameters.camera_handle);
if (result.IsSuccess()) {
// TODO: Stop Image processor
+ npad_device->SetPollingMode(Common::Input::PollingMode::Active);
result = ResultSuccess;
}
@@ -139,6 +142,7 @@ void IRS::RunMomentProcessor(Kernel::HLERequestContext& ctx) {
MakeProcessor<MomentProcessor>(parameters.camera_handle, device);
auto& image_transfer_processor = GetProcessor<MomentProcessor>(parameters.camera_handle);
image_transfer_processor.SetConfig(parameters.processor_config);
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -170,6 +174,7 @@ void IRS::RunClusteringProcessor(Kernel::HLERequestContext& ctx) {
auto& image_transfer_processor =
GetProcessor<ClusteringProcessor>(parameters.camera_handle);
image_transfer_processor.SetConfig(parameters.processor_config);
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -219,6 +224,7 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) {
GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
image_transfer_processor.SetConfig(parameters.processor_config);
image_transfer_processor.SetTransferMemoryPointer(transfer_memory);
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -294,6 +300,7 @@ void IRS::RunTeraPluginProcessor(Kernel::HLERequestContext& ctx) {
auto& image_transfer_processor =
GetProcessor<TeraPluginProcessor>(parameters.camera_handle);
image_transfer_processor.SetConfig(parameters.processor_config);
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -343,6 +350,7 @@ void IRS::RunPointingProcessor(Kernel::HLERequestContext& ctx) {
MakeProcessor<PointingProcessor>(camera_handle, device);
auto& image_transfer_processor = GetProcessor<PointingProcessor>(camera_handle);
image_transfer_processor.SetConfig(processor_config);
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -453,6 +461,7 @@ void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) {
GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
image_transfer_processor.SetConfig(parameters.processor_config);
image_transfer_processor.SetTransferMemoryPointer(transfer_memory);
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -479,6 +488,7 @@ void IRS::RunIrLedProcessor(Kernel::HLERequestContext& ctx) {
MakeProcessor<IrLedProcessor>(camera_handle, device);
auto& image_transfer_processor = GetProcessor<IrLedProcessor>(camera_handle);
image_transfer_processor.SetConfig(processor_config);
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -504,6 +514,7 @@ void IRS::StopImageProcessorAsync(Kernel::HLERequestContext& ctx) {
auto result = IsIrCameraHandleValid(parameters.camera_handle);
if (result.IsSuccess()) {
// TODO: Stop image processor async
+ npad_device->SetPollingMode(Common::Input::PollingMode::IR);
result = ResultSuccess;
}