*added a little screensaver which depends on the wiimote timeout (for now set to 300 seconds)

*added 2 functions (by dimok) to wpad.c: bool IsWpadConnected();
void WPad_SetIdleTime(u32 seconds);
This commit is contained in:
mauricewoelk 2009-06-18 07:36:23 +00:00
parent ed5370945d
commit 383aaa45e5
7 changed files with 98 additions and 4 deletions

View File

@ -20,6 +20,9 @@ extern const u32 clock_ttf_size;
extern const u8 closebutton_png[]; extern const u8 closebutton_png[];
extern const u32 closebutton_png_size; extern const u32 closebutton_png_size;
extern const u8 gxlogo_png[];
extern const u32 gxlogo_png_size;
extern const u8 sdcard_png[]; extern const u8 sdcard_png[];
extern const u32 sdcard_png_size; extern const u32 sdcard_png_size;

BIN
source/images/gxlogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -190,6 +190,9 @@ static int MenuDiscList()
char ID[4]; char ID[4];
char IDfull[7]; 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; datagB=0;
int menu = MENU_NONE, dataef=0; int menu = MENU_NONE, dataef=0;
@ -1303,7 +1306,15 @@ 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(); HaltGui();
mainWindow->RemoveAll(); mainWindow->RemoveAll();

View File

@ -4,6 +4,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <dirent.h> #include <dirent.h>
#include <time.h>
#include <stdlib.h>
#include "usbloader/wbfs.h" #include "usbloader/wbfs.h"
#include "usbloader/wdvd.h" #include "usbloader/wdvd.h"
@ -315,6 +317,58 @@ void WindowCredits()
SetVolumeOgg(255*(Settings.volume/100.0)); 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 * WindowPrompt
* *

View File

@ -22,5 +22,6 @@ int ProgressWindow(const char *title, const char *msg);
int ProgressDownloadWindow(int choice2); int ProgressDownloadWindow(int choice2);
int ProgressUpdateWindow(); int ProgressUpdateWindow();
char * GetMissingFiles(); char * GetMissingFiles();
void WindowScreensaver();
#endif #endif

View File

@ -16,6 +16,11 @@ void __Wpad_PowerCallback(s32 chan)
shutdown = 1; shutdown = 1;
} }
void WPad_SetIdleTime(u32 seconds)
{
/*Set idle time for wiimote*/
WPAD_SetIdleTimeout(seconds);
}
s32 Wpad_Init(void) s32 Wpad_Init(void)
{ {
@ -44,6 +49,24 @@ void Wpad_Disconnect(void)
WPAD_Shutdown(); 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) { u32 ButtonsHold(void) {
int i; int i;

View File

@ -13,6 +13,8 @@ s32 Wpad_Init(void);
void Wpad_Disconnect(void); void Wpad_Disconnect(void);
u32 ButtonsPressed(void); u32 ButtonsPressed(void);
u32 ButtonsHold(void); u32 ButtonsHold(void);
bool IsWpadConnected();
void WPad_SetIdleTime(u32 seconds);
#ifdef __cplusplus #ifdef __cplusplus
} }