diff --git a/core/sdl/dreamconn.cpp b/core/sdl/dreamconn.cpp index 8b22c7904..7c3a08a77 100644 --- a/core/sdl/dreamconn.cpp +++ b/core/sdl/dreamconn.cpp @@ -189,13 +189,13 @@ public: } }; -class DreamPortSerialHandler +class DreamPicoPortSerialHandler { //! Asynchronous context for serial_handler asio::io_context io_context; //! Output buffer data for serial_handler std::string serial_out_data; - //! Handles communication to DreamPort + //! Handles communication to DreamPicoPort asio::serial_port serial_handler{io_context}; //! Set to true while an async write is in progress with serial_handler bool serial_write_in_progress = false; @@ -215,7 +215,7 @@ class DreamPortSerialHandler std::mutex read_cv_mutex; public: - DreamPortSerialHandler() { + DreamPicoPortSerialHandler() { // the serial port isn't ready at this point, so we need to sleep briefly // we probably should have a better way to handle this @@ -227,30 +227,23 @@ public: std::string serial_device = ""; // use user-configured serial device if available, fallback to first available - serial_device = cfgLoadStr("input", "DreamPortSerialDevice", ""); - if (serial_device.empty()) { - serial_device = cfgLoadStr("input", "DreamcastControllerUsbSerialDevice", ""); - if (!serial_device.empty()) { - WARN_LOG(INPUT, "DreamcastControllerUsbSerialDevice config is deprecated; use DreamPortSerialDevice instead"); - } - } - + serial_device = cfgLoadStr("input", "DreamPicoPortSerialDevice", ""); if (!serial_device.empty()) { - NOTICE_LOG(INPUT, "DreamPort connecting to user-configured serial device: %s", serial_device.c_str()); + NOTICE_LOG(INPUT, "DreamPicoPort connecting to user-configured serial device: %s", serial_device.c_str()); } else { serial_device = getFirstSerialDevice(); - NOTICE_LOG(INPUT, "DreamPort connecting to autoselected serial device: %s", serial_device.c_str()); + NOTICE_LOG(INPUT, "DreamPicoPort connecting to autoselected serial device: %s", serial_device.c_str()); } asio::error_code ec; serial_handler.open(serial_device, ec); if (ec || !serial_handler.is_open()) { - WARN_LOG(INPUT, "DreamPort serial connection failed: %s", ec.message().c_str()); + WARN_LOG(INPUT, "DreamPicoPort serial connection failed: %s", ec.message().c_str()); disconnect(); } else { - NOTICE_LOG(INPUT, "DreamPort serial connection successful!"); + NOTICE_LOG(INPUT, "DreamPicoPort serial connection successful!"); } // This must be done before the io_context is run because it will keep io_context from returning immediately @@ -259,7 +252,7 @@ public: io_context_thread = std::make_unique([this](){contextThreadEnty();}); } - ~DreamPortSerialHandler() { + ~DreamPicoPortSerialHandler() { disconnect(); io_context_thread->join(); } @@ -583,11 +576,11 @@ private: } }; -//! See: https://github.com/OrangeFox86/DreamPort -class DreamPortConnection : public DreamcastControllerConnection +//! See: https://github.com/OrangeFox86/DreamPicoPort +class DreamPicoPortConnection : public DreamcastControllerConnection { //! The one and only serial port - static std::unique_ptr serial; + static std::unique_ptr serial; //! Number of devices using the above serial static std::atomic connected_dev_count; //! Current timeout in milliseconds @@ -610,10 +603,10 @@ public: static constexpr const char* VID_PID_GUID = "09120000072f0000"; public: - DreamPortConnection(const DreamPortConnection&) = delete; - DreamPortConnection() = delete; + DreamPicoPortConnection(const DreamPicoPortConnection&) = delete; + DreamPicoPortConnection() = delete; - DreamPortConnection(int joystick_idx, SDL_Joystick* sdl_joystick) : + DreamPicoPortConnection(int joystick_idx, SDL_Joystick* sdl_joystick) : DreamcastControllerConnection() { #if defined(_WIN32) @@ -623,7 +616,7 @@ public: determineHardwareBus(joystick_idx, sdl_joystick); } - ~DreamPortConnection(){ + ~DreamPicoPortConnection(){ disconnect(); } @@ -659,7 +652,7 @@ public: ++connected_dev_count; connection_established = true; if (!serial) { - serial = std::make_unique(); + serial = std::make_unique(); } if (serial && serial->is_open()) { @@ -716,7 +709,7 @@ public: } std::string getName() override { - std::string name = "DreamPort"; + std::string name = "DreamPicoPort"; if (!is_hardware_bus_implied && !is_single_device) { const char portChar = ('A' + hardware_bus); name += " " + std::string(1, portChar); @@ -827,8 +820,8 @@ private: }; // Define the static instances here -std::unique_ptr DreamPortConnection::serial; -std::atomic DreamPortConnection::connected_dev_count = 0; +std::unique_ptr DreamPicoPortConnection::serial; +std::atomic DreamPicoPortConnection::connected_dev_count = 0; DreamConn::DreamConn(int bus, int dreamcastControllerType, int joystick_idx, SDL_Joystick* sdl_joystick) : bus(bus), dreamcastControllerType(dreamcastControllerType) @@ -839,8 +832,8 @@ DreamConn::DreamConn(int bus, int dreamcastControllerType, int joystick_idx, SDL dcConnection = std::make_unique(); break; - case TYPE_DREAMPORT: - dcConnection = std::make_unique(joystick_idx, sdl_joystick); + case TYPE_DREAMPICOPORT: + dcConnection = std::make_unique(joystick_idx, sdl_joystick); break; } } @@ -956,7 +949,7 @@ bool DreamConnGamepad::isDreamcastController(int deviceIndex) // DreamConn VID:4457 PID:4443 // Dreamcast Controller USB VID:1209 PID:2f07 if (memcmp(DreamConnConnection::VID_PID_GUID, guid_str + 8, 16) == 0 || - memcmp(DreamPortConnection::VID_PID_GUID, guid_str + 8, 16) == 0) + memcmp(DreamPicoPortConnection::VID_PID_GUID, guid_str + 8, 16) == 0) { NOTICE_LOG(INPUT, "Dreamcast controller found!"); return true; @@ -977,9 +970,9 @@ DreamConnGamepad::DreamConnGamepad(int maple_port, int joystick_idx, SDL_Joystic { dreamconn = std::make_shared(maple_port, TYPE_DREAMCONN, joystick_idx, sdl_joystick); } - else if (memcmp(DreamPortConnection::VID_PID_GUID, guid_str + 8, 16) == 0) + else if (memcmp(DreamPicoPortConnection::VID_PID_GUID, guid_str + 8, 16) == 0) { - dreamconn = std::make_shared(maple_port, TYPE_DREAMPORT, joystick_idx, sdl_joystick); + dreamconn = std::make_shared(maple_port, TYPE_DREAMPICOPORT, joystick_idx, sdl_joystick); } if (dreamconn) { diff --git a/core/sdl/dreamconn.h b/core/sdl/dreamconn.h index 8d3f9c74a..b6a69e6c7 100644 --- a/core/sdl/dreamconn.h +++ b/core/sdl/dreamconn.h @@ -23,7 +23,7 @@ #if (defined(_WIN32) || defined(__linux__) || (defined(__APPLE__) && defined(TARGET_OS_MAC))) && !defined(TARGET_UWP) #define USE_DREAMCASTCONTROLLER 1 #define TYPE_DREAMCONN 1 -#define TYPE_DREAMPORT 2 +#define TYPE_DREAMPICOPORT 2 #include #endif #include diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp index 09acb494c..a6f84cfcd 100644 --- a/core/sdl/sdl.cpp +++ b/core/sdl/sdl.cpp @@ -271,9 +271,9 @@ void input_sdl_init() // Linux mappings are OK by default // Can be removed once mapping is merged into SDL, see https://github.com/libsdl-org/SDL/pull/12039 #if (defined(__APPLE__) && defined(TARGET_OS_MAC)) - SDL_GameControllerAddMapping("0300000009120000072f000000010000,OrangeFox86 DreamPort,a:b0,b:b1,x:b3,y:b4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:a2,righttrigger:a5,start:b11"); + SDL_GameControllerAddMapping("0300000009120000072f000000010000,OrangeFox86 DreamPicoPort,a:b0,b:b1,x:b3,y:b4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:a2,righttrigger:a5,start:b11"); #elif defined(_WIN32) - SDL_GameControllerAddMapping("0300000009120000072f000000000000,OrangeFox86 DreamPort,a:b0,b:b1,x:b3,y:b4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:-a2,righttrigger:-a5,start:b11"); + SDL_GameControllerAddMapping("0300000009120000072f000000000000,OrangeFox86 DreamPicoPort,a:b0,b:b1,x:b3,y:b4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:-a2,righttrigger:-a5,start:b11"); #endif }