diff --git a/source/filelist.h b/source/filelist.h index 4b057c8e..aa384775 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -20,6 +20,9 @@ extern const u32 clock_ttf_size; extern const u8 closebutton_png[]; extern const u32 closebutton_png_size; +extern const u8 gxlogo_png[]; +extern const u32 gxlogo_png_size; + extern const u8 sdcard_png[]; extern const u32 sdcard_png_size; diff --git a/source/images/gxlogo.png b/source/images/gxlogo.png new file mode 100644 index 00000000..dadd5cb6 Binary files /dev/null and b/source/images/gxlogo.png differ diff --git a/source/menu.cpp b/source/menu.cpp index 4f3a641e..39b5bc9d 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -189,7 +189,10 @@ static int MenuDiscList() int selectImg1 = 0; char ID[4]; char IDfull[7]; - + + //SCREENSAVER + WPad_SetIdleTime(300); //needs the time in seconds + int check = 0; //to skip the first cycle when wiimote isn't completely connected datagB=0; int menu = MENU_NONE, dataef=0; @@ -1303,8 +1306,16 @@ static int MenuDiscList() } } } - } - + /* to skip the first call of windowScreensaver at startup when wiimote is not connected */ + if(IsWpadConnected()){check = 1;} + + /* screensaver is called when wiimote shuts down, depending on the wiimotet idletime */ + if(!IsWpadConnected() && check == 1) + { + WindowScreensaver(); + } + } + HaltGui(); mainWindow->RemoveAll(); mainWindow->Append(bgImg); diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index e9a08ff0..43b82cc5 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "usbloader/wbfs.h" #include "usbloader/wdvd.h" @@ -315,6 +317,58 @@ void WindowCredits() SetVolumeOgg(255*(Settings.volume/100.0)); } +/**************************************************************************** + * WindowScreensaver + * Display screensaver + ***************************************************************************/ +void WindowScreensaver() +{ + int i = 0; + bool exit = false; + + /* initialize random seed: */ + srand ( time(NULL) ); + + GuiImageData GXlogo(gxlogo_png); + GuiImage GXlogoImg(&GXlogo); + GXlogoImg.SetPosition(172,152); + GXlogoImg.SetAlignment(ALIGN_LEFT,ALIGN_TOP); + + GuiImage BackgroundImg(640,480,(GXColor){0, 0, 0, 255}); + BackgroundImg.SetPosition(0,0); + BackgroundImg.SetAlignment(ALIGN_LEFT,ALIGN_TOP); + + GuiWindow screensaverWindow(screenwidth,screenheight); + screensaverWindow.Append(&BackgroundImg); + screensaverWindow.Append(&GXlogoImg); + + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&screensaverWindow); + ResumeGui(); + + while(!exit) + { + i++; + if(IsWpadConnected()) + { + exit = true; + } + /* Set position only every 400000th loop */ + if((i % 8000000) == 0) + { + /* Set random position */ + GXlogoImg.SetPosition((rand() % 345), (rand() % 305)); + } + + } + + HaltGui(); + mainWindow->Remove(&screensaverWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); +} + /**************************************************************************** * WindowPrompt * diff --git a/source/prompts/PromptWindows.h b/source/prompts/PromptWindows.h index 23aeaee2..271ab9fc 100644 --- a/source/prompts/PromptWindows.h +++ b/source/prompts/PromptWindows.h @@ -22,5 +22,6 @@ int ProgressWindow(const char *title, const char *msg); int ProgressDownloadWindow(int choice2); int ProgressUpdateWindow(); char * GetMissingFiles(); +void WindowScreensaver(); #endif diff --git a/source/wpad.c b/source/wpad.c index 573ad52e..82cb5416 100644 --- a/source/wpad.c +++ b/source/wpad.c @@ -16,6 +16,11 @@ void __Wpad_PowerCallback(s32 chan) shutdown = 1; } +void WPad_SetIdleTime(u32 seconds) +{ + /*Set idle time for wiimote*/ + WPAD_SetIdleTimeout(seconds); +} s32 Wpad_Init(void) { @@ -44,6 +49,24 @@ void Wpad_Disconnect(void) WPAD_Shutdown(); } +bool IsWpadConnected() +{ + int i = 0; + u32 test = 0; + int notconnected = 0; + #ifdef HW_RVL + for(i = 0; i < 4; i++) { + if(WPAD_Probe(i, &test) == WPAD_ERR_NO_CONTROLLER) { + notconnected++; + } + } + #endif + if(notconnected < 4) + return true; + else + return false; +} + u32 ButtonsHold(void) { int i; diff --git a/source/wpad.h b/source/wpad.h index 55e22f28..5669a2a1 100644 --- a/source/wpad.h +++ b/source/wpad.h @@ -12,7 +12,9 @@ extern "C" s32 Wpad_Init(void); void Wpad_Disconnect(void); u32 ButtonsPressed(void); -u32 ButtonsHold(void); +u32 ButtonsHold(void); +bool IsWpadConnected(); +void WPad_SetIdleTime(u32 seconds); #ifdef __cplusplus }