Skip to content

Commit 83fcc71

Browse files
committed
Menu stability tester.
1 parent 4c94f6a commit 83fcc71

File tree

4 files changed

+225
-0
lines changed

4 files changed

+225
-0
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ file(GLOB MAIN_SOURCES
997997
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.h
998998
Source/NintendoSwitch/Programs/NintendoSwitch_KeyboardCodeEntry.cpp
999999
Source/NintendoSwitch/Programs/NintendoSwitch_KeyboardCodeEntry.h
1000+
Source/NintendoSwitch/Programs/NintendoSwitch_MenuStabilityTester.cpp
1001+
Source/NintendoSwitch/Programs/NintendoSwitch_MenuStabilityTester.h
10001002
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp
10011003
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.h
10021004
Source/NintendoSwitch/Programs/NintendoSwitch_NumberCodeEntry.cpp

SerialPrograms/Source/NintendoSwitch/NintendoSwitch_Panels.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "DevPrograms/BoxDraw.h"
2424
#include "Programs/NintendoSwitch_SnapshotDumper.h"
25+
#include "Programs/NintendoSwitch_MenuStabilityTester.h"
2526
#include "DevPrograms/TestProgramComputer.h"
2627
#include "DevPrograms/TestProgramSwitch.h"
2728
#include "DevPrograms/JoyconProgram.h"
@@ -67,6 +68,7 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
6768
ret.emplace_back("---- Developer Tools ----");
6869
ret.emplace_back(make_single_switch_program<BoxDraw_Descriptor, BoxDraw>());
6970
ret.emplace_back(make_single_switch_program<SnapshotDumper_Descriptor, SnapshotDumper>());
71+
ret.emplace_back(make_single_switch_program<MenuStabilityTester_Descriptor, MenuStabilityTester>());
7072
ret.emplace_back(make_computer_program<TestProgramComputer_Descriptor, TestProgramComputer>());
7173
ret.emplace_back(make_multi_switch_program<TestProgram_Descriptor, TestProgram>());
7274
ret.emplace_back(make_single_switch_program<JoyconProgram_Descriptor, JoyconProgram>());
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/* Friend Delete
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
8+
#include "NintendoSwitch_MenuStabilityTester.h"
9+
10+
namespace PokemonAutomation{
11+
namespace NintendoSwitch{
12+
13+
14+
15+
MenuStabilityTester_Descriptor::MenuStabilityTester_Descriptor()
16+
: SingleSwitchProgramDescriptor(
17+
"NintendoSwitch:MenuStabilityTester",
18+
"Nintendo Switch", "Menu Stability Tester",
19+
"",
20+
"Test the speed and stability of various fast menu movements.",
21+
FeedbackType::NONE,
22+
AllowCommandsWhenRunning::DISABLE_COMMANDS,
23+
{ControllerFeature::NintendoSwitch_ProController},
24+
FasterIfTickPrecise::NOT_FASTER
25+
)
26+
{}
27+
28+
MenuStabilityTester::~MenuStabilityTester(){
29+
TEST_TYPE.remove_listener(*this);
30+
}
31+
MenuStabilityTester::MenuStabilityTester()
32+
: TEST_TYPE(
33+
std::move("Console Type:"),
34+
{
35+
{TestType::Vertical, "vertical", "Vertical Up-Down"},
36+
{TestType::Horizontal, "horizontal", "Horizontal Side-to-Side"},
37+
{TestType::SimultaneousScrollA, "scroll-A", "Simultaneous Scroll + A"},
38+
},
39+
LockMode::LOCK_WHILE_RUNNING,
40+
TestType::Vertical
41+
)
42+
, VERTICAL_RANGE(
43+
"<b>Vertical Scroll Range:</b>",
44+
LockMode::LOCK_WHILE_RUNNING,
45+
60
46+
)
47+
, HORIZONTAL_RANGE(
48+
"<b>Horizontal Scroll Range:</b>",
49+
LockMode::LOCK_WHILE_RUNNING,
50+
4
51+
)
52+
, DELAY_TO_NEXT(
53+
"<b>Delay to Next Button:</b>",
54+
LockMode::LOCK_WHILE_RUNNING,
55+
"24 ms"
56+
)
57+
, HOLD_DURATION(
58+
"<b>Hold Duration:</b>",
59+
LockMode::LOCK_WHILE_RUNNING,
60+
"48 ms"
61+
)
62+
, COOLDOWN(
63+
"<b>Cooldown:</b>",
64+
LockMode::LOCK_WHILE_RUNNING,
65+
"24 ms"
66+
)
67+
{
68+
PA_ADD_OPTION(TEST_TYPE);
69+
70+
PA_ADD_OPTION(VERTICAL_RANGE);
71+
PA_ADD_OPTION(HORIZONTAL_RANGE);
72+
73+
PA_ADD_OPTION(DELAY_TO_NEXT);
74+
PA_ADD_OPTION(HOLD_DURATION);
75+
PA_ADD_OPTION(COOLDOWN);
76+
77+
MenuStabilityTester::on_config_value_changed(this);
78+
79+
TEST_TYPE.add_listener(*this);
80+
}
81+
void MenuStabilityTester::on_config_value_changed(void* object){
82+
switch (TEST_TYPE){
83+
case TestType::Vertical:
84+
VERTICAL_RANGE.set_visibility(ConfigOptionState::ENABLED);
85+
HORIZONTAL_RANGE.set_visibility(ConfigOptionState::HIDDEN);
86+
break;
87+
case TestType::Horizontal:
88+
VERTICAL_RANGE.set_visibility(ConfigOptionState::HIDDEN);
89+
HORIZONTAL_RANGE.set_visibility(ConfigOptionState::ENABLED);
90+
break;
91+
case TestType::SimultaneousScrollA:
92+
VERTICAL_RANGE.set_visibility(ConfigOptionState::HIDDEN);
93+
HORIZONTAL_RANGE.set_visibility(ConfigOptionState::HIDDEN);
94+
break;
95+
}
96+
}
97+
98+
99+
100+
101+
void MenuStabilityTester::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
102+
switch (TEST_TYPE){
103+
case TestType::Vertical:
104+
while (true){
105+
for (size_t c = 0; c < VERTICAL_RANGE; c++){
106+
ssf_issue_scroll(context, DPAD_DOWN, DELAY_TO_NEXT, HOLD_DURATION, COOLDOWN);
107+
}
108+
ssf_do_nothing(context, 1000ms);
109+
for (size_t c = 0; c < VERTICAL_RANGE; c++){
110+
ssf_issue_scroll(context, DPAD_UP, DELAY_TO_NEXT, HOLD_DURATION, COOLDOWN);
111+
}
112+
ssf_do_nothing(context, 1000ms);
113+
}
114+
break;
115+
116+
case TestType::Horizontal:
117+
for (size_t i = 0; i < 100; i++){
118+
for (size_t c = 0; c < HORIZONTAL_RANGE; c++){
119+
ssf_issue_scroll(context, DPAD_RIGHT, DELAY_TO_NEXT, HOLD_DURATION, COOLDOWN);
120+
}
121+
for (size_t c = 0; c < HORIZONTAL_RANGE; c++){
122+
ssf_issue_scroll(context, DPAD_LEFT, DELAY_TO_NEXT, HOLD_DURATION, COOLDOWN);
123+
}
124+
}
125+
break;
126+
127+
case TestType::SimultaneousScrollA:
128+
while (true){
129+
ssf_press_button(context, BUTTON_A, 0ms, HOLD_DURATION, COOLDOWN);
130+
ssf_issue_scroll(context, DPAD_UP, DELAY_TO_NEXT, HOLD_DURATION, COOLDOWN);
131+
ssf_do_nothing(context, 1000ms);
132+
}
133+
break;
134+
135+
}
136+
}
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
}
158+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* Menu Stability Tester
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_NintendoSwitch_MenuStabilityTester_H
8+
#define PokemonAutomation_NintendoSwitch_MenuStabilityTester_H
9+
10+
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11+
#include "Common/Cpp/Options/EnumDropdownOption.h"
12+
#include "Common/Cpp/Options/TimeDurationOption.h"
13+
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
14+
15+
namespace PokemonAutomation{
16+
namespace NintendoSwitch{
17+
18+
19+
20+
21+
class MenuStabilityTester_Descriptor : public SingleSwitchProgramDescriptor{
22+
public:
23+
MenuStabilityTester_Descriptor();
24+
};
25+
26+
27+
28+
class MenuStabilityTester : public SingleSwitchProgramInstance, private ConfigOption::Listener{
29+
public:
30+
~MenuStabilityTester();
31+
MenuStabilityTester();
32+
33+
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
34+
35+
private:
36+
virtual void on_config_value_changed(void* object) override;
37+
38+
private:
39+
enum class TestType{
40+
Vertical,
41+
Horizontal,
42+
SimultaneousScrollA,
43+
};
44+
45+
EnumDropdownOption<TestType> TEST_TYPE;
46+
SimpleIntegerOption<uint8_t> VERTICAL_RANGE;
47+
SimpleIntegerOption<uint8_t> HORIZONTAL_RANGE;
48+
49+
MillisecondsOption DELAY_TO_NEXT;
50+
MillisecondsOption HOLD_DURATION;
51+
MillisecondsOption COOLDOWN;
52+
53+
};
54+
55+
56+
57+
58+
}
59+
}
60+
#endif
61+
62+
63+

0 commit comments

Comments
 (0)