From d16ee561f3d4f91d57b7d09e21472ad707bdee19 Mon Sep 17 00:00:00 2001 From: dborth Date: Sat, 27 Jun 2009 20:05:45 +0000 Subject: [PATCH] change video callbacks to avoid over-reading pads --- readme.txt | 2 ++ source/ngc/fileop.cpp | 2 +- source/ngc/gcvideo.cpp | 41 +++++------------------------------------ source/ngc/pad.cpp | 34 ++++++++++++++++++++++++++++++++++ source/ngc/pad.h | 1 + 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/readme.txt b/readme.txt index 368b336..05fc271 100644 --- a/readme.txt +++ b/readme.txt @@ -35,6 +35,8 @@ Wii/GameCube. [3.0.5] * Increase file browser listing to 10 entries, decrease font size +* Added text scrolling on file browser +* Added reset button for controller mappings * Settings are now loaded from USB when loading the app from USB on HBC * Fixed original mode lockup bug * Fixed menu crashes caused by ogg player bugs diff --git a/source/ngc/fileop.cpp b/source/ngc/fileop.cpp index 6b27208..9686f46 100644 --- a/source/ngc/fileop.cpp +++ b/source/ngc/fileop.cpp @@ -393,7 +393,7 @@ ParseDirectory(int method) } else { - StripExt(browserList[entryNum].displayname, filename); // hide file extension + StripExt(browserList[entryNum].displayname, browserList[entryNum].filename); // hide file extension } browserList[entryNum].length = filestat.st_size; diff --git a/source/ngc/gcvideo.cpp b/source/ngc/gcvideo.cpp index 1dbb3cb..6540abe 100644 --- a/source/ngc/gcvideo.cpp +++ b/source/ngc/gcvideo.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "driver.h" @@ -438,39 +437,6 @@ UpdateScaling() draw_init (); } -/**************************************************************************** - * UpdatePadsCB - * - * called by postRetraceCallback in InitGCVideo - scans gcpad and wpad - ***************************************************************************/ -static void -UpdatePadsCB () -{ - #ifdef HW_RVL - WPAD_ScanPads(); - #endif - PAD_ScanPads(); - - for(int i=3; i >= 0; i--) - { - #ifdef HW_RVL - memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); - #endif - - userInput[i].chan = i; - userInput[i].pad.btns_d = PAD_ButtonsDown(i); - userInput[i].pad.btns_u = PAD_ButtonsUp(i); - userInput[i].pad.btns_h = PAD_ButtonsHeld(i); - userInput[i].pad.stickX = PAD_StickX(i); - userInput[i].pad.stickY = PAD_StickY(i); - userInput[i].pad.substickX = PAD_SubStickX(i); - userInput[i].pad.substickY = PAD_SubStickY(i); - userInput[i].pad.triggerL = PAD_TriggerL(i); - userInput[i].pad.triggerR = PAD_TriggerR(i); - } -} - - /**************************************************************************** * SetupVideoMode * @@ -597,8 +563,7 @@ InitGCVideo () VIDEO_SetNextFramebuffer (xfb[0]); // video callbacks - VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB); - VIDEO_SetPreRetraceCallback ((VIRetraceCallback)copy_to_xfb); + VIDEO_SetPostRetraceCallback ((VIRetraceCallback)copy_to_xfb); VIDEO_SetBlack (FALSE); VIDEO_Flush (); @@ -639,6 +604,8 @@ ResetVideo_Emu () while (VIDEO_GetNextField()) VIDEO_WaitVSync(); + VIDEO_SetPreRetraceCallback(NULL); + GXColor background = {0, 0, 0, 255}; GX_SetCopyClear (background, 0x00ffffff); @@ -866,6 +833,8 @@ ResetVideo_Menu () while (VIDEO_GetNextField()) VIDEO_WaitVSync(); + VIDEO_SetPreRetraceCallback((VIRetraceCallback)UpdatePads); + // clears the bg to color and clears the z buffer GXColor background = {0, 0, 0, 255}; GX_SetCopyClear (background, 0x00ffffff); diff --git a/source/ngc/pad.cpp b/source/ngc/pad.cpp index c1f9607..69aa254 100644 --- a/source/ngc/pad.cpp +++ b/source/ngc/pad.cpp @@ -186,6 +186,38 @@ void SetControllers() } } +/**************************************************************************** + * UpdatePads + * + * called by postRetraceCallback in InitGCVideo - scans pad and wpad + ***************************************************************************/ +static void +UpdatePads () +{ + #ifdef HW_RVL + WPAD_ScanPads(); + #endif + PAD_ScanPads(); + + for(int i=3; i >= 0; i--) + { + #ifdef HW_RVL + memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); + #endif + + userInput[i].chan = i; + userInput[i].pad.btns_d = PAD_ButtonsDown(i); + userInput[i].pad.btns_u = PAD_ButtonsUp(i); + userInput[i].pad.btns_h = PAD_ButtonsHeld(i); + userInput[i].pad.stickX = PAD_StickX(i); + userInput[i].pad.stickY = PAD_StickY(i); + userInput[i].pad.substickX = PAD_SubStickX(i); + userInput[i].pad.substickY = PAD_SubStickY(i); + userInput[i].pad.triggerL = PAD_TriggerL(i); + userInput[i].pad.triggerR = PAD_TriggerR(i); + } +} + #ifdef HW_RVL /**************************************************************************** @@ -604,6 +636,8 @@ void GetJoy() unsigned char pad[4]; short i; + UpdatePads(); + // Turbo mode // RIGHT on c-stick and on classic ctrlr right joystick if(userInput[0].pad.substickX > 70 || userInput[0].WPAD_Stick(1,0) > 70) diff --git a/source/ngc/pad.h b/source/ngc/pad.h index 867de58..ac2f43d 100644 --- a/source/ngc/pad.h +++ b/source/ngc/pad.h @@ -33,5 +33,6 @@ s8 WPAD_StickY(u8 chan, u8 right); void GetJoy(); void DrawCursor(); bool MenuRequested(); +void UpdatePads(); #endif