Clarify touch gesture and input API comments

Simplify and clarify documentation for touch gesture detection (back gesture, item taps, long-press) and board detection flags. No functional changes, just improved comment readability.
This commit is contained in:
Justin Mitchell
2026-06-15 19:42:09 -04:00
parent 9f3dddabe6
commit cef0d267b7
13 changed files with 40 additions and 83 deletions
+3 -6
View File
@@ -179,12 +179,9 @@ void HomeActivity::loop() {
requestUpdate();
});
// A tap on a menu button selects + activates it. The button menu registers
// menu-local ids (it is drawn with selectorIndex offset by recentBooks.size()),
// so map the tapped id back into the global selector space. (The recent-book
// cover is a separate, single-item draw path — tappable in a later phase.)
// Touch-down moves the selector to the pressed menu button (shows selected state),
// like Up/Down; release opens it below.
// Tap a menu button to select + activate it. The button menu registers
// menu-local ids (drawn with selectorIndex offset by recentBooks.size()), so map
// back into the global selector space. Touch-down shows it selected; release opens.
int downId = -1;
if (mappedInput.wasItemTouchedDown(downId)) {
selectorIndex = static_cast<int>(recentBooks.size()) + downId;
+2 -6
View File
@@ -256,12 +256,8 @@ void EpubReaderActivity::loop() {
requestUpdate();
}
// Touch reader controls mirror the side page buttons (left third = back, right
// third = forward, press-and-hold = long-press behavior) and the Confirm
// button (center press-and-hold = open menu). The top-left Back corner is
// consumed by wasReleased(Back) earlier, so it never reaches here. No-op on
// Xteink / when the setting is off. wasTouchTap is idempotent within a frame,
// so reading it here and again below is safe.
// Touch page nav (idempotent within a frame, so read here and again below). The
// top-left Back corner is consumed by wasReleased(Back) above, never reaching here.
const auto touch = ReaderUtils::detectTouchPageTurn(renderer);
// Enter reader menu activity (Confirm release, or a center touch-and-hold).
+4 -8
View File
@@ -65,14 +65,10 @@ inline PageTurnResult detectPageTurn(const MappedInputManager& input) {
return {prev, next, tiltPrev || tiltNext};
}
// Touch reader controls: a tap on the left third of the (oriented) screen turns
// back a page, the right third turns forward, mirroring the side page buttons.
// The center third opens the reader menu on press-and-hold (see center/heldMs;
// the menu/Back gesture is handled by each reader). heldMs carries the contact
// duration so callers can apply the same long-press behavior (chapter skip /
// orientation change) as the buttons. Gated off the Xteink devices (no touch)
// and behind the touchReaderControls setting; returns all-false otherwise, so
// non-touch readers pay a single branch.
// Touch reader controls: left third = page back, right third = forward, center =
// open menu on press-and-hold (see isTouchMenuGesture). heldMs is the contact
// duration, for the same long-press behavior as the buttons (chapter skip).
// All-false on Xteink (no touch) or when the setting is off.
struct TouchPageTurn {
bool prev;
bool next;
+1 -2
View File
@@ -72,8 +72,7 @@ void TxtReaderActivity::loop() {
return;
}
// Touch reader controls mirror the side page buttons (left third = back,
// right third = forward). No-op on Xteink / when the setting is off.
// Touch page nav (left third = back, right third = forward).
const auto touch = ReaderUtils::detectTouchPageTurn(renderer);
auto [prevTriggered, nextTriggered, fromTilt] = ReaderUtils::detectPageTurn(mappedInput);
+1 -4
View File
@@ -53,10 +53,7 @@ void XtcReaderActivity::onExit() {
}
void XtcReaderActivity::loop() {
// Touch reader controls mirror the side page buttons (left third = back, right
// third = forward, press-and-hold = chapter skip) and the Confirm button
// (center press-and-hold = chapter selection). No-op on Xteink / when the
// setting is off.
// Touch page nav; center hold opens chapter selection (the Confirm analogue).
const auto touch = ReaderUtils::detectTouchPageTurn(renderer);
// Enter chapter selection activity (Confirm release, or a center touch-and-hold).
+3 -5
View File
@@ -115,11 +115,9 @@ void SettingsActivity::onExit() {
void SettingsActivity::loop() {
bool hasChangedCategory = false;
// A tap on a settings row selects + activates it in one gesture. The list is drawn
// with selectedIndex = selectedSettingIndex - 1 (row 0 is the category tab), so map
// the tapped 0-based row back by +1. (Category tab bar is tappable in a later phase.)
// Touch-down moves the selection to the pressed row (shows selected state); release
// toggles/activates it below. (Row 0 is the tab bar, so settings list id 0 -> index 1.)
// Tap a settings row to select + activate it. Row 0 is the tab bar, so the list
// is drawn at selectedSettingIndex - 1; map the tapped row back by +1. Touch-down
// shows it selected; release toggles/activates below.
int downId = -1;
if (mappedInput.wasItemTouchedDown(downId) && downId >= 0 && downId < settingsCount) {
selectedSettingIndex = downId + 1;
@@ -337,11 +337,9 @@ void KeyboardEntryActivity::loop() {
}
}
// A tap selects the key and presses it. Encoded id = row*100+col (bottom function
// row = getContentRowCount()). A touch-and-hold inserts the alternate character
// (numbers/symbols on a letter), mirroring the button long-press — wasItemLongPressed
// is checked first since it's a subset of wasItemTapped's releases. Skipped in
// cursor mode, where a tap on a key would be ambiguous with cursor editing.
// Tap a key to press it (encoded id = row*100+col). Touch-and-hold inserts the
// alternate char, like the button long-press (check wasItemLongPressed first, it's
// a subset of these releases). Skipped in cursor mode (ambiguous with editing).
int tappedKey = -1;
if (!cursorMode && mappedInput.wasItemTapped(tappedKey)) {
selectedRow = tappedKey / 100;