early-access version 3244
This commit is contained in:
@@ -88,6 +88,7 @@ void EmulatedController::ReloadFromSettings() {
|
||||
motion_params[index] = Common::ParamPackage(player.motions[index]);
|
||||
}
|
||||
|
||||
controller.color_values = {};
|
||||
controller.colors_state.fullkey = {
|
||||
.body = GetNpadColor(player.body_color_left),
|
||||
.button = GetNpadColor(player.button_color_left),
|
||||
@@ -101,6 +102,8 @@ void EmulatedController::ReloadFromSettings() {
|
||||
.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
|
||||
if (npad_id_type != NpadIdType::Other) {
|
||||
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
||||
@@ -127,18 +130,26 @@ void EmulatedController::LoadDevices() {
|
||||
trigger_params[LeftIndex] = button_params[Settings::NativeButton::ZL];
|
||||
trigger_params[RightIndex] = button_params[Settings::NativeButton::ZR];
|
||||
|
||||
color_params[LeftIndex] = left_joycon;
|
||||
color_params[RightIndex] = right_joycon;
|
||||
color_params[LeftIndex].Set("color", true);
|
||||
color_params[RightIndex].Set("color", true);
|
||||
|
||||
battery_params[LeftIndex] = left_joycon;
|
||||
battery_params[RightIndex] = right_joycon;
|
||||
battery_params[LeftIndex].Set("battery", true);
|
||||
battery_params[RightIndex].Set("battery", true);
|
||||
|
||||
camera_params = Common::ParamPackage{"engine:camera,camera:1"};
|
||||
nfc_params = Common::ParamPackage{"engine:virtual_amiibo,nfc: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;
|
||||
nfc_params[1].Set("nfc", true);
|
||||
|
||||
output_params[LeftIndex] = left_joycon;
|
||||
output_params[RightIndex] = right_joycon;
|
||||
output_params[2] = camera_params;
|
||||
output_params[3] = nfc_params;
|
||||
output_params[3] = nfc_params[0];
|
||||
output_params[LeftIndex].Set("output", true);
|
||||
output_params[RightIndex].Set("output", true);
|
||||
output_params[2].Set("output", true);
|
||||
@@ -154,8 +165,11 @@ void EmulatedController::LoadDevices() {
|
||||
Common::Input::CreateInputDevice);
|
||||
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);
|
||||
nfc_devices = Common::Input::CreateInputDevice(nfc_params);
|
||||
std::ranges::transform(ring_params, ring_analog_devices.begin(),
|
||||
Common::Input::CreateInputDevice);
|
||||
std::ranges::transform(nfc_params, nfc_devices.begin(), Common::Input::CreateInputDevice);
|
||||
std::ranges::transform(output_params, output_devices.begin(),
|
||||
Common::Input::CreateOutputDevice);
|
||||
|
||||
@@ -310,6 +324,19 @@ void EmulatedController::ReloadInput() {
|
||||
battery_devices[index]->ForceUpdate();
|
||||
}
|
||||
|
||||
for (std::size_t index = 0; index < color_devices.size(); ++index) {
|
||||
if (!color_devices[index]) {
|
||||
continue;
|
||||
}
|
||||
color_devices[index]->SetCallback({
|
||||
.on_change =
|
||||
[this, index](const Common::Input::CallbackStatus& callback) {
|
||||
SetColors(callback, index);
|
||||
},
|
||||
});
|
||||
color_devices[index]->ForceUpdate();
|
||||
}
|
||||
|
||||
for (std::size_t index = 0; index < motion_devices.size(); ++index) {
|
||||
if (!motion_devices[index]) {
|
||||
continue;
|
||||
@@ -331,14 +358,26 @@ void EmulatedController::ReloadInput() {
|
||||
camera_devices->ForceUpdate();
|
||||
}
|
||||
|
||||
if (nfc_devices) {
|
||||
if (npad_id_type == NpadIdType::Handheld || npad_id_type == NpadIdType::Player1) {
|
||||
nfc_devices->SetCallback({
|
||||
.on_change =
|
||||
[this](const Common::Input::CallbackStatus& callback) { SetNfc(callback); },
|
||||
});
|
||||
nfc_devices->ForceUpdate();
|
||||
for (std::size_t index = 0; index < ring_analog_devices.size(); ++index) {
|
||||
if (!ring_analog_devices[index]) {
|
||||
continue;
|
||||
}
|
||||
ring_analog_devices[index]->SetCallback({
|
||||
.on_change =
|
||||
[this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); },
|
||||
});
|
||||
ring_analog_devices[index]->ForceUpdate();
|
||||
}
|
||||
|
||||
for (std::size_t index = 0; index < nfc_devices.size(); ++index) {
|
||||
if (!nfc_devices[index]) {
|
||||
continue;
|
||||
}
|
||||
nfc_devices[index]->SetCallback({
|
||||
.on_change =
|
||||
[this](const Common::Input::CallbackStatus& callback) { SetNfc(callback); },
|
||||
});
|
||||
nfc_devices[index]->ForceUpdate();
|
||||
}
|
||||
|
||||
// Use a common UUID for TAS
|
||||
@@ -416,6 +455,9 @@ void EmulatedController::UnloadInput() {
|
||||
for (auto& battery : battery_devices) {
|
||||
battery.reset();
|
||||
}
|
||||
for (auto& color : color_devices) {
|
||||
color.reset();
|
||||
}
|
||||
for (auto& output : output_devices) {
|
||||
output.reset();
|
||||
}
|
||||
@@ -432,7 +474,12 @@ void EmulatedController::UnloadInput() {
|
||||
stick.reset();
|
||||
}
|
||||
camera_devices.reset();
|
||||
nfc_devices.reset();
|
||||
for (auto& ring : ring_analog_devices) {
|
||||
ring.reset();
|
||||
}
|
||||
for (auto& nfc : nfc_devices) {
|
||||
nfc.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatedController::EnableConfiguration() {
|
||||
@@ -444,6 +491,11 @@ void EmulatedController::EnableConfiguration() {
|
||||
void EmulatedController::DisableConfiguration() {
|
||||
is_configuring = false;
|
||||
|
||||
// Get Joycon colors before turning on the controller
|
||||
for (const auto& color_device : color_devices) {
|
||||
color_device->ForceUpdate();
|
||||
}
|
||||
|
||||
// Apply temporary npad type to the real controller
|
||||
if (tmp_npad_type != npad_type) {
|
||||
if (is_connected) {
|
||||
@@ -497,6 +549,9 @@ void EmulatedController::SaveCurrentConfig() {
|
||||
for (std::size_t index = 0; index < player.motions.size(); ++index) {
|
||||
player.motions[index] = motion_params[index].Serialize();
|
||||
}
|
||||
if (npad_id_type == NpadIdType::Player1) {
|
||||
Settings::values.ringcon_analogs = ring_params[0].Serialize();
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatedController::RestoreConfig() {
|
||||
@@ -906,6 +961,58 @@ void EmulatedController::SetMotion(const Common::Input::CallbackStatus& callback
|
||||
TriggerOnChange(ControllerTriggerType::Motion, true);
|
||||
}
|
||||
|
||||
void EmulatedController::SetColors(const Common::Input::CallbackStatus& callback,
|
||||
std::size_t index) {
|
||||
if (index >= controller.color_values.size()) {
|
||||
return;
|
||||
}
|
||||
std::unique_lock lock{mutex};
|
||||
controller.color_values[index] = TransformToColor(callback);
|
||||
|
||||
if (is_configuring) {
|
||||
lock.unlock();
|
||||
TriggerOnChange(ControllerTriggerType::Color, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (controller.color_values[index].body == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
controller.colors_state.fullkey = {
|
||||
.body = GetNpadColor(controller.color_values[index].body),
|
||||
.button = GetNpadColor(controller.color_values[index].buttons),
|
||||
};
|
||||
if (npad_type == NpadStyleIndex::ProController) {
|
||||
controller.colors_state.left = {
|
||||
.body = GetNpadColor(controller.color_values[index].left_grip),
|
||||
.button = GetNpadColor(controller.color_values[index].buttons),
|
||||
};
|
||||
controller.colors_state.right = {
|
||||
.body = GetNpadColor(controller.color_values[index].right_grip),
|
||||
.button = GetNpadColor(controller.color_values[index].buttons),
|
||||
};
|
||||
} else {
|
||||
switch (index) {
|
||||
case LeftIndex:
|
||||
controller.colors_state.left = {
|
||||
.body = GetNpadColor(controller.color_values[index].body),
|
||||
.button = GetNpadColor(controller.color_values[index].buttons),
|
||||
};
|
||||
break;
|
||||
case RightIndex:
|
||||
controller.colors_state.right = {
|
||||
.body = GetNpadColor(controller.color_values[index].body),
|
||||
.button = GetNpadColor(controller.color_values[index].buttons),
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
TriggerOnChange(ControllerTriggerType::Color, true);
|
||||
}
|
||||
|
||||
void EmulatedController::SetBattery(const Common::Input::CallbackStatus& callback,
|
||||
std::size_t index) {
|
||||
if (index >= controller.battery_values.size()) {
|
||||
@@ -996,6 +1103,24 @@ void EmulatedController::SetCamera(const Common::Input::CallbackStatus& callback
|
||||
TriggerOnChange(ControllerTriggerType::IrSensor, true);
|
||||
}
|
||||
|
||||
void EmulatedController::SetRingAnalog(const Common::Input::CallbackStatus& callback) {
|
||||
std::unique_lock lock{mutex};
|
||||
const auto force_value = TransformToStick(callback);
|
||||
|
||||
controller.ring_analog_value = force_value.x;
|
||||
|
||||
if (is_configuring) {
|
||||
lock.unlock();
|
||||
TriggerOnChange(ControllerTriggerType::RingController, false);
|
||||
return;
|
||||
}
|
||||
|
||||
controller.ring_analog_state.force = force_value.x.value;
|
||||
|
||||
lock.unlock();
|
||||
TriggerOnChange(ControllerTriggerType::RingController, true);
|
||||
}
|
||||
|
||||
void EmulatedController::SetNfc(const Common::Input::CallbackStatus& callback) {
|
||||
std::unique_lock lock{mutex};
|
||||
controller.nfc_values = TransformToNfc(callback);
|
||||
@@ -1095,6 +1220,15 @@ bool EmulatedController::SetCameraFormat(
|
||||
camera_format)) == Common::Input::CameraError::None;
|
||||
}
|
||||
|
||||
Common::ParamPackage EmulatedController::GetRingParam() const {
|
||||
return ring_params[0];
|
||||
}
|
||||
|
||||
void EmulatedController::SetRingParam(Common::ParamPackage param) {
|
||||
ring_params[0] = std::move(param);
|
||||
ReloadInput();
|
||||
}
|
||||
|
||||
bool EmulatedController::HasNfc() const {
|
||||
const auto& nfc_output_device = output_devices[3];
|
||||
|
||||
@@ -1386,6 +1520,10 @@ CameraValues EmulatedController::GetCameraValues() const {
|
||||
return controller.camera_values;
|
||||
}
|
||||
|
||||
RingAnalogValue EmulatedController::GetRingSensorValues() const {
|
||||
return controller.ring_analog_value;
|
||||
}
|
||||
|
||||
HomeButtonState EmulatedController::GetHomeButtons() const {
|
||||
std::scoped_lock lock{mutex};
|
||||
if (is_configuring) {
|
||||
@@ -1479,6 +1617,10 @@ const CameraState& EmulatedController::GetCamera() const {
|
||||
return controller.camera_state;
|
||||
}
|
||||
|
||||
RingSensorForce EmulatedController::GetRingSensorForce() const {
|
||||
return controller.ring_analog_state;
|
||||
}
|
||||
|
||||
const NfcState& EmulatedController::GetNfc() const {
|
||||
std::scoped_lock lock{mutex};
|
||||
return controller.nfc_state;
|
||||
|
||||
Reference in New Issue
Block a user