mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-21 05:04:46 -07:00
Fix scroll acceleration wrap-around
This commit is contained in:
@@ -425,11 +425,20 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||
} else {
|
||||
scroll_speed = model->button_held_for_ticks > 9 ? 4 : 2;
|
||||
}
|
||||
} else if(model->button_held_for_ticks < 0) {
|
||||
scroll_speed = 0;
|
||||
}
|
||||
|
||||
if(event->key == InputKeyUp) {
|
||||
if(model->item_idx < scroll_speed) {
|
||||
scroll_speed = model->item_idx;
|
||||
if(scroll_speed == 0) {
|
||||
if(model->button_held_for_ticks > 0) {
|
||||
model->button_held_for_ticks = -1;
|
||||
} else {
|
||||
scroll_speed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model->item_idx =
|
||||
@@ -442,11 +451,22 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||
browser->callback(ArchiveBrowserEventFavMoveUp, browser->context);
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
|
||||
if(model->button_held_for_ticks < -1) {
|
||||
model->button_held_for_ticks = 0;
|
||||
}
|
||||
model->button_held_for_ticks += 1;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
int32_t count = model->item_cnt;
|
||||
if(model->item_idx >= (count - scroll_speed)) {
|
||||
scroll_speed = model->item_cnt - model->item_idx - 1;
|
||||
if(scroll_speed == 0) {
|
||||
if(model->button_held_for_ticks > 0) {
|
||||
model->button_held_for_ticks = -1;
|
||||
} else {
|
||||
scroll_speed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
||||
@@ -458,6 +478,10 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||
browser->callback(ArchiveBrowserEventFavMoveDown, browser->context);
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
|
||||
if(model->button_held_for_ticks < -1) {
|
||||
model->button_held_for_ticks = 0;
|
||||
}
|
||||
model->button_held_for_ticks += 1;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -111,7 +111,7 @@ typedef struct {
|
||||
int32_t list_offset;
|
||||
size_t scroll_counter;
|
||||
|
||||
uint32_t button_held_for_ticks;
|
||||
int32_t button_held_for_ticks;
|
||||
} ArchiveBrowserViewModel;
|
||||
|
||||
void archive_browser_set_callback(
|
||||
|
||||
@@ -148,7 +148,7 @@ typedef struct {
|
||||
bool hide_ext;
|
||||
size_t scroll_counter;
|
||||
|
||||
uint32_t button_held_for_ticks;
|
||||
int32_t button_held_for_ticks;
|
||||
} FileBrowserModel;
|
||||
|
||||
static const Icon* BrowserItemIcons[] = {
|
||||
@@ -670,11 +670,20 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
|
||||
} else {
|
||||
scroll_speed = model->button_held_for_ticks > 9 ? 5 : 3;
|
||||
}
|
||||
} else if(model->button_held_for_ticks < 0) {
|
||||
scroll_speed = 0;
|
||||
}
|
||||
|
||||
if(event->key == InputKeyUp) {
|
||||
if(model->item_idx < scroll_speed) {
|
||||
scroll_speed = model->item_idx;
|
||||
if(scroll_speed == 0) {
|
||||
if(model->button_held_for_ticks > 0) {
|
||||
model->button_held_for_ticks = -1;
|
||||
} else {
|
||||
scroll_speed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model->item_idx =
|
||||
@@ -690,11 +699,21 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
|
||||
if(model->button_held_for_ticks < -1) {
|
||||
model->button_held_for_ticks = 0;
|
||||
}
|
||||
model->button_held_for_ticks += 1;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
int32_t count = model->item_cnt;
|
||||
if(model->item_idx + scroll_speed >= count) {
|
||||
scroll_speed = count - model->item_idx - 1;
|
||||
if(scroll_speed == 0) {
|
||||
if(model->button_held_for_ticks > 0) {
|
||||
model->button_held_for_ticks = -1;
|
||||
} else {
|
||||
scroll_speed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
||||
@@ -709,6 +728,9 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
|
||||
if(model->button_held_for_ticks < -1) {
|
||||
model->button_held_for_ticks = 0;
|
||||
}
|
||||
model->button_held_for_ticks += 1;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user