mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
Fix scroll acceleration wrap-around
This commit is contained in:
@@ -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