mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-26 05:04:16 +01:00
*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:
parent
ed5370945d
commit
383aaa45e5
@ -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
BIN
source/images/gxlogo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -189,7 +189,10 @@ static int MenuDiscList()
|
|||||||
int selectImg1 = 0;
|
int selectImg1 = 0;
|
||||||
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,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();
|
HaltGui();
|
||||||
mainWindow->RemoveAll();
|
mainWindow->RemoveAll();
|
||||||
mainWindow->Append(bgImg);
|
mainWindow->Append(bgImg);
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
@ -12,7 +12,9 @@ extern "C"
|
|||||||
s32 Wpad_Init(void);
|
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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user