mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 22:40:25 +00:00
Fix roll-over in file browser and archive (#2811)
This commit is contained in:
parent
6f1c46e11d
commit
bf975ad786
2 changed files with 21 additions and 15 deletions
|
@ -345,11 +345,13 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||||
|
|
||||||
if(event->key == InputKeyUp) {
|
if(event->key == InputKeyUp) {
|
||||||
if(model->item_idx < scroll_speed) {
|
if(model->item_idx < scroll_speed) {
|
||||||
scroll_speed = model->item_idx;
|
model->button_held_for_ticks = 0;
|
||||||
|
model->item_idx = model->item_cnt - 1;
|
||||||
|
} else {
|
||||||
|
model->item_idx =
|
||||||
|
((model->item_idx - scroll_speed) + model->item_cnt) %
|
||||||
|
model->item_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
model->item_idx =
|
|
||||||
((model->item_idx - scroll_speed) + model->item_cnt) % model->item_cnt;
|
|
||||||
if(is_file_list_load_required(model)) {
|
if(is_file_list_load_required(model)) {
|
||||||
model->list_loading = true;
|
model->list_loading = true;
|
||||||
browser->callback(ArchiveBrowserEventLoadPrevItems, browser->context);
|
browser->callback(ArchiveBrowserEventLoadPrevItems, browser->context);
|
||||||
|
@ -361,11 +363,12 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||||
model->button_held_for_ticks += 1;
|
model->button_held_for_ticks += 1;
|
||||||
} else if(event->key == InputKeyDown) {
|
} else if(event->key == InputKeyDown) {
|
||||||
int32_t count = model->item_cnt;
|
int32_t count = model->item_cnt;
|
||||||
if(model->item_idx >= (count - scroll_speed)) {
|
if(model->item_idx + scroll_speed >= count) {
|
||||||
scroll_speed = model->item_cnt - model->item_idx - 1;
|
model->button_held_for_ticks = 0;
|
||||||
|
model->item_idx = 0;
|
||||||
|
} else {
|
||||||
|
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
|
||||||
if(is_file_list_load_required(model)) {
|
if(is_file_list_load_required(model)) {
|
||||||
model->list_loading = true;
|
model->list_loading = true;
|
||||||
browser->callback(ArchiveBrowserEventLoadNextItems, browser->context);
|
browser->callback(ArchiveBrowserEventLoadNextItems, browser->context);
|
||||||
|
|
|
@ -602,11 +602,13 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
|
||||||
|
|
||||||
if(event->key == InputKeyUp) {
|
if(event->key == InputKeyUp) {
|
||||||
if(model->item_idx < scroll_speed) {
|
if(model->item_idx < scroll_speed) {
|
||||||
scroll_speed = model->item_idx;
|
model->button_held_for_ticks = 0;
|
||||||
|
model->item_idx = model->item_cnt - 1;
|
||||||
|
} else {
|
||||||
|
model->item_idx =
|
||||||
|
((model->item_idx - scroll_speed) + model->item_cnt) %
|
||||||
|
model->item_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
model->item_idx =
|
|
||||||
((model->item_idx - scroll_speed) + model->item_cnt) % model->item_cnt;
|
|
||||||
if(browser_is_list_load_required(model)) {
|
if(browser_is_list_load_required(model)) {
|
||||||
model->list_loading = true;
|
model->list_loading = true;
|
||||||
int32_t load_offset = CLAMP(
|
int32_t load_offset = CLAMP(
|
||||||
|
@ -622,10 +624,11 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
|
||||||
} else if(event->key == InputKeyDown) {
|
} else if(event->key == InputKeyDown) {
|
||||||
int32_t count = model->item_cnt;
|
int32_t count = model->item_cnt;
|
||||||
if(model->item_idx + scroll_speed >= count) {
|
if(model->item_idx + scroll_speed >= count) {
|
||||||
scroll_speed = count - model->item_idx - 1;
|
model->button_held_for_ticks = 0;
|
||||||
|
model->item_idx = 0;
|
||||||
|
} else {
|
||||||
|
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
|
||||||
if(browser_is_list_load_required(model)) {
|
if(browser_is_list_load_required(model)) {
|
||||||
model->list_loading = true;
|
model->list_loading = true;
|
||||||
int32_t load_offset = CLAMP(
|
int32_t load_offset = CLAMP(
|
||||||
|
|
Loading…
Reference in a new issue