Skip to content

Commit b859ad5

Browse files
committed
More controllers refactor.
1 parent cdd3567 commit b859ad5

File tree

3 files changed

+12
-34
lines changed

3 files changed

+12
-34
lines changed

Common/SerialPABotBase/SerialPABotBase_Messages_NS_WiredController.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222

2323
#ifdef __cplusplus
24-
namespace PokemonAutomation{
25-
namespace SerialPABotBase{
24+
extern "C" {
2625
#endif
2726

2827

@@ -37,7 +36,6 @@ typedef struct{
3736

3837
#ifdef __cplusplus
3938
}
40-
}
4139
#endif
4240

4341

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_OemControllers.h

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h"
1111
#include "Common/SerialPABotBase/SerialPABotBase_Messages_NS1_OemControllers.h"
1212
#include "Controllers/ControllerTypes.h"
13+
#include "Controllers/SerialPABotBase/SerialPABotBase.h"
1314
#include "Controllers/SerialPABotBase/Connection/BotBaseMessage.h"
1415

1516
namespace PokemonAutomation{
@@ -25,21 +26,8 @@ class MessageControllerReadSpi : public BotBaseRequest{
2526
MessageControllerReadSpi(ControllerType controller_type, uint32_t address, uint8_t bytes)
2627
: BotBaseRequest(false)
2728
{
28-
uint32_t controller_id = PABB_CID_NONE;
29-
switch (controller_type){
30-
case ControllerType::NintendoSwitch_WirelessProController:
31-
controller_id = PABB_CID_NintendoSwitch_WirelessProController;
32-
break;
33-
case ControllerType::NintendoSwitch_LeftJoycon:
34-
controller_id = PABB_CID_NintendoSwitch_LeftJoycon;
35-
break;
36-
case ControllerType::NintendoSwitch_RightJoycon:
37-
controller_id = PABB_CID_NintendoSwitch_RightJoycon;
38-
break;
39-
default:;
40-
}
4129
params.seqnum = 0;
42-
params.controller_type = controller_id;
30+
params.controller_type = controller_type_to_id(controller_type);
4331
params.address = address;
4432
params.bytes = bytes;
4533
}
@@ -57,22 +45,9 @@ class MessageControllerWriteSpi : public BotBaseRequest{
5745
)
5846
: BotBaseRequest(false)
5947
{
60-
uint32_t controller_id = PABB_CID_NONE;
61-
switch (controller_type){
62-
case ControllerType::NintendoSwitch_WirelessProController:
63-
controller_id = PABB_CID_NintendoSwitch_WirelessProController;
64-
break;
65-
case ControllerType::NintendoSwitch_LeftJoycon:
66-
controller_id = PABB_CID_NintendoSwitch_LeftJoycon;
67-
break;
68-
case ControllerType::NintendoSwitch_RightJoycon:
69-
controller_id = PABB_CID_NintendoSwitch_RightJoycon;
70-
break;
71-
default:;
72-
}
7348
pabb_Message_NS1_OemController_WriteSpi params;
7449
params.seqnum = 0;
75-
params.controller_type = controller_id;
50+
params.controller_type = controller_type_to_id(controller_type);
7651
params.address = address;
7752
params.bytes = bytes;
7853
data = std::string((char*)&params, sizeof(params));

SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_OemController.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1313
#include "NintendoSwitch_SerialPABotBase_OemController.h"
1414

15-
//#include <iostream>
16-
//using std::cout;
17-
//using std::endl;
15+
// REMOVE
16+
#include <iostream>
17+
using std::cout;
18+
using std::endl;
1819

1920
namespace PokemonAutomation{
2021
namespace NintendoSwitch{
@@ -40,6 +41,8 @@ SerialPABotBase_OemController::SerialPABotBase_OemController(
4041
)
4142
, m_controller_type(controller_type)
4243
{
44+
// cout << "controller_type = " << (int)controller_type << endl;
45+
4346
using namespace SerialPABotBase;
4447

4548
switch (controller_type){
@@ -155,6 +158,7 @@ void SerialPABotBase_OemController::set_info(){
155158
colors.right_grip[2] = color.blue();
156159
}
157160

161+
158162
m_serial->issue_request_and_wait(
159163
MessageControllerWriteSpi(
160164
m_controller_type,
@@ -359,6 +363,7 @@ void SerialPABotBase_OemController::update_status(Cancellable& cancellable){
359363
m_logger.log("Reading Controller Colors... Done");
360364

361365
switch (m_controller_type){
366+
case ControllerType::NintendoSwitch_WiredProController:
362367
case ControllerType::NintendoSwitch_WirelessProController:{
363368
Color left(colors.left_grip[0], colors.left_grip[1], colors.left_grip[2]);
364369
Color body(colors.body[0], colors.body[1], colors.body[2]);

0 commit comments

Comments
 (0)