Skip to content

Commit

Permalink
wii: Reset analog inputs for Wiimote
Browse files Browse the repository at this point in the history
This prevents triggering analog inputs when hotswapping extensions.
  • Loading branch information
Mefiresu committed Oct 7, 2022
1 parent b30e21c commit 7f913b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions RSDKv5/RSDK/Input/Wii/WiiInputDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using namespace RSDK;

void RSDK::SKU::InputDeviceWii::UpdateInput() {
s32 WiiPads = WPAD_ScanPads();
WPAD_ScanPads();

this->buttonMasksWii = WPAD_ButtonsHeld(0);
WPADData *data = WPAD_Data(0);
Expand All @@ -25,6 +25,9 @@ void RSDK::SKU::InputDeviceWii::UpdateInput() {
this->stateZ = (this->buttonMasksWii & 0) != 0;
this->stateStart = (this->buttonMasksWii & WPAD_BUTTON_PLUS) != 0;
this->stateSelect = (this->buttonMasksWii & WPAD_BUTTON_MINUS) != 0;
// Reset analog input to prevent it from triggering a movement
this->vDelta_L = 0.0f;
this->hDelta_L = 0.0f;
break;
case WPAD_EXP_NUNCHUK:
this->stateUp = (this->buttonMasksWii & WPAD_BUTTON_UP) != 0;
Expand Down Expand Up @@ -59,10 +62,10 @@ void RSDK::SKU::InputDeviceWii::UpdateInput() {
this->hDelta_L = (float)(data->exp.classic.ljs.pos.x - data->exp.classic.ljs.center.x) / ((float)data->exp.classic.ljs.max.x / 2.0f);
break;
}
if (PAD_ScanPads() > 0) // checks if a gamecube controller is plugged into the wii
{
// checks if a gamecube controller is plugged into the wii
if (PAD_ScanPads() > 0) {
this->buttonMasksGC = PAD_ButtonsHeld(0);

this->stateUp |= (this->buttonMasksGC & PAD_BUTTON_UP) != 0;
this->stateDown |= (this->buttonMasksGC & PAD_BUTTON_DOWN) != 0;
this->stateLeft |= (this->buttonMasksGC & PAD_BUTTON_LEFT) != 0;
Expand Down

0 comments on commit 7f913b7

Please sign in to comment.