Skip to content

Commit 27e2447

Browse files
committed
Allow filtering of controller types. Put wired OEM behind beta.
1 parent 863da06 commit 27e2447

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "Common/Cpp/Exceptions.h"
88
#include "Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h"
9+
#include "CommonFramework/Globals.h"
10+
#include "CommonFramework/GlobalSettingsPanel.h"
911
#include "SerialPABotBase.h"
1012

1113
namespace PokemonAutomation{
@@ -44,6 +46,32 @@ const std::map<uint32_t, std::map<pabb_ProgramID, uint8_t>>& SUPPORTED_VERSIONS(
4446
}
4547

4648

49+
bool controller_is_valid(uint32_t id){
50+
switch (id){
51+
case PABB_CID_NONE:
52+
case PABB_CID_StandardHid_Keyboard:
53+
case PABB_CID_NintendoSwitch_WiredController:
54+
case PABB_CID_NintendoSwitch2_WiredController:
55+
case PABB_CID_NintendoSwitch_WirelessProController:
56+
case PABB_CID_NintendoSwitch_WirelessLeftJoycon:
57+
case PABB_CID_NintendoSwitch_WirelessRightJoycon:
58+
return true;
59+
case PABB_CID_NintendoSwitch_WiredProController:
60+
case PABB_CID_NintendoSwitch_WiredLeftJoycon:
61+
case PABB_CID_NintendoSwitch_WiredRightJoycon:
62+
return IS_BETA_VERSION || PreloadSettings::instance().DEVELOPER_MODE;
63+
case PABB_CID_NintendoSwitch2_WiredProController:
64+
case PABB_CID_NintendoSwitch2_WiredLeftJoycon:
65+
case PABB_CID_NintendoSwitch2_WiredRightJoycon:
66+
case PABB_CID_NintendoSwitch2_WirelessProController:
67+
case PABB_CID_NintendoSwitch2_WirelessLeftJoycon:
68+
case PABB_CID_NintendoSwitch2_WirelessRightJoycon:
69+
return PreloadSettings::instance().DEVELOPER_MODE;
70+
}
71+
return false;
72+
}
73+
74+
4775

4876
ControllerType id_to_controller_type(uint32_t id){
4977
switch (id){
@@ -82,15 +110,12 @@ ControllerType id_to_controller_type(uint32_t id){
82110
return ControllerType::NintendoSwitch2_WirelessLeftJoycon;
83111
case PABB_CID_NintendoSwitch2_WirelessRightJoycon:
84112
return ControllerType::NintendoSwitch2_WirelessRightJoycon;
85-
86-
default:
87-
return ControllerType::None;
88113
}
89114

90-
// throw InternalProgramError(
91-
// nullptr, PA_CURRENT_FUNCTION,
92-
// "Invalid Controller ID: " + std::to_string(id)
93-
// );
115+
throw InternalProgramError(
116+
nullptr, PA_CURRENT_FUNCTION,
117+
"Invalid Controller ID: " + std::to_string(id)
118+
);
94119
}
95120
uint32_t controller_type_to_id(ControllerType controller_type){
96121
switch (controller_type){

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const std::map<
3030
>& SUPPORTED_VERSIONS();
3131

3232

33-
33+
bool controller_is_valid(uint32_t id);
3434

3535
ControllerType id_to_controller_type(uint32_t id);
3636
uint32_t controller_type_to_id(ControllerType controller_type);

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ ControllerType SerialPABotBase_Connection::process_device(bool set_to_null_contr
204204
}
205205
first = false;
206206
str += "0x" + tostr_hex(id);
207-
m_controller_list.emplace_back(id_to_controller_type(id));
207+
if (controller_is_valid(id)){
208+
m_controller_list.emplace_back(id_to_controller_type(id));
209+
}
208210
}
209211
m_logger.Logger::log("Checking Controller List... (" + str + ")");
210212
}

0 commit comments

Comments
 (0)