mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
Merge 0952152879 into 3ce11f14ce
This commit is contained in:
commit
60e827bd5e
@ -163,14 +163,23 @@ void EpubReaderActivity::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool prevReleased = mappedInput.wasReleased(MappedInputManager::Button::PageBack) ||
|
// When long-press chapter skip is disabled, turn pages on press instead of release.
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Left);
|
const bool usePressForPageTurn = !SETTINGS.longPressChapterSkip;
|
||||||
const bool nextReleased = mappedInput.wasReleased(MappedInputManager::Button::PageForward) ||
|
const bool prevTriggered = usePressForPageTurn ? (mappedInput.wasPressed(MappedInputManager::Button::PageBack) ||
|
||||||
|
mappedInput.wasPressed(MappedInputManager::Button::Left))
|
||||||
|
: (mappedInput.wasReleased(MappedInputManager::Button::PageBack) ||
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Left));
|
||||||
|
const bool nextTriggered = usePressForPageTurn
|
||||||
|
? (mappedInput.wasPressed(MappedInputManager::Button::PageForward) ||
|
||||||
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Right);
|
mappedInput.wasPressed(MappedInputManager::Button::Right))
|
||||||
|
: (mappedInput.wasReleased(MappedInputManager::Button::PageForward) ||
|
||||||
|
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Right));
|
||||||
|
|
||||||
if (!prevReleased && !nextReleased) {
|
if (!prevTriggered && !nextTriggered) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +197,7 @@ void EpubReaderActivity::loop() {
|
|||||||
// We don't want to delete the section mid-render, so grab the semaphore
|
// We don't want to delete the section mid-render, so grab the semaphore
|
||||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
||||||
nextPageNumber = 0;
|
nextPageNumber = 0;
|
||||||
currentSpineIndex = nextReleased ? currentSpineIndex + 1 : currentSpineIndex - 1;
|
currentSpineIndex = nextTriggered ? currentSpineIndex + 1 : currentSpineIndex - 1;
|
||||||
section.reset();
|
section.reset();
|
||||||
xSemaphoreGive(renderingMutex);
|
xSemaphoreGive(renderingMutex);
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
@ -201,7 +210,7 @@ void EpubReaderActivity::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevReleased) {
|
if (prevTriggered) {
|
||||||
if (section->currentPage > 0) {
|
if (section->currentPage > 0) {
|
||||||
section->currentPage--;
|
section->currentPage--;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -107,21 +107,30 @@ void TxtReaderActivity::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool prevReleased = mappedInput.wasReleased(MappedInputManager::Button::PageBack) ||
|
// When long-press chapter skip is disabled, turn pages on press instead of release.
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Left);
|
const bool usePressForPageTurn = !SETTINGS.longPressChapterSkip;
|
||||||
const bool nextReleased = mappedInput.wasReleased(MappedInputManager::Button::PageForward) ||
|
const bool prevTriggered = usePressForPageTurn ? (mappedInput.wasPressed(MappedInputManager::Button::PageBack) ||
|
||||||
|
mappedInput.wasPressed(MappedInputManager::Button::Left))
|
||||||
|
: (mappedInput.wasReleased(MappedInputManager::Button::PageBack) ||
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Left));
|
||||||
|
const bool nextTriggered = usePressForPageTurn
|
||||||
|
? (mappedInput.wasPressed(MappedInputManager::Button::PageForward) ||
|
||||||
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Right);
|
mappedInput.wasPressed(MappedInputManager::Button::Right))
|
||||||
|
: (mappedInput.wasReleased(MappedInputManager::Button::PageForward) ||
|
||||||
|
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Right));
|
||||||
|
|
||||||
if (!prevReleased && !nextReleased) {
|
if (!prevTriggered && !nextTriggered) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevReleased && currentPage > 0) {
|
if (prevTriggered && currentPage > 0) {
|
||||||
currentPage--;
|
currentPage--;
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
} else if (nextReleased && currentPage < totalPages - 1) {
|
} else if (nextTriggered && currentPage < totalPages - 1) {
|
||||||
currentPage++;
|
currentPage++;
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,14 +111,23 @@ void XtcReaderActivity::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool prevReleased = mappedInput.wasReleased(MappedInputManager::Button::PageBack) ||
|
// When long-press chapter skip is disabled, turn pages on press instead of release.
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Left);
|
const bool usePressForPageTurn = !SETTINGS.longPressChapterSkip;
|
||||||
const bool nextReleased = mappedInput.wasReleased(MappedInputManager::Button::PageForward) ||
|
const bool prevTriggered = usePressForPageTurn ? (mappedInput.wasPressed(MappedInputManager::Button::PageBack) ||
|
||||||
|
mappedInput.wasPressed(MappedInputManager::Button::Left))
|
||||||
|
: (mappedInput.wasReleased(MappedInputManager::Button::PageBack) ||
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Left));
|
||||||
|
const bool nextTriggered = usePressForPageTurn
|
||||||
|
? (mappedInput.wasPressed(MappedInputManager::Button::PageForward) ||
|
||||||
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Right);
|
mappedInput.wasPressed(MappedInputManager::Button::Right))
|
||||||
|
: (mappedInput.wasReleased(MappedInputManager::Button::PageForward) ||
|
||||||
|
(SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Power)) ||
|
||||||
|
mappedInput.wasReleased(MappedInputManager::Button::Right));
|
||||||
|
|
||||||
if (!prevReleased && !nextReleased) {
|
if (!prevTriggered && !nextTriggered) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,14 +141,14 @@ void XtcReaderActivity::loop() {
|
|||||||
const bool skipPages = SETTINGS.longPressChapterSkip && mappedInput.getHeldTime() > skipPageMs;
|
const bool skipPages = SETTINGS.longPressChapterSkip && mappedInput.getHeldTime() > skipPageMs;
|
||||||
const int skipAmount = skipPages ? 10 : 1;
|
const int skipAmount = skipPages ? 10 : 1;
|
||||||
|
|
||||||
if (prevReleased) {
|
if (prevTriggered) {
|
||||||
if (currentPage >= static_cast<uint32_t>(skipAmount)) {
|
if (currentPage >= static_cast<uint32_t>(skipAmount)) {
|
||||||
currentPage -= skipAmount;
|
currentPage -= skipAmount;
|
||||||
} else {
|
} else {
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
}
|
}
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
} else if (nextReleased) {
|
} else if (nextTriggered) {
|
||||||
currentPage += skipAmount;
|
currentPage += skipAmount;
|
||||||
if (currentPage >= xtc->getPageCount()) {
|
if (currentPage >= xtc->getPageCount()) {
|
||||||
currentPage = xtc->getPageCount(); // Allow showing "End of book"
|
currentPage = xtc->getPageCount(); // Allow showing "End of book"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user