diff --git a/docs/usage.md b/docs/usage.md index b0e2a2e9f..946f658bc 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -83,4 +83,4 @@ A number of hotkeys are enabled by default and if you are encountering issues wi ## Add-Ons and Additional Features -There are a number of add-ons that expand the functionality of GP2040-CE, such as [analog stick emulation](add-ons/analog) and [turbo functions](add-ons/turbo). Due to the large number of add-ons created by the community, they are located in a separate documentation page. Navigate to [Add-Ons page](add-ons) for more information on the individual add-ons. \ No newline at end of file +There are a number of add-ons that expand the functionality of GP2040-CE, such as [analog stick emulation](add-ons/analog) and [turbo functions](add-ons/turbo). Due to the large number of add-ons created by the community, they are located in a separate documentation page. Navigate to [Add-Ons page](add-ons) for more information on the individual add-ons. diff --git a/headers/addons/wiiext.h b/headers/addons/wiiext.h index 73cbf19fa..0a7d6cb3b 100644 --- a/headers/addons/wiiext.h +++ b/headers/addons/wiiext.h @@ -297,6 +297,8 @@ class WiiExtensionInput : public GPAddon { bool dpadLeft = false; bool dpadRight = false; + bool isAnalogTriggers = false; + uint16_t triggerLeft = 0; uint16_t triggerRight = 0; uint16_t lastTriggerLeft = 0; diff --git a/src/addons/keyboard_host.cpp b/src/addons/keyboard_host.cpp index a5294e940..0ba9e3515 100644 --- a/src/addons/keyboard_host.cpp +++ b/src/addons/keyboard_host.cpp @@ -69,8 +69,10 @@ void KeyboardHostAddon::preprocess() { gamepad->state.ly |= _keyboard_host_state.ly; gamepad->state.rx |= _keyboard_host_state.rx; gamepad->state.ry |= _keyboard_host_state.ry; - gamepad->state.lt |= _keyboard_host_state.lt; - gamepad->state.rt |= _keyboard_host_state.rt; + if (!gamepad->hasAnalogTriggers) { + gamepad->state.lt |= _keyboard_host_state.lt; + gamepad->state.rt |= _keyboard_host_state.rt; + } } void KeyboardHostAddon::mount(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len) { diff --git a/src/addons/wiiext.cpp b/src/addons/wiiext.cpp index 235e2ba53..37e3a531a 100644 --- a/src/addons/wiiext.cpp +++ b/src/addons/wiiext.cpp @@ -105,6 +105,8 @@ void WiiExtensionInput::update() { // WII_SET_MASK(buttonState, wii->getController()->buttons[extensionButton], value); //} + isAnalogTriggers = false; + if (wii->extensionType == WII_EXTENSION_NUNCHUCK) { buttonZ = wii->getController()->buttons[WiiButtons::WII_BUTTON_Z]; buttonC = wii->getController()->buttons[WiiButtons::WII_BUTTON_C]; @@ -136,6 +138,7 @@ void WiiExtensionInput::update() { if (wii->extensionType == WII_EXTENSION_CLASSIC) { triggerLeft = wii->getController()->analogState[WiiAnalogs::WII_ANALOG_LEFT_TRIGGER]; triggerRight = wii->getController()->analogState[WiiAnalogs::WII_ANALOG_RIGHT_TRIGGER]; + isAnalogTriggers = true; } leftX = map(wii->getController()->analogState[WiiAnalogs::WII_ANALOG_LEFT_X],0,WII_ANALOG_PRECISION_3,GAMEPAD_JOYSTICK_MIN,GAMEPAD_JOYSTICK_MAX); @@ -211,6 +214,8 @@ void WiiExtensionInput::update() { triggerLeft = wii->getController()->analogState[TurntableAnalogs::TURNTABLE_EFFECTS]; triggerRight = wii->getController()->analogState[TurntableAnalogs::TURNTABLE_CROSSFADE]; + + isAnalogTriggers = true; } } else { currentConfig = NULL; @@ -330,7 +335,7 @@ void WiiExtensionInput::queueAnalogChange(uint16_t analogInput, uint16_t analogV void WiiExtensionInput::updateAnalogState() { Gamepad * gamepad = Storage::getInstance().GetGamepad(); - gamepad->hasAnalogTriggers = true; + gamepad->hasAnalogTriggers = isAnalogTriggers; uint16_t axisType; uint16_t analogInput; @@ -363,6 +368,8 @@ void WiiExtensionInput::updateAnalogState() { axisToChange = WII_ANALOG_TYPE_NONE; adjustedValue = 0; + if (!isAnalogTriggers && ((analogInput == WiiAnalogs::WII_ANALOG_LEFT_TRIGGER) || (analogInput == WiiAnalogs::WII_ANALOG_RIGHT_TRIGGER))) continue; + // define ranges switch (analogInput) { case WiiAnalogs::WII_ANALOG_LEFT_X: diff --git a/src/gamepad.cpp b/src/gamepad.cpp index 71b1b4608..f220c4ce1 100644 --- a/src/gamepad.cpp +++ b/src/gamepad.cpp @@ -563,8 +563,8 @@ XInputReport *Gamepad::getXInputReport() if (hasAnalogTriggers) { - xinputReport.lt = state.lt; - xinputReport.rt = state.rt; + xinputReport.lt = pressedL2() ? 0xFF : state.lt; + xinputReport.rt = pressedR2() ? 0xFF : state.rt; } else { diff --git a/www/src/Addons/Wii.tsx b/www/src/Addons/Wii.tsx index 7eb14278c..1ca7690eb 100644 --- a/www/src/Addons/Wii.tsx +++ b/www/src/Addons/Wii.tsx @@ -103,7 +103,8 @@ const Wii = ({ values, errors, handleChange, handleCheckbox }) => { .reduce( (o, i) => { let modeID = i.value; - let joyMode = getJoystickMode(modeID); + let axes = i.getAttribute('axiscount') || 2; + let joyMode = (axes == 2 ? getJoystickMode(modeID) : null); if (joyMode && joyMode.options) { let r = o; Object.keys(joyMode.options).forEach(key => { @@ -130,10 +131,10 @@ const Wii = ({ values, errors, handleChange, handleCheckbox }) => { const getJoystickMode = (searchValue: number) => WII_JOYSTICK_MODES.find(({ value }) => parseInt(value) === parseInt(searchValue)); - const setWiiAnalogEntry = (controlID,analogID,e) => { + const setWiiAnalogEntry = (controlID,analogID,axes,e) => { let analogEntry = {}; let modeID = e.target.value; - let joyMode = getJoystickMode(modeID); + let joyMode = (axes == 2 ? getJoystickMode(modeID) : null); if (joyMode && joyMode.options) { let r = analogEntry; Object.keys(joyMode.options).forEach(key => { @@ -280,7 +281,7 @@ const Wii = ({ values, errors, handleChange, handleCheckbox }) => {