change scrolling timing

This commit is contained in:
dborth 2009-11-04 21:27:16 +00:00
parent e933e32b20
commit daa7e8195e
2 changed files with 60 additions and 39 deletions

View File

@ -52,8 +52,9 @@
extern FreeTypeGX *fontSystem[]; extern FreeTypeGX *fontSystem[];
#define SCROLL_INITIAL_DELAY 20 #define SCROLL_DELAY_INITIAL 200000
#define SCROLL_LOOP_DELAY 3 #define SCROLL_DELAY_LOOP 30000
#define SCROLL_DELAY_DECREASE 300
#define FILE_PAGESIZE 10 #define FILE_PAGESIZE 10
#define PAGESIZE 8 #define PAGESIZE 8
#define SAVELISTSIZE 6 #define SAVELISTSIZE 6

View File

@ -9,8 +9,12 @@
***************************************************************************/ ***************************************************************************/
#include "gui.h" #include "gui.h"
#include <ogc/lwp_watchdog.h>
#include <gctypes.h>
static int scrollDelay = 0; static u64 prev[4];
static u64 now[4];
static u32 delay[4];
/** /**
* Constructor for the GuiTrigger class. * Constructor for the GuiTrigger class.
@ -156,24 +160,28 @@ bool GuiTrigger::Left()
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT || (pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT
|| pad.stickX < -PADCAL || pad.stickX < -PADCAL
|| WPAD_Stick(0,0) < -PADCAL) || WPAD_StickX(0) < -PADCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT)
|| pad.btns_d & PAD_BUTTON_LEFT) || pad.btns_d & PAD_BUTTON_LEFT)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. prev[chan] = gettime();
delay[chan] = SCROLLL_DELAY_INITIAL; // reset scroll delay
return true; return true;
} }
else if(scrollDelay == 0)
now[chan] = gettime();
if(diff_usec(prev[chan], now[chan]) > delay[chan])
{ {
scrollDelay = SCROLL_LOOP_DELAY; prev[chan] = now[chan];
if(delay[chan] == SCROLLL_DELAY_INITIAL)
delay[chan] = SCROLL_DELAY_LOOP;
else if(delay[chan] > SCROLL_DELAY_DECREASE)
delay[chan] -= SCROLL_DELAY_DECREASE;
return true; return true;
} }
else
{
if(scrollDelay > 0)
scrollDelay--;
}
} }
return false; return false;
} }
@ -185,24 +193,28 @@ bool GuiTrigger::Right()
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT || (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT
|| pad.stickX > PADCAL || pad.stickX > PADCAL
|| WPAD_Stick(0,0) > PADCAL) || WPAD_StickX(0) > PADCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
|| pad.btns_d & PAD_BUTTON_RIGHT) || pad.btns_d & PAD_BUTTON_RIGHT)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. prev[chan] = gettime();
delay[chan] = SCROLLL_DELAY_INITIAL; // reset scroll delay
return true; return true;
} }
else if(scrollDelay == 0)
now[chan] = gettime();
if(diff_usec(prev[chan], now[chan]) > delay[chan])
{ {
scrollDelay = SCROLL_LOOP_DELAY; prev[chan] = now[chan];
if(delay[chan] == SCROLLL_DELAY_INITIAL)
delay[chan] = SCROLL_DELAY_LOOP;
else if(delay[chan] > SCROLL_DELAY_DECREASE)
delay[chan] -= SCROLL_DELAY_DECREASE;
return true; return true;
} }
else
{
if(scrollDelay > 0)
scrollDelay--;
}
} }
return false; return false;
} }
@ -214,24 +226,28 @@ bool GuiTrigger::Up()
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_UP || (pad.btns_d | pad.btns_h) & PAD_BUTTON_UP
|| pad.stickY > PADCAL || pad.stickY > PADCAL
|| WPAD_Stick(0,1) > PADCAL) || WPAD_StickY(0) > PADCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP)
|| pad.btns_d & PAD_BUTTON_UP) || pad.btns_d & PAD_BUTTON_UP)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. prev[chan] = gettime();
delay[chan] = SCROLLL_DELAY_INITIAL; // reset scroll delay
return true; return true;
} }
else if(scrollDelay == 0)
now[chan] = gettime();
if(diff_usec(prev[chan], now[chan]) > delay[chan])
{ {
scrollDelay = SCROLL_LOOP_DELAY; prev[chan] = now[chan];
if(delay[chan] == SCROLL_DELAY_INITIAL)
delay[chan] = SCROLL_DELAY_LOOP;
else if(delay[chan] > SCROLL_DELAY_DECREASE)
delay[chan] -= SCROLL_DELAY_DECREASE;
return true; return true;
} }
else
{
if(scrollDelay > 0)
scrollDelay--;
}
} }
return false; return false;
} }
@ -243,24 +259,28 @@ bool GuiTrigger::Down()
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN || (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN
|| pad.stickY < -PADCAL || pad.stickY < -PADCAL
|| WPAD_Stick(0,1) < -PADCAL) || WPAD_StickY(0) < -PADCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
|| pad.btns_d & PAD_BUTTON_DOWN) || pad.btns_d & PAD_BUTTON_DOWN)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. prev[chan] = gettime();
delay[chan] = SCROLLL_DELAY_INITIAL; // reset scroll delay
return true; return true;
} }
else if(scrollDelay == 0)
now[chan] = gettime();
if(diff_usec(prev[chan], now[chan]) > delay[chan])
{ {
scrollDelay = SCROLL_LOOP_DELAY; prev[chan] = now[chan];
if(delay[chan] == SCROLLL_DELAY_INITIAL)
delay[chan] = SCROLL_DELAY_LOOP;
else if(delay[chan] > SCROLL_DELAY_DECREASE)
delay[chan] -= SCROLL_DELAY_DECREASE;
return true; return true;
} }
else
{
if(scrollDelay > 0)
scrollDelay--;
}
} }
return false; return false;
} }