Display type of controller

This commit is contained in:
jaby 2024-01-04 21:54:21 -06:00
parent b2e25c6dc3
commit 8a7bcf92fa
1 changed files with 36 additions and 1 deletions

View File

@ -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<Periphery::ControllerType>(controller.get_type())));
}
void ControllerState :: render() {