Skip to content

Commit c9780ac

Browse files
authored
use the original dpad input, not the modified dpad output, in hotkeys (#1635)
hotkey processing used to be before the core gamepad process, so it was reading the unmodified dpad input, but #1593 moved hotkey processing to after, so what it ends up reading is the output, which gets bits masked off of it when in LS/RS mode (so as to not do a double output of a direction in LS and DP outputs, when that's likely not intended). all the code involved here makes sense, but it broke in tandem as an order of operations sequence. this separates the concerns by having the hotkey dpad read use dpadOriginal, which is only used for the display, but is exactly what we need --- the dpad input element, untouched by gamepad output processing. I moved where dpadOriginal gets set in order to make its purpose clearer --- it happens on read(), now, not process()ing. fixes #1634
1 parent f3f1266 commit c9780ac

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

headers/gamepad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Gamepad {
6969
* @brief Check for a dpad press. Used by `pressed[Dpad]` helper methods.
7070
*/
7171
inline bool __attribute__((always_inline)) pressedDpad(const uint8_t mask) {
72-
return (state.dpad & mask) == mask;
72+
return (state.dpadOriginal & mask) == mask;
7373
}
7474

7575
/**

src/gamepad.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@ void Gamepad::process()
277277
state.dpad = filterToFourWayMode(state.dpad);
278278
}
279279

280-
// hold current dpad state regardless of input
281-
state.dpadOriginal = state.dpad;
282-
283280
// stash digital-only dpad state for later
284281
uint8_t dpadOnlyMask = ((state.dpadOriginal & 0xF0) >> 4);
285282

@@ -373,6 +370,9 @@ void Gamepad::read()
373370
| ((values & mapButtonE12->pinMask) ? mapButtonE12->buttonMask : 0)
374371
;
375372

373+
// hold current dpad state regardless of input mode -> output, which is determined in process()
374+
state.dpadOriginal = state.dpad;
375+
376376
// set the effective dpad mode based on settings + overrides
377377
if (values & mapButtonDP->pinMask) activeDpadMode = DpadMode::DPAD_MODE_DIGITAL;
378378
else if (values & mapButtonLS->pinMask) activeDpadMode = DpadMode::DPAD_MODE_LEFT_ANALOG;

0 commit comments

Comments
 (0)