diff --git a/Common/SerialPABotBase/SerialPABotBase_Messages_HID_Keyboard.h b/Common/SerialPABotBase/SerialPABotBase_Messages_HID_Keyboard.h deleted file mode 100644 index 94dab4147a..0000000000 --- a/Common/SerialPABotBase/SerialPABotBase_Messages_HID_Keyboard.h +++ /dev/null @@ -1,37 +0,0 @@ -/* SerialPABotBase Messages (HID Keyboard) - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#ifndef PokemonAutomation_SerialPABotBase_Messages_HID_Keyboard_H -#define PokemonAutomation_SerialPABotBase_Messages_HID_Keyboard_H - -#include "../ControllerStates/StandardHid_Keyboard_State.h" -#include "SerialPABotBase_Protocol.h" - -#pragma pack(push, 1) - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define PABB_MSG_COMMAND_HID_KEYBOARD_STATE 0x82 -typedef struct{ - seqnum_t seqnum; - uint16_t milliseconds; - pabb_HID_Keyboard_State report; -} pabb_Message_Command_HID_Keyboard_State; - - - -#ifdef __cplusplus -} -#endif - - -#pragma pack(pop) - -#endif diff --git a/Common/SerialPABotBase/SerialPABotBase_Messages_NS1_OemControllers.h b/Common/SerialPABotBase/SerialPABotBase_Messages_NS1_OemControllers.h deleted file mode 100644 index 4823077d1f..0000000000 --- a/Common/SerialPABotBase/SerialPABotBase_Messages_NS1_OemControllers.h +++ /dev/null @@ -1,93 +0,0 @@ -/* SerialPABotBase Messages (Nintendo Switch 1 OEM Controllers) - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#ifndef PokemonAutomation_SerialPABotBase_Messages_NS1_OemControllers_H -#define PokemonAutomation_SerialPABotBase_Messages_NS1_OemControllers_H - -#include "../ControllerStates/NintendoSwitch_OemController_State.h" -#include "SerialPABotBase_Protocol.h" - -#pragma pack(push, 1) - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef struct{ - uint8_t body[3]; - uint8_t buttons[3]; - uint8_t left_grip[3]; - uint8_t right_grip[3]; -} PABB_NintendoSwitch_ControllerColors; - - - - - -#define PABB_MSG_INFO_NS1_OEM_CONTROLLER_RUMBLE 0x30 -typedef struct{ - OemController_RumbleState rumble; -} pabb_MsgInfo_NS1_OemController_Rumble; - -#define PABB_MSG_INFO_NS1_OEM_CONTROLLER_USB_DISALLOWED 0x31 - - - -#define PABB_MSG_REQUEST_NS1_OEM_CONTROLLER_READ_SPI 0x60 -typedef struct{ - seqnum_t seqnum; - uint32_t controller_type; - uint32_t address; - uint8_t bytes; -} pabb_Message_NS1_OemController_ReadSpi; - -#define PABB_MSG_REQUEST_NS1_OEM_CONTROLLER_WRITE_SPI 0x61 -typedef struct{ - seqnum_t seqnum; - uint32_t controller_type; - uint32_t address; - uint8_t bytes; -} pabb_Message_NS1_OemController_WriteSpi; - -#define PABB_MSG_REQUEST_NS1_OEM_CONTROLLER_PLAYER_LIGHTS 0x62 -typedef struct{ - seqnum_t seqnum; - uint32_t controller_type; -} pabb_MsgInfo_NS1_OemController_PlayerLights; - - - -#define PABB_MSG_COMMAND_NS1_OEM_CONTROLLER_BUTTONS 0xa0 -typedef struct{ - seqnum_t seqnum; - uint16_t milliseconds; - pabb_NintendoSwitch_OemController_State0x30_Buttons buttons; -} pabb_Message_Command_NS1_OemController_Buttons; - - -#define PABB_MSG_COMMAND_NS1_OEM_CONTROLLER_FULL_STATE 0xa1 -typedef struct{ - seqnum_t seqnum; - uint16_t milliseconds; - pabb_NintendoSwitch_OemController_State0x30 state; -} pabb_Message_Command_NS1_OemController_FullState; - - - - -#ifdef __cplusplus -} -#endif - - - -#pragma pack(pop) - - -#endif diff --git a/Common/SerialPABotBase/SerialPABotBase_Messages_NS_WiredController.h b/Common/SerialPABotBase/SerialPABotBase_Messages_NS_WiredController.h deleted file mode 100644 index 470554e46a..0000000000 --- a/Common/SerialPABotBase/SerialPABotBase_Messages_NS_WiredController.h +++ /dev/null @@ -1,37 +0,0 @@ -/* SerialPABotBase Messages (Nintendo Switch Wired Controller) - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#ifndef PokemonAutomation_SerialPABotBase_Messages_NS_WiredController_H -#define PokemonAutomation_SerialPABotBase_Messages_NS_WiredController_H - -#include "../ControllerStates/NintendoSwitch_WiredController_State.h" -#include "SerialPABotBase_Protocol.h" - -#pragma pack(push, 1) - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define PABB_MSG_COMMAND_NS_WIRED_CONTROLLER_STATE 0x90 -typedef struct{ - seqnum_t seqnum; - uint16_t milliseconds; - pabb_NintendoSwitch_WiredController_State report; -} pabb_Message_Command_NS_WiredController_State; - - - -#ifdef __cplusplus -} -#endif - - -#pragma pack(pop) - -#endif diff --git a/Common/SerialPABotBase/SerialPABotBase_Protocol.h b/Common/SerialPABotBase/SerialPABotBase_Protocol.h deleted file mode 100644 index a9d91d3f38..0000000000 --- a/Common/SerialPABotBase/SerialPABotBase_Protocol.h +++ /dev/null @@ -1,397 +0,0 @@ -/* Serial PABotBase Message Protocol - * - * From: https://github.com/PokemonAutomation/ - * - * - * Pokemon Automation Bot-Base implements reliable data transmissions over - * serial communication. This is done by checksumming messages along with a - * protocol that is tolerant to data drops. - * - * This file describes the message protocol. The data being transmitted is raw - * binary and not is readable text. - * - * - * Message Format: - * byte 0: Length of the entire message. (bits are inverted) - * byte 1: Message Type - * byte X: Optional data of variable length. - * Last 4 bytes: CRC32C of the entire message except these last 4 bytes. - * - * Thus there are 6 bytes of overhead for each message. - * - * - * There are currently 4 categories of message types: - * - * 1. Info: These are simple one-way messages. They do not need to be - * acked and may be dropped without adversely affecting anything. - * - * 2. Ack/Response: These are messages sent in response to an earlier - * message that was received. - * - * 3. Request: The sender requests the receiver to do something simple. - * The receiver must respond with an ack. - * - * This is used for things that take no clock time. For example, querying - * for program identifiers, turning on/off LEDs, or setting flags in the - * program to change its behavior in the future. - * - * 4. Command: The sender requests the receiver to do a large asynchronous - * operation. The receiver must ack this message. Once the command is - * finished, the receiver must send a request message back to the sender - * to indicate that the command is finished. - * - * This is used for issuing button presses or other subroutines that - * consume time. - * - * - * General Protocol: - * - * 1. Every time you send a new request/command message, you increment - * your sequence number (seqnum) by 1. - * - * 2. If you receive an invalid message (bad length or bad checksum), ignore - * the first byte and attempt to parse the next byte as the start of a - * new message. - * - * 3. If you receive a zero for the 1st byte of a message, ignore it and - * attempt to parse the next byte as the start of a new message. - * - * 4. At any point, you can send a bunch of zero bytes. This will cause - * the receiver to re-synchronize. - * - * 5. If you receive a request/command message, you must send the appropriate - * ack/response message using the same seqnum. - * - * 6. If you receive a command message, you must first ack the message itself. - * Once the command is finished, you must send a request referencing the - * command to indicate that it is finished. You will receive an ack for - * this short (finishing) command, and if you don't, send it again until - * you do. If the command finishes immediately, you can skip the ack and - * just send the finish request. - * - * 7. If you send a request/command message and don't get a response after - * a time limit, you should resend the message with the same seqnum. - * - * 8. If you receive a request/command that has a seqnum ahead of what you - * are expecting, it means an earlier request/command was dropped. - * Do not process the request/command since you will lose ordering. - * - * 9. If you receive a request/command that has an old seqnum, it is a - * retransmit. Send an ack for it, but don't process it again. (idempotency) - * - * - * Failure Analysis: - * - * - Corrupted messages will either fail checksum or will have an invalid - * length/type. These are simply ignored and dropped. - * - * - If either sender or receiver gets out-of-sync and loses track of - * message boundaries, it will eventually find the boundary again by - * simply trying to parse every byte as the start of a new message and - * verifying the length and CRC. - * - * - If a request/command is dropped, no ack will be received. The sender - * will eventually send the command again. (#7) - * - * - If an ack is dropped, the sender will eventually resend the - * request/command again. The receiver will see the duplicate - * request/command and ack it. But the receiver will not process it - * again to preserve idempotency. (#9) - * - * The current protocol guarantees that all commands are processed in order - * exactly once. Requests are not guaranteed to process in order and may execute - * more than once so they should be idempotent. - * - * The protocol also allows both sides to queue up requests and commands. - * In other words, it is possible to send multiple requests/commands at once - * without waiting for the individual acks. - * - * - * PABotBase Specifics: - * - * - PABotBase can queue up to 4 commands. If it receives any commands - * while the queue is full, it drops it and responds with - * "PABB_MSG_ERROR_COMMAND_DROPPED". (Any command that results in a - * button press or a wait is a long command.) - * - * - PABotBase can still handle other messages while it is running a long - * command. - * - */ - -#ifndef PokemonAutomation_SerialPABotBase_Protocol_H -#define PokemonAutomation_SerialPABotBase_Protocol_H - -#include -#include - -#pragma pack(push, 1) - -#ifdef __cplusplus -extern "C" { -#endif - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// - -#define PABB_BAUD_RATE 115200 -#define PABB_PROTOCOL_OVERHEAD (2 + sizeof(uint32_t)) -#define PABB_PROTOCOL_MAX_PACKET_SIZE 64 - -// Must be a power-of-two. -#define PABB_DEVICE_MINIMUM_QUEUE_SIZE 4 - -typedef uint32_t seqnum_t; - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// Basic Message Types - -#define PABB_MSG_IS_ERROR(x) (((x) & 0xf0) == 0x00) // Framework errors between 0x00 - 0x0f. -#define PABB_MSG_IS_ACK(x) (((x) & 0xf0) == 0x10) // Acks between 0x10 - 0x1f. -#define PABB_MSG_IS_INFO(x) (((x) & 0xe0) == 0x20) // Custom info between 0x20 - 0x3f. -#define PABB_MSG_IS_REQUEST(x) (((x) & 0xc0) == 0x40) // Requests between 0x40 - 0x7f. -#define PABB_MSG_IS_COMMAND(x) ((x) >= 0x80) // Commands between 0x80 - 0xff. - -#define PABB_MSG_IS_REQUEST_OR_COMMAND(x) ((x) >= 0x40) - -//////////////////////////////////////////////////////////////////////////////// -// Framework Errors -#define PABB_MSG_ERROR_READY 0x00 -// No Parameters - -#define PABB_MSG_ERROR_INVALID_MESSAGE 0x01 -typedef struct{ - uint8_t message_length; -} pabb_MsgInfoInvalidMessage; - -#define PABB_MSG_ERROR_CHECKSUM_MISMATCH 0x02 -typedef struct{ - uint8_t message_length; -} pabb_MsgInfoChecksumMismatch; - -#define PABB_MSG_ERROR_INVALID_TYPE 0x03 -typedef struct{ - uint8_t type; -} pabb_MsgInfoInvalidType; - -#define PABB_MSG_ERROR_INVALID_REQUEST 0x04 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgInfoInvalidRequest; - -#define PABB_MSG_ERROR_MISSED_REQUEST 0x05 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgInfoMissedRequest; - -#define PABB_MSG_ERROR_COMMAND_DROPPED 0x06 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgInfoCommandDropped; - -#define PABB_MSG_ERROR_WARNING 0x07 -typedef struct{ - uint16_t error_code; -} pabb_MsgInfoWARNING; - -#define PABB_MSG_ERROR_DISCONNECTED 0x08 -typedef struct{ - uint16_t error_code; -} pabb_MsgInfoDisconnected; - -//////////////////////////////////////////////////////////////////////////////// -// Ack - -#define PABB_MSG_ACK_COMMAND 0x10 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgAckCommand; - -#define PABB_MSG_ACK_REQUEST 0x11 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgAckRequest; - -#define PABB_MSG_ACK_REQUEST_I8 0x12 -typedef struct{ - seqnum_t seqnum; - uint8_t data; -} pabb_MsgAckRequestI8; - -#define PABB_MSG_ACK_REQUEST_I16 0x13 -typedef struct{ - seqnum_t seqnum; - uint16_t data; -} pabb_MsgAckRequestI16; - -#define PABB_MSG_ACK_REQUEST_I32 0x14 -typedef struct{ - seqnum_t seqnum; - uint32_t data; -} pabb_MsgAckRequestI32; - -#define PABB_MSG_ACK_REQUEST_DATA 0x1f -typedef struct{ - seqnum_t seqnum; -} pabb_MsgAckRequestData; - -//////////////////////////////////////////////////////////////////////////////// -// Custom Info - -#define PABB_MSG_INFO_I32 0x20 -typedef struct{ - uint8_t tag; - uint32_t data; -} pabb_MsgInfoI32; - -#define PABB_MSG_INFO_DATA 0x21 -typedef struct{ - uint32_t tag; -} pabb_MsgInfoData; - -#define PABB_MSG_INFO_STRING 0x23 - -#define PABB_MSG_INFO_I32_LABEL 0x24 -#define PABB_MSG_INFO_H32_LABEL 0x25 -typedef struct{ - uint32_t value; -} pabb_MsgInfoI32Label; - -typedef uint8_t pabb_DeviceResetReason; -#define PABB_DeviceResetReason_UNKNOWN 0x00 -#define PABB_DeviceResetReason_OTHER 0x01 -#define PABB_DeviceResetReason_POWER_ON 0x02 -#define PABB_DeviceResetReason_MANUAL 0x03 -#define PABB_DeviceResetReason_BROWNOUT 0x04 -#define PABB_DeviceResetReason_CRASH 0x05 - -#define PABB_MSG_INFO_DEVICE_RESET_REASON 0x26 -typedef struct{ - pabb_DeviceResetReason reason; - uint32_t native_code; -} pabb_MsgDeviceReset; - -//////////////////////////////////////////////////////////////////////////////// -// Static Requests - -#define PABB_MSG_SEQNUM_RESET 0x40 -// After you send this message, the next seqnum you should use is (seqnum + 1). -typedef struct{ - seqnum_t seqnum; -} pabb_MsgInfoSeqnumReset; - -#define PABB_MSG_REQUEST_PROTOCOL_VERSION 0x41 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestProtocolVersion; - -#define PABB_MSG_REQUEST_PROGRAM_VERSION 0x42 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestProgramVersion; - -#define PABB_MSG_REQUEST_PROGRAM_ID 0x43 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestProgramID; - -#define PABB_MSG_REQUEST_PROGRAM_NAME 0x44 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestProgramName; - -#define PABB_MSG_REQUEST_CONTROLLER_LIST 0x45 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestControllerList; - -#define PABB_MSG_REQUEST_QUEUE_SIZE 0x46 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestQueueSize; - -//////////////////////////////////////////////////////////////////////////////// -// Mode Requests - -#define PABB_MSG_REQUEST_READ_CONTROLLER_MODE 0x47 -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestReadControllerMode; - -#define PABB_MSG_REQUEST_CHANGE_CONTROLLER_MODE 0x48 // Change controller and keep settings. -#define PABB_MSG_REQUEST_RESET_TO_CONTROLLER 0x49 // Change controller and wipe settings. (unpair from host) -typedef struct{ - seqnum_t seqnum; - uint32_t controller_id; -} pabb_MsgRequestChangeControllerMode; - -//////////////////////////////////////////////////////////////////////////////// -// Command Queue Requests - -#define PABB_MSG_REQUEST_COMMAND_FINISHED 0x4a -// When you receive this message, you must ack it with PABB_MSG_ACK_REQUEST. -typedef struct{ - seqnum_t seqnum; - seqnum_t seq_of_original_command; - uint32_t finish_time; -} pabb_MsgRequestCommandFinished; - -#define PABB_MSG_REQUEST_STOP 0x4b -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestStop; - -#define PABB_MSG_REQUEST_NEXT_CMD_INTERRUPT 0x4c -typedef struct{ - seqnum_t seqnum; -} pabb_MsgRequestNextCmdInterrupt; - -//////////////////////////////////////////////////////////////////////////////// -// Other Requests - -#define PABB_MSG_REQUEST_CLOCK 0x4f // Deprecated -typedef struct{ - seqnum_t seqnum; -} pabb_system_clock; - -#define PABB_MSG_REQUEST_STATUS 0x50 -typedef struct{ - seqnum_t seqnum; -} pabb_Message_RequestStatus; - -#define PABB_MSG_REQUEST_READ_MAC_ADDRESS 0x51 -typedef struct{ - seqnum_t seqnum; - uint32_t mode; -} pabb_MsgRequestReadMacAddress; - -#define PABB_MSG_REQUEST_PAIRED_MAC_ADDRESS 0x52 -typedef struct{ - seqnum_t seqnum; - uint32_t mode; -} pabb_MsgRequestPairedMacAddress; - -//////////////////////////////////////////////////////////////////////////////// -// Commands - -// These are no longer supported by anything. - -#if 0 -#define PABB_MSG_COMMAND_SET_LED_STATE 0x81 -typedef struct{ - seqnum_t seqnum; - bool on; -} pabb_MsgCommandSetLeds; -#endif - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -} -#endif - -#pragma pack(pop) - -#endif diff --git a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp index 4a34405616..62478f43b8 100644 --- a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp +++ b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp @@ -35,7 +35,6 @@ #include "Common/Cpp/StreamConnections/MockDevice.h" #include "Common/Cpp/TestRunners/ParallelUnitTestRunner.h" #include "Common/Qt/TimeQt.h" -#include "Common/SerialPABotBase/SerialPABotBase_Protocol.h" #include "Kernels/Waterfill/Kernels_Waterfill.h" #include "Kernels/BinaryImageFilters/Kernels_BinaryImage_BasicFilters.h" #include "Kernels/ImageStats/Kernels_ImagePixelSumSqr.h" diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index e3a854eb06..e029e68ee2 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -505,10 +505,6 @@ file(GLOB LIBRARY_SOURCES ../Common/Qt/UiStateQtWidget.h ../Common/Qt/WidgetStackFixedAspectRatio.cpp ../Common/Qt/WidgetStackFixedAspectRatio.h - ../Common/SerialPABotBase/SerialPABotBase_Messages_HID_Keyboard.h - ../Common/SerialPABotBase/SerialPABotBase_Messages_NS1_OemControllers.h - ../Common/SerialPABotBase/SerialPABotBase_Messages_NS_WiredController.h - ../Common/SerialPABotBase/SerialPABotBase_Protocol.h Source/CommonFramework/AudioPipeline/AudioConstants.h Source/CommonFramework/AudioPipeline/AudioFeed.h Source/CommonFramework/AudioPipeline/AudioFormat.cpp