Skip to content

Commit eeed056

Browse files
committed
Big refactor of code entry.
1 parent 9ace96d commit eeed056

File tree

44 files changed

+1334
-1080
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1334
-1080
lines changed

Common/Cpp/Options/FixedCodeOption.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,10 @@ JsonValue FixedCodeOption::to_json() const{
101101
return m_data->m_current;
102102
}
103103

104-
void FixedCodeOption::to_str(uint8_t* code) const{
105-
std::string qstr;
104+
std::string FixedCodeOption::to_str() const{
106105
{
107106
ReadSpinLock lg(m_data->m_lock);
108-
qstr = sanitize_code(8, m_data->m_current);
109-
}
110-
for (int c = 0; c < 8; c++){
111-
code[c] = qstr[c] - '0';
107+
return sanitize_code(8, m_data->m_current);
112108
}
113109
}
114110

Common/Cpp/Options/FixedCodeOption.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class FixedCodeOption : public ConfigOption{
2929
operator const std::string&() const;
3030
const std::string& get() const;
3131
std::string set(std::string x);
32-
void to_str(uint8_t* code) const;
32+
std::string to_str() const;
3333

3434
virtual std::string check_validity() const override;
3535
std::string check_validity(const std::string& x) const;

Common/Cpp/Options/RandomCodeOption.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@ std::string RaidCodeOption::check_validity() const{
4242
bool RaidCodeOption::code_enabled() const{
4343
return m_random_digits != 0 || m_code.size() > 0;
4444
}
45-
bool RaidCodeOption::get_code(uint8_t* code) const{
45+
std::string RaidCodeOption::get_code() const{
4646
if (!code_enabled()){
47-
return false;
47+
return "";
4848
}
49+
std::string code;
50+
code.resize(8);
4951
if (m_random_digits == 0){
5052
std::string qstr = sanitize_code(8, m_code);
5153
for (int c = 0; c < 8; c++){
5254
code[c] = qstr[c] - '0';
5355
}
54-
return true;
56+
return code;
5557
}
5658
srand((unsigned)time(nullptr));
5759
for (uint8_t c = 0; c < m_random_digits; c++){
@@ -64,7 +66,7 @@ bool RaidCodeOption::get_code(uint8_t* code) const{
6466
for (size_t c = m_random_digits; c < m_digits; c++){
6567
code[c] = code[c - 1];
6668
}
67-
return true;
69+
return code;
6870
}
6971
bool RaidCodeOption::operator==(const RaidCodeOption& x) const{
7072
return
@@ -175,9 +177,9 @@ bool RandomCodeOption::code_enabled() const{
175177
ReadSpinLock lg(m_data->m_lock);
176178
return m_data->m_current.code_enabled();
177179
}
178-
bool RandomCodeOption::get_code(uint8_t* code) const{
180+
std::string RandomCodeOption::get_code() const{
179181
ReadSpinLock lg(m_data->m_lock);
180-
return m_data->m_current.get_code(code);
182+
return m_data->m_current.get_code();
181183
}
182184

183185
std::string RandomCodeOption::check_validity() const{

Common/Cpp/Options/RandomCodeOption.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RaidCodeOption{
2525

2626
std::string check_validity() const;
2727
bool code_enabled() const;
28-
bool get_code(uint8_t* code) const;
28+
std::string get_code() const;
2929

3030
bool operator==(const RaidCodeOption& x) const;
3131

@@ -53,7 +53,7 @@ class RandomCodeOption : public ConfigOption{
5353
std::string set(RaidCodeOption code);
5454

5555
bool code_enabled() const;
56-
bool get_code(uint8_t* code) const;
56+
std::string get_code() const;
5757

5858
virtual std::string check_validity() const override;
5959
virtual void restore_defaults() override;

SerialPrograms/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,6 @@ file(GLOB MAIN_SOURCES
811811
Source/Kernels/Waterfill/Kernels_Waterfill_Session.h
812812
Source/Kernels/Waterfill/Kernels_Waterfill_Session.tpp
813813
Source/Kernels/Waterfill/Kernels_Waterfill_Types.h
814-
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_DigitEntry.cpp
815-
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_DigitEntry.h
816814
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.cpp
817815
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h
818816
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Routines.cpp
@@ -885,6 +883,8 @@ file(GLOB MAIN_SOURCES
885883
Source/NintendoSwitch/NintendoSwitch_Settings.h
886884
Source/NintendoSwitch/NintendoSwitch_SingleSwitchProgram.cpp
887885
Source/NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h
886+
Source/NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.cpp
887+
Source/NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.h
888888
Source/NintendoSwitch/Options/NintendoSwitch_FriendCodeListOption.cpp
889889
Source/NintendoSwitch/Options/NintendoSwitch_FriendCodeListOption.h
890890
Source/NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.cpp
@@ -894,16 +894,18 @@ file(GLOB MAIN_SOURCES
894894
Source/NintendoSwitch/Options/TurboMacroTable.h
895895
Source/NintendoSwitch/Options/UI/NintendoSwitch_FriendCodeListWidget.cpp
896896
Source/NintendoSwitch/Options/UI/NintendoSwitch_FriendCodeListWidget.h
897-
Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.cpp
898-
Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.h
899897
Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.cpp
900898
Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.h
901899
Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.cpp
902900
Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.h
903901
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp
904902
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.h
903+
Source/NintendoSwitch/Programs/NintendoSwitch_KeyboardCodeEntry.cpp
904+
Source/NintendoSwitch/Programs/NintendoSwitch_KeyboardCodeEntry.h
905905
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp
906906
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.h
907+
Source/NintendoSwitch/Programs/NintendoSwitch_NumberCodeEntry.cpp
908+
Source/NintendoSwitch/Programs/NintendoSwitch_NumberCodeEntry.h
907909
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.cpp
908910
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.h
909911
Source/NintendoSwitch/Programs/NintendoSwitch_PushJoySticks.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ SOURCES += \
402402
Source/Kernels/Waterfill/Kernels_Waterfill_Core_64x8_x64_SSE42.cpp \
403403
Source/Kernels/Waterfill/Kernels_Waterfill_Core_64xH_Default.cpp \
404404
Source/Kernels/Waterfill/Kernels_Waterfill_Session.cpp \
405-
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_DigitEntry.cpp \
406405
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.cpp \
407406
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Routines.cpp \
408407
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.cpp \
@@ -437,14 +436,15 @@ SOURCES += \
437436
Source/NintendoSwitch/NintendoSwitch_Panels.cpp \
438437
Source/NintendoSwitch/NintendoSwitch_Settings.cpp \
439438
Source/NintendoSwitch/NintendoSwitch_SingleSwitchProgram.cpp \
439+
Source/NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.cpp \
440440
Source/NintendoSwitch/Options/NintendoSwitch_FriendCodeListOption.cpp \
441441
Source/NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.cpp \
442442
Source/NintendoSwitch/Options/TurboMacroTable.cpp \
443443
Source/NintendoSwitch/Options/UI/NintendoSwitch_FriendCodeListWidget.cpp \
444-
Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.cpp \
445444
Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.cpp \
446445
Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.cpp \
447446
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp \
447+
Source/NintendoSwitch/Programs/NintendoSwitch_KeyboardCodeEntry.cpp \
448448
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp \
449449
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.cpp \
450450
Source/NintendoSwitch/Programs/NintendoSwitch_PushJoySticks.cpp \
@@ -1560,7 +1560,6 @@ HEADERS += \
15601560
Source/Kernels/Waterfill/Kernels_Waterfill_Session.h \
15611561
Source/Kernels/Waterfill/Kernels_Waterfill_Session.tpp \
15621562
Source/Kernels/Waterfill/Kernels_Waterfill_Types.h \
1563-
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_DigitEntry.h \
15641563
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h \
15651564
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Routines.h \
15661565
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h \
@@ -1599,15 +1598,16 @@ HEADERS += \
15991598
Source/NintendoSwitch/NintendoSwitch_Panels.h \
16001599
Source/NintendoSwitch/NintendoSwitch_Settings.h \
16011600
Source/NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h \
1601+
Source/NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.h \
16021602
Source/NintendoSwitch/Options/NintendoSwitch_FriendCodeListOption.h \
16031603
Source/NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h \
16041604
Source/NintendoSwitch/Options/NintendoSwitch_StartInGripMenuOption.h \
16051605
Source/NintendoSwitch/Options/TurboMacroTable.h \
16061606
Source/NintendoSwitch/Options/UI/NintendoSwitch_FriendCodeListWidget.h \
1607-
Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.h \
16081607
Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.h \
16091608
Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.h \
16101609
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.h \
1610+
Source/NintendoSwitch/Programs/NintendoSwitch_KeyboardCodeEntry.h \
16111611
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.h \
16121612
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.h \
16131613
Source/NintendoSwitch/Programs/NintendoSwitch_PushJoySticks.h \

0 commit comments

Comments
 (0)