Support MultiTap and read ports every other frame
This commit is contained in:
parent
c6089d64a1
commit
b760474859
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace Periphery {
|
namespace Periphery {
|
||||||
static constexpr uint32_t PortCount = Configuration::Periphery::UsePortB ? 2 : 1;
|
static constexpr uint32_t PortCount = Configuration::Periphery::IncludePortB ? 2 : 1;
|
||||||
static constexpr uint32_t DeviceCount = Configuration::Periphery::UseMultiTap ? 4 : 1;
|
static constexpr uint32_t DeviceCount = Configuration::Periphery::UseMultiTap ? 4 : 1;
|
||||||
|
|
||||||
extern RawController controller[PortCount][DeviceCount];
|
extern RawController controller[PortCount][DeviceCount];
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace JabyEngine {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Periphery {
|
struct Periphery {
|
||||||
static constexpr bool UsePortB = false;
|
static constexpr bool IncludePortB = false;
|
||||||
static constexpr bool UseMultiTap = false;
|
static constexpr bool UseMultiTap = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace Periphery {
|
namespace Periphery {
|
||||||
|
// Controllers are checked every alternating frame
|
||||||
|
static uint8_t cur_controller_port = 0;
|
||||||
RawController controller[PortCount][DeviceCount];
|
RawController controller[PortCount][DeviceCount];
|
||||||
|
|
||||||
struct ControllerHelper {
|
struct ControllerHelper {
|
||||||
|
@ -86,10 +88,9 @@ namespace JabyEngine {
|
||||||
void query_controller() {
|
void query_controller() {
|
||||||
static constexpr auto TypeIDX = 1;
|
static constexpr auto TypeIDX = 1;
|
||||||
|
|
||||||
for(uint32_t port = 0; port < Periphery::PortCount; port++) {
|
Periphery::connect_to(cur_controller_port);
|
||||||
Periphery::connect_to(port);
|
|
||||||
for(uint32_t id = 0; id < Periphery::DeviceCount; id++) {
|
for(uint32_t id = 0; id < Periphery::DeviceCount; id++) {
|
||||||
auto &cur_controller = controller[port][id];
|
auto &cur_controller = controller[cur_controller_port][id];
|
||||||
|
|
||||||
uint8_t header[] = {static_cast<uint8_t>((id + 1)), 0x42, 0x0};
|
uint8_t header[] = {static_cast<uint8_t>((id + 1)), 0x42, 0x0};
|
||||||
uint8_t data[] = {cur_controller.header.rumble0, cur_controller.header.rumble1, 0x0, 0x0, 0x0, 0x0};
|
uint8_t data[] = {cur_controller.header.rumble0, cur_controller.header.rumble1, 0x0, 0x0, 0x0, 0x0};
|
||||||
|
@ -124,10 +125,10 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Periphery::close_connection();
|
Periphery::close_connection();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static_assert(!Configuration::Periphery::UsePortB, "Port B not supported yet");
|
if(Configuration::Periphery::IncludePortB) {
|
||||||
static_assert(!Configuration::Periphery::UseMultiTap, "MultiTap not supported yet");
|
cur_controller_port ^= 0x1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue