From daa7e8195e1b793ffdd5605159ca4d70e20641c4 Mon Sep 17 00:00:00 2001 From: dborth Date: Wed, 4 Nov 2009 21:27:16 +0000 Subject: [PATCH] change scrolling timing --- source/ngc/gui/gui.h | 5 +- source/ngc/gui/gui_trigger.cpp | 94 +++++++++++++++++++++------------- 2 files changed, 60 insertions(+), 39 deletions(-) diff --git a/source/ngc/gui/gui.h b/source/ngc/gui/gui.h index 82cdeeb..52ab263 100644 --- a/source/ngc/gui/gui.h +++ b/source/ngc/gui/gui.h @@ -52,8 +52,9 @@ extern FreeTypeGX *fontSystem[]; -#define SCROLL_INITIAL_DELAY 20 -#define SCROLL_LOOP_DELAY 3 +#define SCROLL_DELAY_INITIAL 200000 +#define SCROLL_DELAY_LOOP 30000 +#define SCROLL_DELAY_DECREASE 300 #define FILE_PAGESIZE 10 #define PAGESIZE 8 #define SAVELISTSIZE 6 diff --git a/source/ngc/gui/gui_trigger.cpp b/source/ngc/gui/gui_trigger.cpp index 591a949..d120d75 100644 --- a/source/ngc/gui/gui_trigger.cpp +++ b/source/ngc/gui/gui_trigger.cpp @@ -9,8 +9,12 @@ ***************************************************************************/ #include "gui.h" +#include +#include -static int scrollDelay = 0; +static u64 prev[4]; +static u64 now[4]; +static u32 delay[4]; /** * Constructor for the GuiTrigger class. @@ -156,24 +160,28 @@ bool GuiTrigger::Left() if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) || (pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT || pad.stickX < -PADCAL - || WPAD_Stick(0,0) < -PADCAL) + || WPAD_StickX(0) < -PADCAL) { if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_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; } - 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; } - else - { - if(scrollDelay > 0) - scrollDelay--; - } } return false; } @@ -185,24 +193,28 @@ bool GuiTrigger::Right() if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) || (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT || pad.stickX > PADCAL - || WPAD_Stick(0,0) > PADCAL) + || WPAD_StickX(0) > PADCAL) { if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_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; } - 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; } - else - { - if(scrollDelay > 0) - scrollDelay--; - } } return false; } @@ -214,24 +226,28 @@ bool GuiTrigger::Up() if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP) || (pad.btns_d | pad.btns_h) & PAD_BUTTON_UP || pad.stickY > PADCAL - || WPAD_Stick(0,1) > PADCAL) + || WPAD_StickY(0) > PADCAL) { if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_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; } - 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; } - else - { - if(scrollDelay > 0) - scrollDelay--; - } } return false; } @@ -243,24 +259,28 @@ bool GuiTrigger::Down() if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) || (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN || pad.stickY < -PADCAL - || WPAD_Stick(0,1) < -PADCAL) + || WPAD_StickY(0) < -PADCAL) { if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_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; } - 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; } - else - { - if(scrollDelay > 0) - scrollDelay--; - } } return false; }