Skip to content

Commit 78b199f

Browse files
committed
Wired OEM controllers.
1 parent b859ad5 commit 78b199f

File tree

11 files changed

+165
-94
lines changed

11 files changed

+165
-94
lines changed

SerialPrograms/Source/Controllers/ControllerTypeStrings.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ const EnumStringMap<ControllerType> CONTROLLER_TYPE_STRINGS{
2222
{ControllerType::HID_Keyboard, "HID: Keyboard"},
2323
{ControllerType::NintendoSwitch_WiredController, "NS1: Wired Controller"},
2424
{ControllerType::NintendoSwitch_WiredProController, "NS1: Wired Pro Controller"},
25+
{ControllerType::NintendoSwitch_WiredLeftJoycon, "NS1: Wired Left Joycon"},
26+
{ControllerType::NintendoSwitch_WiredRightJoycon, "NS1: Wired Right Joycon"},
2527
{ControllerType::NintendoSwitch_WirelessProController, "NS1: Wireless Pro Controller"},
26-
{ControllerType::NintendoSwitch_LeftJoycon, "NS1: Left Joycon"},
27-
{ControllerType::NintendoSwitch_RightJoycon, "NS1: Right Joycon"},
28+
{ControllerType::NintendoSwitch_WirelessLeftJoycon, "NS1: Wireless Left Joycon"},
29+
{ControllerType::NintendoSwitch_WirelessRightJoycon, "NS1: Wireless Right Joycon"},
2830
{ControllerType::NintendoSwitch2_WiredController, "NS2: Wired Controller"},
2931
{ControllerType::NintendoSwitch2_WiredProController, "NS2: Wired Pro Controller"},
32+
{ControllerType::NintendoSwitch2_WiredLeftJoycon, "NS2: Wired Left Joycon"},
33+
{ControllerType::NintendoSwitch2_WiredRightJoycon, "NS2: Wired Right Joycon"},
3034
{ControllerType::NintendoSwitch2_WirelessProController, "NS2: Wireless Pro Controller"},
31-
{ControllerType::NintendoSwitch2_LeftJoycon, "NS2: Left Joycon"},
32-
{ControllerType::NintendoSwitch2_RightJoycon, "NS2: Right Joycon"},
35+
{ControllerType::NintendoSwitch2_WirelessLeftJoycon, "NS2: Wireless Left Joycon"},
36+
{ControllerType::NintendoSwitch2_WirelessRightJoycon, "NS2: Wireless Right Joycon"},
3337
};
3438

3539
const EnumStringMap<ControllerClass>& CONTROLLER_CLASS_STRINGS(){

SerialPrograms/Source/Controllers/ControllerTypes.h

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,14 @@ enum class ControllerInterface{
1818
UsbSysbotBase,
1919
};
2020

21-
22-
enum class ControllerType{
23-
None,
24-
25-
HID_Keyboard,
26-
27-
NintendoSwitch_WiredController, // Generic 3rd party wired controller.
28-
NintendoSwitch_WiredProController, // The official Pro Controller, connected over USB.
29-
NintendoSwitch_WirelessProController,
30-
NintendoSwitch_LeftJoycon,
31-
NintendoSwitch_RightJoycon,
32-
NintendoSwitch2_WiredController, // Generic 3rd party wired controller.
33-
NintendoSwitch2_WiredProController, // The official Pro Controller, connected over USB.
34-
NintendoSwitch2_WirelessProController,
35-
NintendoSwitch2_LeftJoycon,
36-
NintendoSwitch2_RightJoycon,
37-
};
38-
39-
4021
enum class ControllerPerformanceClass{
4122
Unknown,
4223
SerialPABotBase_Wired,
4324
SerialPABotBase_Wireless,
4425
SysbotBase,
4526
};
4627

28+
4729
enum class ControllerClass{
4830
None,
4931
HID_Keyboard,
@@ -53,6 +35,29 @@ enum class ControllerClass{
5335
};
5436

5537

38+
enum class ControllerType{
39+
None,
40+
41+
HID_Keyboard,
42+
43+
NintendoSwitch_WiredController, // Generic 3rd party wired controller.
44+
NintendoSwitch_WiredProController,
45+
NintendoSwitch_WiredLeftJoycon,
46+
NintendoSwitch_WiredRightJoycon,
47+
NintendoSwitch_WirelessProController,
48+
NintendoSwitch_WirelessLeftJoycon,
49+
NintendoSwitch_WirelessRightJoycon,
50+
51+
NintendoSwitch2_WiredController, // Generic 3rd party wired controller.
52+
NintendoSwitch2_WiredProController,
53+
NintendoSwitch2_WiredLeftJoycon,
54+
NintendoSwitch2_WiredRightJoycon,
55+
NintendoSwitch2_WirelessProController,
56+
NintendoSwitch2_WirelessLeftJoycon,
57+
NintendoSwitch2_WirelessRightJoycon,
58+
};
59+
60+
5661

5762

5863
}

SerialPrograms/Source/Controllers/KeyboardInput/KeyboardInput.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ void KeyboardInputController::thread_loop(){
123123

124124
update_state(*current, pressed_native_keys);
125125
bool neutral = current->is_neutral();
126+
// cout << "neutral = " << neutral << endl;
126127

127128

128129
// Send the command.
@@ -155,6 +156,7 @@ void KeyboardInputController::thread_loop(){
155156
}
156157

157158
// Send the command.
159+
// cout << "send_state()" << endl;
158160
send_state(*current);
159161

160162
std::swap(last, current);

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,31 @@ ControllerType id_to_controller_type(uint32_t id){
5757
return ControllerType::NintendoSwitch_WiredController;
5858
case PABB_CID_NintendoSwitch_WiredProController:
5959
return ControllerType::NintendoSwitch_WiredProController;
60+
case PABB_CID_NintendoSwitch_WiredLeftJoycon:
61+
return ControllerType::NintendoSwitch_WiredLeftJoycon;
62+
case PABB_CID_NintendoSwitch_WiredRightJoycon:
63+
return ControllerType::NintendoSwitch_WiredRightJoycon;
6064
case PABB_CID_NintendoSwitch_WirelessProController:
6165
return ControllerType::NintendoSwitch_WirelessProController;
62-
case PABB_CID_NintendoSwitch_LeftJoycon:
63-
return ControllerType::NintendoSwitch_LeftJoycon;
64-
case PABB_CID_NintendoSwitch_RightJoycon:
65-
return ControllerType::NintendoSwitch_RightJoycon;
66+
case PABB_CID_NintendoSwitch_WirelessLeftJoycon:
67+
return ControllerType::NintendoSwitch_WirelessLeftJoycon;
68+
case PABB_CID_NintendoSwitch_WirelessRightJoycon:
69+
return ControllerType::NintendoSwitch_WirelessRightJoycon;
6670

6771
case PABB_CID_NintendoSwitch2_WiredController:
6872
return ControllerType::NintendoSwitch2_WiredController;
6973
case PABB_CID_NintendoSwitch2_WiredProController:
7074
return ControllerType::NintendoSwitch2_WiredProController;
75+
case PABB_CID_NintendoSwitch2_WiredLeftJoycon:
76+
return ControllerType::NintendoSwitch2_WiredLeftJoycon;
77+
case PABB_CID_NintendoSwitch2_WiredRightJoycon:
78+
return ControllerType::NintendoSwitch2_WiredRightJoycon;
7179
case PABB_CID_NintendoSwitch2_WirelessProController:
7280
return ControllerType::NintendoSwitch2_WirelessProController;
73-
case PABB_CID_NintendoSwitch2_LeftJoycon:
74-
return ControllerType::NintendoSwitch2_LeftJoycon;
75-
case PABB_CID_NintendoSwitch2_RightJoycon:
76-
return ControllerType::NintendoSwitch2_RightJoycon;
81+
case PABB_CID_NintendoSwitch2_WirelessLeftJoycon:
82+
return ControllerType::NintendoSwitch2_WirelessLeftJoycon;
83+
case PABB_CID_NintendoSwitch2_WirelessRightJoycon:
84+
return ControllerType::NintendoSwitch2_WirelessRightJoycon;
7785

7886
default:
7987
return ControllerType::None;
@@ -96,23 +104,31 @@ uint32_t controller_type_to_id(ControllerType controller_type){
96104
return PABB_CID_NintendoSwitch_WiredController;
97105
case ControllerType::NintendoSwitch_WiredProController:
98106
return PABB_CID_NintendoSwitch_WiredProController;
107+
case ControllerType::NintendoSwitch_WiredLeftJoycon:
108+
return PABB_CID_NintendoSwitch_WiredLeftJoycon;
109+
case ControllerType::NintendoSwitch_WiredRightJoycon:
110+
return PABB_CID_NintendoSwitch_WiredRightJoycon;
99111
case ControllerType::NintendoSwitch_WirelessProController:
100112
return PABB_CID_NintendoSwitch_WirelessProController;
101-
case ControllerType::NintendoSwitch_LeftJoycon:
102-
return PABB_CID_NintendoSwitch_LeftJoycon;
103-
case ControllerType::NintendoSwitch_RightJoycon:
104-
return PABB_CID_NintendoSwitch_RightJoycon;
113+
case ControllerType::NintendoSwitch_WirelessLeftJoycon:
114+
return PABB_CID_NintendoSwitch_WirelessLeftJoycon;
115+
case ControllerType::NintendoSwitch_WirelessRightJoycon:
116+
return PABB_CID_NintendoSwitch_WirelessRightJoycon;
105117

106118
case ControllerType::NintendoSwitch2_WiredController:
107119
return PABB_CID_NintendoSwitch2_WiredController;
108120
case ControllerType::NintendoSwitch2_WiredProController:
109121
return PABB_CID_NintendoSwitch2_WiredProController;
122+
case ControllerType::NintendoSwitch2_WiredLeftJoycon:
123+
return PABB_CID_NintendoSwitch2_WiredLeftJoycon;
124+
case ControllerType::NintendoSwitch2_WiredRightJoycon:
125+
return PABB_CID_NintendoSwitch2_WiredRightJoycon;
110126
case ControllerType::NintendoSwitch2_WirelessProController:
111127
return PABB_CID_NintendoSwitch2_WirelessProController;
112-
case ControllerType::NintendoSwitch2_LeftJoycon:
113-
return PABB_CID_NintendoSwitch2_LeftJoycon;
114-
case ControllerType::NintendoSwitch2_RightJoycon:
115-
return PABB_CID_NintendoSwitch2_RightJoycon;
128+
case ControllerType::NintendoSwitch2_WirelessLeftJoycon:
129+
return PABB_CID_NintendoSwitch2_WirelessLeftJoycon;
130+
case ControllerType::NintendoSwitch2_WirelessRightJoycon:
131+
return PABB_CID_NintendoSwitch2_WirelessRightJoycon;
116132
}
117133

118134
throw InternalProgramError(

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,24 @@ std::unique_ptr<AbstractController> SerialPABotBase_Descriptor::make_controller(
105105
)
106106
);
107107

108-
case ControllerType::NintendoSwitch_LeftJoycon:
108+
case ControllerType::NintendoSwitch_WiredLeftJoycon:
109+
case ControllerType::NintendoSwitch_WirelessLeftJoycon:
109110
return std::unique_ptr<AbstractController>(
110111
new PokemonAutomation::NintendoSwitch::SerialPABotBase_LeftJoycon(
111112
logger,
112113
static_cast<SerialPABotBase_Connection&>(connection),
114+
controller_type,
113115
reset_mode
114116
)
115117
);
116118

117-
case ControllerType::NintendoSwitch_RightJoycon:
119+
case ControllerType::NintendoSwitch_WiredRightJoycon:
120+
case ControllerType::NintendoSwitch_WirelessRightJoycon:
118121
return std::unique_ptr<AbstractController>(
119122
new PokemonAutomation::NintendoSwitch::SerialPABotBase_RightJoycon(
120123
logger,
121124
static_cast<SerialPABotBase_Connection&>(connection),
125+
controller_type,
122126
reset_mode
123127
)
124128
);

SerialPrograms/Source/NintendoSwitch/Controllers/Joycon/NintendoSwitch_Joycon.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include "NintendoSwitch_JoyconState.h"
1515
#include "NintendoSwitch_Joycon.h"
1616

17+
//#include <iostream>
18+
//using std::cout;
19+
//using std::endl;
20+
1721
namespace PokemonAutomation{
1822

1923
// Instantiate some template helper classes.
@@ -35,15 +39,15 @@ class JoyconController::KeyboardManager final :
3539
public PokemonAutomation::KeyboardManager<JoyconState, JoyconDeltas>
3640
{
3741
public:
38-
KeyboardManager(Logger& logger, JoyconController& controller, ControllerType controller_type)
42+
KeyboardManager(Logger& logger, JoyconController& controller, ControllerClass controller_class)
3943
: PokemonAutomation::KeyboardManager<JoyconState, JoyconDeltas>(logger, controller)
4044
{
4145
std::vector<std::shared_ptr<EditableTableRow>> mapping;
42-
switch (controller_type){
43-
case ControllerType::NintendoSwitch_LeftJoycon:
46+
switch (controller_class){
47+
case ControllerClass::NintendoSwitch_LeftJoycon:
4448
mapping = ConsoleSettings::instance().KEYBOARD_MAPPINGS.LEFT_JOYCON0.current_refs();
4549
break;
46-
case ControllerType::NintendoSwitch_RightJoycon:
50+
case ControllerClass::NintendoSwitch_RightJoycon:
4751
mapping = ConsoleSettings::instance().KEYBOARD_MAPPINGS.RIGHT_JOYCON0.current_refs();
4852
break;
4953
default:;
@@ -88,8 +92,8 @@ class JoyconController::KeyboardManager final :
8892

8993

9094

91-
JoyconController::JoyconController(Logger& logger, ControllerType controller_type)
92-
: m_keyboard_manager(CONSTRUCT_TOKEN, logger, *this, controller_type)
95+
JoyconController::JoyconController(Logger& logger, ControllerClass controller_class)
96+
: m_keyboard_manager(CONSTRUCT_TOKEN, logger, *this, controller_class)
9397
{
9498

9599
}

SerialPrograms/Source/NintendoSwitch/Controllers/Joycon/NintendoSwitch_Joycon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class JoyconController : public AbstractController{
5656
public:
5757
using ContextType = JoyconContext;
5858

59-
JoyconController(Logger& logger, ControllerType controller_type);
59+
JoyconController(Logger& logger, ControllerClass controller_class);
6060
virtual ~JoyconController();
6161

6262

SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_ControllerSettings.cpp

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,22 @@ struct JoyconColors : public ControllerColors{
6363
virtual void write_to_profile(ControllerProfile& profile, ControllerType controller) const override{
6464
profile.official_name = name;
6565
switch (controller){
66-
case ControllerType::NintendoSwitch_WirelessProController:{
66+
case ControllerType::NintendoSwitch_WirelessProController:
67+
case ControllerType::NintendoSwitch_WiredProController:{
6768
// Set the grips to the joycon colors.
6869
profile.left_grip = left_body;
6970
profile.right_grip = right_body;
7071
profile.body_color = average_colors(left_buttons, right_buttons);
7172
profile.button_color = average_colors(left_body, right_body);
7273
break;
7374
}
74-
case ControllerType::NintendoSwitch_LeftJoycon:
75+
case ControllerType::NintendoSwitch_WiredLeftJoycon:
76+
case ControllerType::NintendoSwitch_WirelessLeftJoycon:
7577
profile.button_color = left_buttons;
7678
profile.body_color = left_body;
7779
break;
78-
case ControllerType::NintendoSwitch_RightJoycon:
80+
case ControllerType::NintendoSwitch_WiredRightJoycon:
81+
case ControllerType::NintendoSwitch_WirelessRightJoycon:
7982
profile.button_color = right_buttons;
8083
profile.body_color = right_body;
8184
break;
@@ -106,19 +109,22 @@ struct ProconColors : public ControllerColors{
106109
virtual void write_to_profile(ControllerProfile& profile, ControllerType controller) const override{
107110
profile.official_name = name;
108111
switch (controller){
109-
case ControllerType::NintendoSwitch_WirelessProController:{
112+
case ControllerType::NintendoSwitch_WirelessProController:
113+
case ControllerType::NintendoSwitch_WiredProController:{
110114
// Set the grips to the joycon colors.
111115
profile.left_grip = left_grip;
112116
profile.right_grip = right_grip;
113117
profile.body_color = body;
114118
profile.button_color = buttons;
115119
break;
116120
}
117-
case ControllerType::NintendoSwitch_LeftJoycon:
121+
case ControllerType::NintendoSwitch_WiredLeftJoycon:
122+
case ControllerType::NintendoSwitch_WirelessLeftJoycon:
118123
profile.button_color = buttons;
119124
profile.body_color = left_grip;
120125
break;
121-
case ControllerType::NintendoSwitch_RightJoycon:
126+
case ControllerType::NintendoSwitch_WiredRightJoycon:
127+
case ControllerType::NintendoSwitch_WirelessRightJoycon:
122128
profile.button_color = buttons;
123129
profile.body_color = right_grip;
124130
break;
@@ -218,8 +224,8 @@ const StringSelectDatabase& CONTROLLER_DATABASE(){
218224
const EnumDropdownDatabase<ControllerType>& ControllerSettingsType_Database(){
219225
static const EnumDropdownDatabase<ControllerType> database({
220226
{ControllerType::NintendoSwitch_WirelessProController, "pro-controller", "NS1: Pro Controller"},
221-
{ControllerType::NintendoSwitch_LeftJoycon, "left-joycon", "NS1: Left Joycon"},
222-
{ControllerType::NintendoSwitch_RightJoycon, "right-joycon", "NS1: Right Joycon"},
227+
{ControllerType::NintendoSwitch_WirelessLeftJoycon, "left-joycon", "NS1: Left Joycon"},
228+
{ControllerType::NintendoSwitch_WirelessRightJoycon, "right-joycon", "NS1: Right Joycon"},
223229
});
224230
return database;
225231
}
@@ -317,9 +323,15 @@ void ControllerSettingsRow::on_config_value_changed(void* object){
317323
}
318324

319325
if (object == &controller){
320-
ConfigOptionState state = controller == ControllerType::NintendoSwitch_WirelessProController
321-
? ConfigOptionState::ENABLED
322-
: ConfigOptionState::HIDDEN;
326+
ConfigOptionState state;
327+
switch (controller){
328+
case ControllerType::NintendoSwitch_WirelessProController:
329+
case ControllerType::NintendoSwitch_WiredProController:
330+
state = ConfigOptionState::ENABLED;
331+
break;
332+
default:
333+
state = ConfigOptionState::HIDDEN;
334+
}
323335
left_grip.set_visibility(state);
324336
right_grip.set_visibility(state);
325337

@@ -408,16 +420,30 @@ ControllerProfile ControllerSettingsTable::get_or_make_profile(
408420

409421
// Only relevant to Switch controllers.
410422
switch (controller){
411-
case ControllerType::NintendoSwitch_WiredController:
412423
case ControllerType::NintendoSwitch_WiredProController:
413424
case ControllerType::NintendoSwitch_WirelessProController:
414-
case ControllerType::NintendoSwitch_LeftJoycon:
415-
case ControllerType::NintendoSwitch_RightJoycon:
416-
case ControllerType::NintendoSwitch2_WiredController:
417-
case ControllerType::NintendoSwitch2_WiredProController:
418-
case ControllerType::NintendoSwitch2_WirelessProController:
419-
case ControllerType::NintendoSwitch2_LeftJoycon:
420-
case ControllerType::NintendoSwitch2_RightJoycon:
425+
controller = ControllerType::NintendoSwitch_WirelessProController;
426+
break;
427+
case ControllerType::NintendoSwitch_WiredLeftJoycon:
428+
case ControllerType::NintendoSwitch_WirelessLeftJoycon:
429+
controller = ControllerType::NintendoSwitch_WirelessLeftJoycon;
430+
break;
431+
case ControllerType::NintendoSwitch_WiredRightJoycon:
432+
case ControllerType::NintendoSwitch_WirelessRightJoycon:
433+
controller = ControllerType::NintendoSwitch_WirelessRightJoycon;
434+
break;
435+
// case ControllerType::NintendoSwitch2_WiredProController:
436+
// case ControllerType::NintendoSwitch2_WirelessProController:
437+
// controller = ControllerType::NintendoSwitch2_WirelessProController;
438+
// break;
439+
// case ControllerType::NintendoSwitch2_WiredLeftJoycon:
440+
// case ControllerType::NintendoSwitch2_WirelessLeftJoycon:
441+
// controller = ControllerType::NintendoSwitch2_WirelessLeftJoycon;
442+
// break;
443+
// case ControllerType::NintendoSwitch2_WiredRightJoycon:
444+
// case ControllerType::NintendoSwitch2_WirelessRightJoycon:
445+
// controller = ControllerType::NintendoSwitch2_WirelessRightJoycon;
446+
// break;
421447
break;
422448
default:
423449
return profile;

0 commit comments

Comments
 (0)