From 239b2ad5fad31c37092f8fb33a89c1016a9b5f4f Mon Sep 17 00:00:00 2001 From: Gin <> Date: Mon, 5 Oct 2026 23:10:21 -0700 Subject: [PATCH] PybindSwitchProController: add controller_name() controller_name() returns the active controller implementation, e.g. "Nintendo Switch: Pro Controller", or an empty string if not ready. Co-Authored-By: Claude Opus 5.5 --- .../Source/Integrations/PybindSwitchController.cpp | 5 +++++ SerialPrograms/Source/Integrations/PybindSwitchController.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/SerialPrograms/Source/Integrations/PybindSwitchController.cpp b/SerialPrograms/Source/Integrations/PybindSwitchController.cpp index 77aae9d4a1..da3f4dd57e 100644 --- a/SerialPrograms/Source/Integrations/PybindSwitchController.cpp +++ b/SerialPrograms/Source/Integrations/PybindSwitchController.cpp @@ -129,6 +129,11 @@ std::string PybindSwitchProController::current_status() const{ PybindSwitchProControllerInternal* internal = (PybindSwitchProControllerInternal*)m_internals; return internal->m_connection->raw_status_text(); } +std::string PybindSwitchProController::controller_name() const{ + PybindSwitchProControllerInternal* internal = (PybindSwitchProControllerInternal*)m_internals; + ProController* controller = internal->controller_if_ready(); + return controller == nullptr ? "" : controller->name(); +} void PybindSwitchProController::wait_for_all_requests(){ diff --git a/SerialPrograms/Source/Integrations/PybindSwitchController.h b/SerialPrograms/Source/Integrations/PybindSwitchController.h index decbe6a252..a59f733e09 100644 --- a/SerialPrograms/Source/Integrations/PybindSwitchController.h +++ b/SerialPrograms/Source/Integrations/PybindSwitchController.h @@ -32,6 +32,8 @@ namespace NintendoSwitch{ // Button bitfields use `NintendoSwitch::Button` values, and d-pad positions use // `NintendoSwitch::DpadPosition` values (0 = up, clockwise to 7 = up-left, 8 = none). // Joystick coordinates are in [-1.0, 1.0] with +x = right and +y = up. +// +// Thread safety: all methods can be called from any thread. class PybindSwitchProController{ PybindSwitchProController(const PybindSwitchProController&) = delete; void operator=(const PybindSwitchProController&) = delete; @@ -58,6 +60,10 @@ class PybindSwitchProController{ // or the error message if the connection failed. std::string current_status() const; + // Name of the active controller implementation, e.g. "Nintendo Switch: Pro Controller". + // Empty if not ready. + std::string controller_name() const; + // Block until every command queued so far has been executed by the device. // Returns immediately if the controller is not ready. void wait_for_all_requests();