Support more buttons
This commit is contained in:
@@ -28,6 +28,13 @@ namespace ControllerTest {
|
||||
sprt->tex_offset.y = is_active ? 16 : 0;
|
||||
}
|
||||
|
||||
static void set_active(GPU::POLY_FT4::Linked& poly, bool is_active) {
|
||||
poly->tex_offset0.y = is_active ? 16 : 0;
|
||||
poly->tex_offset1.y = is_active ? 16 : 0;
|
||||
poly->tex_offset2.y = is_active ? 32 : 16;
|
||||
poly->tex_offset3.y = is_active ? 32 : 16;
|
||||
}
|
||||
|
||||
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]);
|
||||
@@ -39,11 +46,20 @@ namespace ControllerTest {
|
||||
DigitalButton::Triangle, DigitalButton::Circle, DigitalButton::Cross, DigitalButton::Square,
|
||||
DigitalButton::ST, DigitalButton::SEL, DigitalButton::L1, DigitalButton::L2, DigitalButton::R1, DigitalButton::R2
|
||||
};
|
||||
static const DigitalButton ArrowPolyMap[] = {
|
||||
DigitalButton::Up, DigitalButton::Right, DigitalButton::Down, DigitalButton::Left
|
||||
};
|
||||
|
||||
auto& cur_button_sprts = this->buttons[GPU::update_id()];
|
||||
auto& cur_arrow_poly = this->arrows[GPU::update_id()];
|
||||
|
||||
for(size_t n = 0; n < sizeof(ButtonSprtMap)/sizeof(ButtonSprtMap[0]); n++) {
|
||||
set_active(cur_button_sprts[n], controller.button.is_down(ButtonSprtMap[n]));
|
||||
}
|
||||
for(size_t n = 0; n < sizeof(ArrowPolyMap)/sizeof(ArrowPolyMap[0]); n++) {
|
||||
set_active(cur_arrow_poly[n], controller.button.is_down(ArrowPolyMap[n]));
|
||||
}
|
||||
|
||||
set_active(cur_button_sprts[12], controller.header.state == Periphery::RawController::State::Disconnected);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user