Integrate all the progress into master #6
|
@ -2,8 +2,10 @@
|
|||
#include <PSX/GPU/gpu.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using DigitalButton = Periphery::GenericController::Button;
|
||||
using namespace JabyEngine;
|
||||
|
||||
// This should go to JabyEngine eventually
|
||||
template<typename T>
|
||||
static GPU::Link* link_array(GPU::Link* last_prim, T* elements, size_t length) {
|
||||
for(size_t n = 0; n < length; n++) {
|
||||
|
@ -20,14 +22,29 @@ namespace ControllerTest {
|
|||
return link_array(last_prim, elements, N);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static void set_active(GPU::SPRT_16::Linked& sprt, bool is_active) {
|
||||
sprt->tex_offset.y = is_active ? 16 : 0;
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerState :: update() {
|
||||
void ControllerState :: update(const Periphery::GenericController& controller) {
|
||||
static const DigitalButton ButtonSprtMap[] = {
|
||||
DigitalButton::Triangle, DigitalButton::Circle, DigitalButton::Cross, DigitalButton::Square,
|
||||
DigitalButton::ST, DigitalButton::SEL, DigitalButton::L1, DigitalButton::L2, DigitalButton::R1, DigitalButton::R2
|
||||
};
|
||||
|
||||
auto& cur_button_sprts = this->buttons[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]));
|
||||
}
|
||||
set_active(cur_button_sprts[12], controller.header.state == Periphery::RawController::State::Disconnected);
|
||||
}
|
||||
|
||||
void ControllerState :: render() {
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace ControllerTest {
|
|||
return true;
|
||||
}
|
||||
|
||||
controller_state.update();
|
||||
controller_state.update(Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include "controller_test_assets.hpp"
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/controller.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
@ -59,7 +60,7 @@ namespace ControllerTest {
|
|||
}
|
||||
|
||||
void setup();
|
||||
void update();
|
||||
void update(const Periphery::GenericController& controller);
|
||||
void render();
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue