From e30817906c2e65afdcb05b8058208cdb91e24779 Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 4 Jan 2024 21:54:21 -0600 Subject: [PATCH] Display type of controller --- .../ControllerTest/controller_state.cpp | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp index cef48b0d..514b52e7 100644 --- a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp +++ b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_state.cpp @@ -35,6 +35,40 @@ namespace ControllerTest { poly->tex_offset3.y = is_active ? 32 : 16; } + static const char* get_type_name(Periphery::ControllerType type) { + switch(type) { + case Periphery::ControllerType::Unkown: + return "Unkown"; + + case Periphery::ControllerType::Mouse: + return "Mouse"; + + case Periphery::ControllerType::NegCon: + return "NegCon"; + + case Periphery::ControllerType::HyperBlaster: + return "HyperBlaster"; + + case Periphery::ControllerType::Controller: + return "Digital Controller"; + + case Periphery::ControllerType::ArcadeFlightStick: + return "Flight Stick"; + + case Periphery::ControllerType::GCon: + return "GCon"; + + case Periphery::ControllerType::DualShock: + return "DualShock"; + + case Periphery::ControllerType::MultiTap: + return "MultiTap"; + + default: + return "???"; + } + } + void ControllerState :: setup() { for(size_t n = 0; n < 2; n++) { link_array(link_array(&this->tex_page[n], this->buttons[n]), this->arrows[n]); @@ -68,7 +102,8 @@ namespace ControllerTest { const auto right_stick = controller.get_right_stick_pos(); auto cursor = State::create(Make::PositionI16(98, 0), 0); - font_writer.write(cursor, "Right: %i, %i\n Left: %i, %i", right_stick.x, right_stick.y, left_stick.x, left_stick.y); + font_writer.write(cursor, "Right: %i, %i\nLeft : %i, %i\n", right_stick.x, right_stick.y, left_stick.x, left_stick.y); + font_writer.write(cursor, "[%s]", get_type_name(static_cast(controller.get_type()))); } void ControllerState :: render() {