[PR #902] [MERGED] RT-ACTIVE-INPUT-DEBOUNCE-NAN: active_input: guard timestamp underflow in debounce and ignore non-finite axes #942

Closed
opened 2026-11-26 20:19:34 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/902
Author: @narekshaghoyandev
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: ubiq-active-input-debounce-and-nan


📝 Commits (1)

  • 27c9300 active_input: guard timestamp underflow in debounce and ignore non-finite axes

📊 Changes

2 files changed (+49 additions, -5 deletions)

View changed files

📝 runtime/src/active_input.h (+12 -5)
📝 runtime/test/active_input_test.cpp (+37 -0)

📄 Description

Hardens runtime/src/active_input.h against unsigned timestamp underflow and non-finite analog samples:

  1. Guard unsigned timestamp underflow in debounce (ActiveInputTracker::observe): Previously time_us - changed_at_ < thresholds_.min_switch_us wrapped around to ~UINT64_MAX whenever an out-of-order/earlier timestamp (time_us < changed_at_) arrived, bypassing min_switch_us and switching active input families immediately. Now guards time_us < changed_at_ || time_us - changed_at_ < thresholds_.min_switch_us.
  2. Ignore non-finite stick/trigger samples (ActiveInputTracker::edge_between): Checks std::isfinite on previous and current stick/trigger floats so a NaN baseline or Inf spike cannot trigger a bogus family switch.

Verification

  • Linux (CPU-only, GCC C++20 -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined): runtime/test/active_input_test.cpp passes 8/8 cases cleanly.
  • Negative control against main: out-of-order timestamp and non-finite axes fails as expected.
  • python3 -I scripts/check_no_game_data.py runtime/src/active_input.h runtime/test/active_input_test.cpp: clean.

Claimed in the coordination issue as: RT-ACTIVE-INPUT-DEBOUNCE-NAN (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135437104)
AI-assisted: yes (Gemini)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/902 **Author:** [@narekshaghoyandev](https://github.com/narekshaghoyandev) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `ubiq-active-input-debounce-and-nan` --- ### 📝 Commits (1) - [`27c9300`](https://github.com/ubiquitarianism/leonida/commit/27c930020f7539abf6e9e721a72599ce0c4b4953) active_input: guard timestamp underflow in debounce and ignore non-finite axes ### 📊 Changes **2 files changed** (+49 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/active_input.h` (+12 -5) 📝 `runtime/test/active_input_test.cpp` (+37 -0) </details> ### 📄 Description Hardens `runtime/src/active_input.h` against unsigned timestamp underflow and non-finite analog samples: 1. **Guard unsigned timestamp underflow in debounce (`ActiveInputTracker::observe`)**: Previously `time_us - changed_at_ < thresholds_.min_switch_us` wrapped around to `~UINT64_MAX` whenever an out-of-order/earlier timestamp (`time_us < changed_at_`) arrived, bypassing `min_switch_us` and switching active input families immediately. Now guards `time_us < changed_at_ || time_us - changed_at_ < thresholds_.min_switch_us`. 2. **Ignore non-finite stick/trigger samples (`ActiveInputTracker::edge_between`)**: Checks `std::isfinite` on previous and current stick/trigger floats so a `NaN` baseline or `Inf` spike cannot trigger a bogus family switch. ### Verification - Linux (CPU-only, GCC C++20 `-Wall -Wextra -Werror -pedantic -fsanitize=address,undefined`): `runtime/test/active_input_test.cpp` passes 8/8 cases cleanly. - Negative control against `main`: `out-of-order timestamp and non-finite axes` fails as expected. - `python3 -I scripts/check_no_game_data.py runtime/src/active_input.h runtime/test/active_input_test.cpp`: clean. Claimed in the coordination issue as: RT-ACTIVE-INPUT-DEBOUNCE-NAN (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135437104) AI-assisted: yes (Gemini) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:34 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#942
No description provided.