Add Enter/ExitCriticalSection to Periphery code
This commit is contained in:
parent
cc92b848f9
commit
2623c0c22c
|
@ -111,7 +111,7 @@ namespace Assets {
|
||||||
|
|
||||||
namespace XAAudio {
|
namespace XAAudio {
|
||||||
void play_fox() {
|
void play_fox() {
|
||||||
CDXA::play(lba, FOX_XA, 1, true);
|
CDXA::play(lba, FOX_XA, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -176,7 +176,6 @@ namespace JabyEngine {
|
||||||
send_read_n0(cur_file.cur_lba);
|
send_read_n0(cur_file.cur_lba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void continue_reading() {
|
void continue_reading() {
|
||||||
if(current_state == State::BufferFull) {
|
if(current_state == State::BufferFull) {
|
||||||
Command::wait_completed();
|
Command::wait_completed();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "../../internal-include/periphery_internal.hpp"
|
#include "../../internal-include/periphery_internal.hpp"
|
||||||
#include <PSX/Periphery/periphery.hpp>
|
#include <PSX/Periphery/periphery.hpp>
|
||||||
|
#include <PSX/System/syscalls.hpp>
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace Periphery {
|
namespace Periphery {
|
||||||
|
@ -87,47 +88,49 @@ namespace JabyEngine {
|
||||||
void query_controller() {
|
void query_controller() {
|
||||||
static constexpr auto TypeIDX = 1;
|
static constexpr auto TypeIDX = 1;
|
||||||
|
|
||||||
Periphery::connect_to(cur_controller_port);
|
SysCall::EnterCriticalSection();
|
||||||
for(uint32_t id = 0; id < Periphery::DeviceCount; id++) {
|
Periphery::connect_to(cur_controller_port);
|
||||||
auto &cur_controller = controller[cur_controller_port][id];
|
for(uint32_t id = 0; id < Periphery::DeviceCount; 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};
|
||||||
|
|
||||||
// Can this move to the if??
|
// Can this move to the if??
|
||||||
set_config_command(cur_controller.header.state, header, data);
|
set_config_command(cur_controller.header.state, header, data);
|
||||||
if(ControllerHelper::is_config(cur_controller)) {
|
if(ControllerHelper::is_config(cur_controller)) {
|
||||||
send_data(header, header, data, data);
|
send_data(header, header, data, data);
|
||||||
ControllerHelper::advance_config(cur_controller);
|
ControllerHelper::advance_config(cur_controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
cur_controller.button.exchange_state();
|
cur_controller.button.exchange_state();
|
||||||
|
|
||||||
send_data(header, header, data, ControllerHelper::raw_device_data(cur_controller));
|
send_data(header, header, data, ControllerHelper::raw_device_data(cur_controller));
|
||||||
const bool isValidController = (header[TypeIDX] != 0xFF);
|
const bool isValidController = (header[TypeIDX] != 0xFF);
|
||||||
|
|
||||||
if(header[TypeIDX] != cur_controller.header.type) {
|
if(header[TypeIDX] != cur_controller.header.type) {
|
||||||
cur_controller.header.type = header[TypeIDX];
|
cur_controller.header.type = header[TypeIDX];
|
||||||
cur_controller.header.state = isValidController ? RawController::State::EnterConfigMode : RawController::State::Disconnected;
|
cur_controller.header.state = isValidController ? RawController::State::EnterConfigMode : RawController::State::Disconnected;
|
||||||
|
|
||||||
/*if(!isValidController)
|
/*if(!isValidController)
|
||||||
{
|
{
|
||||||
printf("Disconnected!\n");
|
printf("Disconnected!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("ID: 0x%02X 0x%04X\n", header[TypeIDX], contData.button);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("ID: 0x%02X 0x%04X\n", header[TypeIDX], contData.button);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Periphery::close_connection();
|
||||||
Periphery::close_connection();
|
|
||||||
|
|
||||||
if(Configuration::Periphery::include_portB()) {
|
if(Configuration::Periphery::include_portB()) {
|
||||||
cur_controller_port ^= 0x1;
|
cur_controller_port ^= 0x1;
|
||||||
}
|
}
|
||||||
|
SysCall::ExitCriticalSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue