Skip to content
Draft
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* PABotBase2 Device Handle

Check warning on line 1 in SerialPrograms/Source/Controllers/PABotBase2/PABotBase2_DeviceHandle.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=553 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -79,7 +79,7 @@

void DeviceHandle::add_message_handler(
uint8_t opcode,
std::function<void(const MessageHeader*)> handler
MoveOnlyFunction<void(const MessageHeader*)> handler
){
auto ret = m_message_handlers.emplace(opcode, std::move(handler));
if (!ret.second){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <deque>
#include <map>
#include "Common/Cpp/Exceptions.h"
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/PrettyPrint.h"
#include "Common/Cpp/Logging/AbstractLogger.h"
#include "Common/Cpp/Concurrency/Mutex.h"
Expand Down Expand Up @@ -38,7 +39,7 @@ class DeviceHandle final : public CancellableScope, private StreamListener{
virtual ~DeviceHandle();
void add_message_handler(
uint8_t opcode,
std::function<void(const MessageHeader*)> handler
MoveOnlyFunction<void(const MessageHeader*)> handler
);

virtual bool cancel(std::exception_ptr exception) noexcept override;
Expand Down Expand Up @@ -196,7 +197,7 @@ class DeviceHandle final : public CancellableScope, private StreamListener{
std::deque<char> m_buffer;

MessageLogger m_message_loggers;
std::map<uint8_t, std::function<void(const MessageHeader*)>> m_message_handlers;
std::map<uint8_t, MoveOnlyFunction<void(const MessageHeader*)>> m_message_handlers;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PABotBase2_JoyCon :
PABotBase2::Connection& connection,
ControllerClass controller_class,
ControllerType controller_type,
std::function<void(double magnitude)> on_rumble
MoveOnlyFunction<void(double magnitude)> on_rumble
)
: JoyconType(logger, controller_class)
, PABotBase2_OemController(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* PABotBase2: OEM Controller (Nintendo Switch 1)

Check warning on line 1 in SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_OemController.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=787 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -122,7 +122,7 @@
RecursiveThrottler& logging_throttler,
PABotBase2::Connection& connection,
ControllerType controller_type,
std::function<void(double magnitude)> on_rumble
MoveOnlyFunction<void(double magnitude)> on_rumble
)
: PABotBase2_Controller(logger, logging_throttler, connection)
, m_controller_type(controller_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define PokemonAutomation_NintendoSwitch_PABotBase2_OemController_H

#include "Common/ControllerStates/NintendoSwitch_OemController_State.h"
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Controllers/ControllerStatusThread.h"
#include "Controllers/JoystickTools.h"
//#include "NintendoSwitch/NintendoSwitch_Settings.h"
Expand Down Expand Up @@ -36,7 +37,7 @@ class PABotBase2_OemController :
RecursiveThrottler& logging_throttler,
PABotBase2::Connection& connection,
ControllerType controller_type,
std::function<void(double magnitude)> on_rumble
MoveOnlyFunction<void(double magnitude)> on_rumble
);
~PABotBase2_OemController();
void stop();
Expand Down Expand Up @@ -166,7 +167,7 @@ class PABotBase2_OemController :
Milliseconds m_cooldown;
Milliseconds m_timing_variation;

std::function<void(double magnitude)> m_on_rumble;
MoveOnlyFunction<void(double magnitude)> m_on_rumble;

std::unique_ptr<ControllerStatusThread> m_status_thread;

Expand Down
Loading