@@ -28,15 +28,16 @@ namespace {
2828 /* *
2929 * @brief Expected touchpad support for a configured gamepad.
3030 */
31- struct gamepad_touchpad_case_t {
31+ struct gamepad_capabilities_case_t {
3232 std::string_view gamepad; // /< Configured gamepad name.
33- bool expected; // /< Whether the configured gamepad supports touchpad input.
33+ bool expected_touchpad; // /< Whether the configured gamepad supports touchpad input.
34+ bool expected_controller_extensions; // /< Whether Moonlight controller extensions should be advertised.
3435 };
3536
3637 /* *
3738 * @brief Parameterized fixture that restores the configured gamepad after each test.
3839 */
39- class VirtualHidInputTest : public ::testing::TestWithParam<gamepad_touchpad_case_t > {
40+ class VirtualHidInputTest : public ::testing::TestWithParam<gamepad_capabilities_case_t > {
4041 protected:
4142 /* *
4243 * @brief Preserve the configured gamepad.
@@ -59,25 +60,34 @@ namespace {
5960} // namespace
6061
6162TEST_P (VirtualHidInputTest, ReportsExpectedTouchpadSupport) {
62- const auto &[gamepad, expected] = GetParam ();
63- config::input.gamepad = gamepad;
64- EXPECT_EQ (platf::virtualhid::configured_gamepad_supports_touchpad (), expected) << gamepad;
63+ const auto &test_case = GetParam ();
64+ config::input.gamepad = test_case.gamepad ;
65+ EXPECT_EQ (platf::virtualhid::configured_gamepad_supports_touchpad (), test_case.expected_touchpad ) << test_case.gamepad ;
66+ }
67+
68+ TEST_P (VirtualHidInputTest, ReportsExpectedControllerExtensionSupport) {
69+ const auto &test_case = GetParam ();
70+ config::input.gamepad = test_case.gamepad ;
71+ EXPECT_EQ (
72+ platf::virtualhid::configured_gamepad_supports_controller_extensions (),
73+ test_case.expected_controller_extensions
74+ ) << test_case.gamepad ;
6575}
6676
6777INSTANTIATE_TEST_SUITE_P (
6878 ConfiguredGamepads,
6979 VirtualHidInputTest,
7080 ::testing::Values (
71- gamepad_touchpad_case_t {" auto" sv, true },
72- gamepad_touchpad_case_t {" generic" sv, false },
73- gamepad_touchpad_case_t {" x360" sv, false },
74- gamepad_touchpad_case_t {" xone" sv, false },
75- gamepad_touchpad_case_t {" xseries" sv, false },
76- gamepad_touchpad_case_t {" ds4" sv, true },
77- gamepad_touchpad_case_t {" ds5" sv, true },
78- gamepad_touchpad_case_t {" switch" sv, false }
81+ gamepad_capabilities_case_t {" auto" sv, true , true },
82+ gamepad_capabilities_case_t {" generic" sv, false , false },
83+ gamepad_capabilities_case_t {" x360" sv, false , false },
84+ gamepad_capabilities_case_t {" xone" sv, false , false },
85+ gamepad_capabilities_case_t {" xseries" sv, false , false },
86+ gamepad_capabilities_case_t {" ds4" sv, true , true },
87+ gamepad_capabilities_case_t {" ds5" sv, true , true },
88+ gamepad_capabilities_case_t {" switch" sv, false , true }
7989 ),
80- [](const ::testing::TestParamInfo<gamepad_touchpad_case_t > &info) {
90+ [](const ::testing::TestParamInfo<gamepad_capabilities_case_t > &info) {
8191 return std::string {info.param .gamepad };
8292 }
8393);
@@ -406,6 +416,23 @@ TEST_F(VirtualHidDeviceTest, RoutesAndDeduplicatesGamepadFeedback) {
406416 ASSERT_TRUE (adapter->dispatch_output (output).ok ());
407417 EXPECT_TRUE (feedback_queue ()->pop (10ms));
408418
419+ output.kind = lvh::GamepadOutputKind::player_leds;
420+ output.player_leds = {true , false , true , false };
421+ output.flashing_player_leds = {false , true , false , true };
422+ ASSERT_TRUE (adapter->dispatch_output (output).ok ());
423+ feedback = feedback_queue ()->pop (10ms);
424+ ASSERT_TRUE (feedback);
425+ EXPECT_EQ (feedback->type , platf::gamepad_feedback_e::set_player_leds);
426+ EXPECT_EQ (feedback->data .player_leds .solid , 0x05 );
427+ EXPECT_EQ (feedback->data .player_leds .flashing , 0x0A );
428+ ASSERT_TRUE (adapter->dispatch_output (output).ok ());
429+ EXPECT_FALSE (feedback_queue ()->pop (0ms));
430+ output.player_leds [3 ] = true ;
431+ ASSERT_TRUE (adapter->dispatch_output (output).ok ());
432+ feedback = feedback_queue ()->pop (10ms);
433+ ASSERT_TRUE (feedback);
434+ EXPECT_EQ (feedback->data .player_leds .solid , 0x0D );
435+
409436 output.kind = lvh::GamepadOutputKind::adaptive_triggers;
410437 output.adaptive_trigger_flags = 5 ;
411438 output.left_trigger_effect_type = 6 ;
0 commit comments