Skip to content

Commit

Permalink
Fix errors in my last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Crayon2000 committed Dec 21, 2024
1 parent eff8f70 commit ce6d8a2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ target_compile_options(MiisendU-Wii-U PRIVATE
target_sources(MiisendU-Wii-U PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/console.c
${CMAKE_CURRENT_SOURCE_DIR}/source/udp.c
${CMAKE_CURRENT_SOURCE_DIR}/source/udp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/vpad_to_json.cpp
${inih_SOURCE_DIR}/ini.c
)
Expand Down
16 changes: 5 additions & 11 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,6 @@ static int sendPadData() {
KPADReadEx(WPAD_CHAN_2, &kpad_data3, 1, &kpad_error3);
KPADReadEx(WPAD_CHAN_3, &kpad_data4, 1, &kpad_error4);

// Read the HPADs
int32_t hpad_error1 = HPADRead(HPAD_CHAN_0, &hpad_data1[0], 16);
int32_t hpad_error2 = HPADRead(HPAD_CHAN_1, &hpad_data2[0], 16);
int32_t hpad_error3 = HPADRead(HPAD_CHAN_2, &hpad_data3[0], 16);
int32_t hpad_error4 = HPADRead(HPAD_CHAN_3, &hpad_data4[0], 16);

// Flush the cache (may be needed due to continuous refresh of the data ?)
DCFlushRange(&vpad_data, sizeof(VPADStatus));

Expand All @@ -152,25 +146,25 @@ static int sendPadData() {
{
pad_data.kpad[3] = &kpad_data4;
}
if(hpad_error1 >= 0)
if(HPADRead(HPAD_CHAN_0, &hpad_data1[0], 16) >= 0)
{
pad_data.hpad[0] = &hpad_data1[0];
}
if(hpad_error2 >= 0)
if(HPADRead(HPAD_CHAN_1, &hpad_data2[0], 16) >= 0)
{
pad_data.hpad[1] = &hpad_data2[0];
}
if(hpad_error3 >= 0)
if(HPADRead(HPAD_CHAN_2, &hpad_data3[0], 16) >= 0)
{
pad_data.hpad[2] = &hpad_data3[0];
}
if(hpad_error4 >= 0)
if(HPADRead(HPAD_CHAN_3, &hpad_data4[0], 16) >= 0)
{
pad_data.hpad[3] = &hpad_data4[0];
}

// The buffer sent to the computer
char msg_data[1024];
char msg_data[2048];
pad_to_json(pad_data, msg_data, sizeof(msg_data));

// Send the message
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions source/vpad_to_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ void pad_to_json(PADData pad_data, char* out, uint32_t out_size)
{
if(pad_data.kpad[i]->extensionType != WPAD_EXT_PRO_CONTROLLER)
{ // Wii Remote with or without an extension
wii_remotes_status.emplace(i, pad_data.kpad[i]);
wii_remotes_status.emplace(i + 1, pad_data.kpad[i]);
}
else
{ // Wii U Pro Controller
wii_u_pro_status.emplace(i, pad_data.kpad[i]);
wii_u_pro_status.emplace(i + 1, pad_data.kpad[i]);
}
}
}
if (wii_u_pro_status.empty() == false) {
if (wii_remotes_status.empty() == false) {
writer.Key("wiiRemotes");
writer.StartArray();
for (const auto& [order, kpad] : wii_remotes_status) {
Expand Down

0 comments on commit ce6d8a2

Please sign in to comment.