Skip to content

Commit

Permalink
Send Gamecube controller inputs only when there is no error
Browse files Browse the repository at this point in the history
  • Loading branch information
Crayon2000 committed Dec 21, 2024
1 parent ce6d8a2 commit c31b24c
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,37 +130,49 @@ static int sendPadData() {
PADData pad_data;
memset(&pad_data, 0, sizeof(PADData));
pad_data.vpad = &vpad_data;
if(kpad_error1 == KPADError::KPAD_ERROR_OK)
{
if(kpad_error1 == KPADError::KPAD_ERROR_OK) {
pad_data.kpad[0] = &kpad_data1;
}
if(kpad_error2 == KPADError::KPAD_ERROR_OK)
{
if(kpad_error2 == KPADError::KPAD_ERROR_OK) {
pad_data.kpad[1] = &kpad_data2;
}
if(kpad_error3 == KPADError::KPAD_ERROR_OK)
{
if(kpad_error3 == KPADError::KPAD_ERROR_OK) {
pad_data.kpad[2] = &kpad_data3;
}
if(kpad_error4 == KPADError::KPAD_ERROR_OK)
{
if(kpad_error4 == KPADError::KPAD_ERROR_OK) {
pad_data.kpad[3] = &kpad_data4;
}
if(HPADRead(HPAD_CHAN_0, &hpad_data1[0], 16) >= 0)
{
pad_data.hpad[0] = &hpad_data1[0];
if(HPADRead(HPAD_CHAN_0, &hpad_data1[0], 16) >= 0) {
for(uint8_t i = 0; i < 16; ++i) {
if(hpad_data1[i].error == 0) {
pad_data.hpad[0] = &hpad_data1[i];
break;
}
}
}
if(HPADRead(HPAD_CHAN_1, &hpad_data2[0], 16) >= 0)
{
pad_data.hpad[1] = &hpad_data2[0];
if(HPADRead(HPAD_CHAN_1, &hpad_data2[0], 16) >= 0) {
for(uint8_t i = 0; i < 16; ++i) {
if(hpad_data2[i].error == 0) {
pad_data.hpad[1] = &hpad_data2[i];
break;
}
}
}
if(HPADRead(HPAD_CHAN_2, &hpad_data3[0], 16) >= 0)
{
pad_data.hpad[2] = &hpad_data3[0];
if(HPADRead(HPAD_CHAN_2, &hpad_data3[0], 16) >= 0) {
for(uint8_t i = 0; i < 16; ++i) {
if(hpad_data3[i].error == 0) {
pad_data.hpad[2] = &hpad_data3[i];
break;
}
}
}
if(HPADRead(HPAD_CHAN_3, &hpad_data4[0], 16) >= 0)
{
pad_data.hpad[3] = &hpad_data4[0];
if(HPADRead(HPAD_CHAN_3, &hpad_data4[0], 16) >= 0) {
for(uint8_t i = 0; i < 16; ++i) {
if(hpad_data4[i].error == 0) {
pad_data.hpad[3] = &hpad_data4[i];
break;
}
}
}

// The buffer sent to the computer
Expand Down

0 comments on commit c31b24c

Please sign in to comment.