parent
16958ac4ba
commit
45efcfcb98
@ -35,6 +35,7 @@ static void _menuAddEntry(menu_s *m, menuEntry_s* me) {
|
|||||||
m->lastEntry = me;
|
m->lastEntry = me;
|
||||||
}
|
}
|
||||||
m->xPos = 0;
|
m->xPos = 0;
|
||||||
|
m->slideSpeed = 0;
|
||||||
m->nEntries ++;
|
m->nEntries ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ static void menuAddEntryToFront(menuEntry_s* me) {
|
|||||||
m->lastEntry = me;
|
m->lastEntry = me;
|
||||||
}
|
}
|
||||||
m->xPos = 0;
|
m->xPos = 0;
|
||||||
|
m->slideSpeed = 0;
|
||||||
m->nEntries ++;
|
m->nEntries ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,6 +800,8 @@ void menuLoop(void) {
|
|||||||
int entries_count = layoutobj->posEnd[0];
|
int entries_count = layoutobj->posEnd[0];
|
||||||
layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuList];
|
layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuList];
|
||||||
|
|
||||||
|
// Gentle Realign only when not manually moving
|
||||||
|
if (menu->slideSpeed == 0) {
|
||||||
if (menu->nEntries > entries_count) {
|
if (menu->nEntries > entries_count) {
|
||||||
int wanted_x = clamp(-menu->curEntry * layoutobj->posEnd[0], -(menu->nEntries - entries_count) * layoutobj->posEnd[0], 0);
|
int wanted_x = clamp(-menu->curEntry * layoutobj->posEnd[0], -(menu->nEntries - entries_count) * layoutobj->posEnd[0], 0);
|
||||||
menu->xPos += v;
|
menu->xPos += v;
|
||||||
@ -809,6 +811,25 @@ void menuLoop(void) {
|
|||||||
else {
|
else {
|
||||||
menu->xPos = v = 0;
|
menu->xPos = v = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
menu->xPos += menu->slideSpeed;
|
||||||
|
|
||||||
|
if (abs(menu->slideSpeed) > 2) {
|
||||||
|
// Slow down way faster when outside the normal bounds
|
||||||
|
if (menu->xPos > 0 || menu->xPos < -(menu->nEntries) * layoutobj->posEnd[0]) {
|
||||||
|
menu->slideSpeed *= .5f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
menu->slideSpeed *= .9f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
menu->slideSpeed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->curEntry = clamp(roundf(-((float) menu->xPos / layoutobj->posEnd[0])), 0, menu->nEntries);
|
||||||
|
}
|
||||||
|
|
||||||
menuEntry_s *active_entry = NULL;
|
menuEntry_s *active_entry = NULL;
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ struct menu_s_tag
|
|||||||
int nEntries;
|
int nEntries;
|
||||||
int curEntry;
|
int curEntry;
|
||||||
int xPos;
|
int xPos;
|
||||||
|
int slideSpeed;
|
||||||
|
|
||||||
char dirname[PATH_MAX+1];
|
char dirname[PATH_MAX+1];
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@ void touchInit() {
|
|||||||
touchInfo.isTap = true;
|
touchInfo.isTap = true;
|
||||||
touchInfo.initMenuXPos = 0;
|
touchInfo.initMenuXPos = 0;
|
||||||
touchInfo.initMenuIndex = 0;
|
touchInfo.initMenuIndex = 0;
|
||||||
|
touchInfo.lastSlideSpeed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleTappingOnApp(menu_s* menu, int px) {
|
void handleTappingOnApp(menu_s* menu, int px) {
|
||||||
@ -72,25 +73,25 @@ void handleTouch(menu_s* menu) {
|
|||||||
touchInfo.isTap = true;
|
touchInfo.isTap = true;
|
||||||
touchInfo.initMenuXPos = menu->xPos;
|
touchInfo.initMenuXPos = menu->xPos;
|
||||||
touchInfo.initMenuIndex = menu->curEntry;
|
touchInfo.initMenuIndex = menu->curEntry;
|
||||||
|
touchInfo.lastSlideSpeed = 0;
|
||||||
|
menu->slideSpeed = 0;
|
||||||
}
|
}
|
||||||
// On touch moving.
|
// On touch moving.
|
||||||
else if (touches >= 1 && touchInfo.gestureInProgress) {
|
else if (touches >= 1 && touchInfo.gestureInProgress) {
|
||||||
hidTouchRead(¤tTouch, 0);
|
hidTouchRead(¤tTouch, 0);
|
||||||
|
|
||||||
|
touchInfo.lastSlideSpeed = ((int)(currentTouch.px - touchInfo.prevTouch.px));
|
||||||
|
|
||||||
touchInfo.prevTouch = currentTouch;
|
touchInfo.prevTouch = currentTouch;
|
||||||
|
|
||||||
if (touchInfo.isTap && (abs(touchInfo.firstTouch.px - currentTouch.px) > TAP_MOVEMENT_GAP || abs(touchInfo.firstTouch.py - currentTouch.py) > TAP_MOVEMENT_GAP)) {
|
if (touchInfo.isTap && (abs(touchInfo.firstTouch.px - currentTouch.px) > TAP_MOVEMENT_GAP || abs(touchInfo.firstTouch.py - currentTouch.py) > TAP_MOVEMENT_GAP)) {
|
||||||
touchInfo.isTap = false;
|
touchInfo.isTap = false;
|
||||||
}
|
}
|
||||||
if (!menuIsMsgBoxOpen() && touchInfo.firstTouch.py > layoutobj->posStart[1] && touchInfo.firstTouch.py < layoutobj->posStart[1]+layoutobj->size[1] && !touchInfo.isTap && menu->nEntries > entries_count) {
|
if (!menuIsMsgBoxOpen() && touchInfo.firstTouch.py > layoutobj->posStart[1] && touchInfo.firstTouch.py < layoutobj->posStart[1]+layoutobj->size[1] && !touchInfo.isTap && menu->nEntries > entries_count) {
|
||||||
menu->xPos = touchInfo.initMenuXPos + (currentTouch.px - touchInfo.firstTouch.px);
|
|
||||||
menu->curEntry = touchInfo.initMenuIndex + ((int) (touchInfo.firstTouch.px - currentTouch.px) / layoutobj->posEnd[0]);
|
|
||||||
|
|
||||||
if (menu->curEntry < 0)
|
if (!touchInfo.isTap) {
|
||||||
menu->curEntry = 0;
|
menu->slideSpeed = touchInfo.lastSlideSpeed;
|
||||||
|
}
|
||||||
if (menu->curEntry >= menu->nEntries - entries_count - 1)
|
|
||||||
menu->curEntry = menu->nEntries - entries_count;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// On touch end.
|
// On touch end.
|
||||||
@ -100,6 +101,10 @@ void handleTouch(menu_s* menu) {
|
|||||||
int x2 = touchInfo.prevTouch.px;
|
int x2 = touchInfo.prevTouch.px;
|
||||||
int y2 = touchInfo.prevTouch.py;
|
int y2 = touchInfo.prevTouch.py;
|
||||||
|
|
||||||
|
if (!touchInfo.isTap) {
|
||||||
|
menu->slideSpeed = touchInfo.lastSlideSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
bool netloader_active = menuIsNetloaderActive();
|
bool netloader_active = menuIsNetloaderActive();
|
||||||
|
|
||||||
if (menuIsMsgBoxOpen() && !netloader_active) {
|
if (menuIsMsgBoxOpen() && !netloader_active) {
|
||||||
|
@ -10,6 +10,7 @@ struct touchInfo_s {
|
|||||||
bool isTap;
|
bool isTap;
|
||||||
int initMenuXPos;
|
int initMenuXPos;
|
||||||
int initMenuIndex;
|
int initMenuIndex;
|
||||||
|
int lastSlideSpeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
void handleTouch(menu_s* menu);
|
void handleTouch(menu_s* menu);
|
Loading…
Reference in New Issue
Block a user