summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hid/emulated_controller.cpp1
-rw-r--r--src/core/hid/motion_input.cpp4
-rw-r--r--src/input_common/input_poller.cpp13
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv.cpp12
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/video_minimum_maximum.cpp18
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp12
6 files changed, 39 insertions, 21 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index d12037b11..a7cdf45e6 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -749,6 +749,7 @@ void EmulatedController::SetMotion(const Common::Input::CallbackStatus& callback
749 raw_status.gyro.y.value, 749 raw_status.gyro.y.value,
750 raw_status.gyro.z.value, 750 raw_status.gyro.z.value,
751 }); 751 });
752 emulated.SetGyroThreshold(raw_status.gyro.x.properties.threshold);
752 emulated.UpdateRotation(raw_status.delta_timestamp); 753 emulated.UpdateRotation(raw_status.delta_timestamp);
753 emulated.UpdateOrientation(raw_status.delta_timestamp); 754 emulated.UpdateOrientation(raw_status.delta_timestamp);
754 force_update_motion = raw_status.force_update; 755 force_update_motion = raw_status.force_update;
diff --git a/src/core/hid/motion_input.cpp b/src/core/hid/motion_input.cpp
index 6e126be19..05042fd99 100644
--- a/src/core/hid/motion_input.cpp
+++ b/src/core/hid/motion_input.cpp
@@ -10,7 +10,7 @@ namespace Core::HID {
10MotionInput::MotionInput() { 10MotionInput::MotionInput() {
11 // Initialize PID constants with default values 11 // Initialize PID constants with default values
12 SetPID(0.3f, 0.005f, 0.0f); 12 SetPID(0.3f, 0.005f, 0.0f);
13 SetGyroThreshold(0.00005f); 13 SetGyroThreshold(0.007f);
14} 14}
15 15
16void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) { 16void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) {
@@ -31,7 +31,7 @@ void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) {
31 gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f); 31 gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f);
32 } 32 }
33 33
34 if (gyro.Length2() < gyro_threshold) { 34 if (gyro.Length() < gyro_threshold) {
35 gyro = {}; 35 gyro = {};
36 } else { 36 } else {
37 only_accelerometer = false; 37 only_accelerometer = false;
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index 7b370335f..2f3c0735a 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -504,9 +504,10 @@ private:
504 504
505class InputFromMotion final : public Common::Input::InputDevice { 505class InputFromMotion final : public Common::Input::InputDevice {
506public: 506public:
507 explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, 507 explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, float gyro_threshold_,
508 InputEngine* input_engine_) 508 InputEngine* input_engine_)
509 : identifier(identifier_), motion_sensor(motion_sensor_), input_engine(input_engine_) { 509 : identifier(identifier_), motion_sensor(motion_sensor_), gyro_threshold(gyro_threshold_),
510 input_engine(input_engine_) {
510 UpdateCallback engine_callback{[this]() { OnChange(); }}; 511 UpdateCallback engine_callback{[this]() { OnChange(); }};
511 const InputIdentifier input_identifier{ 512 const InputIdentifier input_identifier{
512 .identifier = identifier, 513 .identifier = identifier,
@@ -525,8 +526,9 @@ public:
525 const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); 526 const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor);
526 Common::Input::MotionStatus status{}; 527 Common::Input::MotionStatus status{};
527 const Common::Input::AnalogProperties properties = { 528 const Common::Input::AnalogProperties properties = {
528 .deadzone = 0.001f, 529 .deadzone = 0.0f,
529 .range = 1.0f, 530 .range = 1.0f,
531 .threshold = gyro_threshold,
530 .offset = 0.0f, 532 .offset = 0.0f,
531 }; 533 };
532 status.accel.x = {.raw_value = basic_motion.accel_x, .properties = properties}; 534 status.accel.x = {.raw_value = basic_motion.accel_x, .properties = properties};
@@ -551,6 +553,7 @@ public:
551private: 553private:
552 const PadIdentifier identifier; 554 const PadIdentifier identifier;
553 const int motion_sensor; 555 const int motion_sensor;
556 const float gyro_threshold;
554 int callback_key; 557 int callback_key;
555 InputEngine* input_engine; 558 InputEngine* input_engine;
556}; 559};
@@ -873,9 +876,11 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
873 876
874 if (params.Has("motion")) { 877 if (params.Has("motion")) {
875 const auto motion_sensor = params.Get("motion", 0); 878 const auto motion_sensor = params.Get("motion", 0);
879 const auto gyro_threshold = params.Get("threshold", 0.007f);
876 input_engine->PreSetController(identifier); 880 input_engine->PreSetController(identifier);
877 input_engine->PreSetMotion(identifier, motion_sensor); 881 input_engine->PreSetMotion(identifier, motion_sensor);
878 return std::make_unique<InputFromMotion>(identifier, motion_sensor, input_engine.get()); 882 return std::make_unique<InputFromMotion>(identifier, motion_sensor, gyro_threshold,
883 input_engine.get());
879 } 884 }
880 885
881 const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); 886 const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f);
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp
index 50918317f..08b3a81ce 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp
@@ -387,6 +387,14 @@ void SetupSignedNanCapabilities(const Profile& profile, const IR::Program& progr
387 } 387 }
388} 388}
389 389
390void SetupTransformFeedbackCapabilities(EmitContext& ctx, Id main_func) {
391 if (ctx.runtime_info.xfb_varyings.empty()) {
392 return;
393 }
394 ctx.AddCapability(spv::Capability::TransformFeedback);
395 ctx.AddExecutionMode(main_func, spv::ExecutionMode::Xfb);
396}
397
390void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ctx) { 398void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ctx) {
391 if (info.uses_sampled_1d) { 399 if (info.uses_sampled_1d) {
392 ctx.AddCapability(spv::Capability::Sampled1D); 400 ctx.AddCapability(spv::Capability::Sampled1D);
@@ -442,9 +450,6 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
442 if (info.uses_sample_id) { 450 if (info.uses_sample_id) {
443 ctx.AddCapability(spv::Capability::SampleRateShading); 451 ctx.AddCapability(spv::Capability::SampleRateShading);
444 } 452 }
445 if (!ctx.runtime_info.xfb_varyings.empty()) {
446 ctx.AddCapability(spv::Capability::TransformFeedback);
447 }
448 if (info.uses_derivatives) { 453 if (info.uses_derivatives) {
449 ctx.AddCapability(spv::Capability::DerivativeControl); 454 ctx.AddCapability(spv::Capability::DerivativeControl);
450 } 455 }
@@ -484,6 +489,7 @@ std::vector<u32> EmitSPIRV(const Profile& profile, const RuntimeInfo& runtime_in
484 SetupSignedNanCapabilities(profile, program, ctx, main); 489 SetupSignedNanCapabilities(profile, program, ctx, main);
485 } 490 }
486 SetupCapabilities(profile, program.info, ctx); 491 SetupCapabilities(profile, program.info, ctx);
492 SetupTransformFeedbackCapabilities(ctx, main);
487 PatchPhiNodes(program, ctx); 493 PatchPhiNodes(program, ctx);
488 return ctx.Assemble(); 494 return ctx.Assemble();
489} 495}
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/video_minimum_maximum.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/video_minimum_maximum.cpp
index 78869601f..4851b0b8d 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/video_minimum_maximum.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/video_minimum_maximum.cpp
@@ -57,16 +57,6 @@ void TranslatorVisitor::VMNMX(u64 insn) {
57 if (vmnmx.sat != 0) { 57 if (vmnmx.sat != 0) {
58 throw NotImplementedException("VMNMX SAT"); 58 throw NotImplementedException("VMNMX SAT");
59 } 59 }
60 // Selectors were shown to default to 2 in unit tests
61 if (vmnmx.src_a_selector != 2) {
62 throw NotImplementedException("VMNMX Selector {}", vmnmx.src_a_selector.Value());
63 }
64 if (vmnmx.src_b_selector != 2) {
65 throw NotImplementedException("VMNMX Selector {}", vmnmx.src_b_selector.Value());
66 }
67 if (vmnmx.src_a_width != VideoWidth::Word) {
68 throw NotImplementedException("VMNMX Source Width {}", vmnmx.src_a_width.Value());
69 }
70 60
71 const bool is_b_imm{vmnmx.is_src_b_reg == 0}; 61 const bool is_b_imm{vmnmx.is_src_b_reg == 0};
72 const IR::U32 src_a{GetReg8(insn)}; 62 const IR::U32 src_a{GetReg8(insn)};
@@ -76,10 +66,14 @@ void TranslatorVisitor::VMNMX(u64 insn) {
76 const VideoWidth a_width{vmnmx.src_a_width}; 66 const VideoWidth a_width{vmnmx.src_a_width};
77 const VideoWidth b_width{GetVideoSourceWidth(vmnmx.src_b_width, is_b_imm)}; 67 const VideoWidth b_width{GetVideoSourceWidth(vmnmx.src_b_width, is_b_imm)};
78 68
69 const u32 a_selector{static_cast<u32>(vmnmx.src_a_selector)};
70 // Immediate values can't have a selector
71 const u32 b_selector{is_b_imm ? 0U : static_cast<u32>(vmnmx.src_b_selector)};
72
79 const bool src_a_signed{vmnmx.src_a_sign != 0}; 73 const bool src_a_signed{vmnmx.src_a_sign != 0};
80 const bool src_b_signed{vmnmx.src_b_sign != 0}; 74 const bool src_b_signed{vmnmx.src_b_sign != 0};
81 const IR::U32 op_a{ExtractVideoOperandValue(ir, src_a, a_width, 0, src_a_signed)}; 75 const IR::U32 op_a{ExtractVideoOperandValue(ir, src_a, a_width, a_selector, src_a_signed)};
82 const IR::U32 op_b{ExtractVideoOperandValue(ir, src_b, b_width, 0, src_b_signed)}; 76 const IR::U32 op_b{ExtractVideoOperandValue(ir, src_b, b_width, b_selector, src_b_signed)};
83 77
84 // First operation's sign is only dependent on operand b's sign 78 // First operation's sign is only dependent on operand b's sign
85 const bool op_1_signed{src_b_signed}; 79 const bool op_1_signed{src_b_signed};
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 7029287a9..752504236 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -403,10 +403,22 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
403 connect(button, &QPushButton::customContextMenuRequested, 403 connect(button, &QPushButton::customContextMenuRequested,
404 [=, this](const QPoint& menu_location) { 404 [=, this](const QPoint& menu_location) {
405 QMenu context_menu; 405 QMenu context_menu;
406 Common::ParamPackage param = emulated_controller->GetMotionParam(motion_id);
406 context_menu.addAction(tr("Clear"), [&] { 407 context_menu.addAction(tr("Clear"), [&] {
407 emulated_controller->SetMotionParam(motion_id, {}); 408 emulated_controller->SetMotionParam(motion_id, {});
408 motion_map[motion_id]->setText(tr("[not set]")); 409 motion_map[motion_id]->setText(tr("[not set]"));
409 }); 410 });
411 if (param.Has("motion")) {
412 context_menu.addAction(tr("Set gyro threshold"), [&] {
413 const int gyro_threshold =
414 static_cast<int>(param.Get("threshold", 0.007f) * 1000.0f);
415 const int new_threshold = QInputDialog::getInt(
416 this, tr("Set threshold"), tr("Choose a value between 0% and 100%"),
417 gyro_threshold, 0, 100);
418 param.Set("threshold", new_threshold / 1000.0f);
419 emulated_controller->SetMotionParam(motion_id, param);
420 });
421 }
410 context_menu.exec(motion_map[motion_id]->mapToGlobal(menu_location)); 422 context_menu.exec(motion_map[motion_id]->mapToGlobal(menu_location));
411 }); 423 });
412 } 424 }