mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-18 17:29:17 +01:00
798ebc188d
*Corrected Screensaver appearance on startup after 30sec of unconnected WiiMote *Complete rewrite of theme downloader. (Downloading themes is not working currently because Deak Phreak changed something on wii.spiffy360.com. He said it's going to be changed back soon) *Added possibility to load theme images from a folder with the same name as the .them file. The "Image-Folder: Example\n" from the .them file is prioritized. *Updated some language files. (Translators please redownload the files from SVN. Many files had a lot of errors in them)
94 lines
1.5 KiB
C
94 lines
1.5 KiB
C
#include <stdio.h>
|
|
#include <ogcsys.h>
|
|
#include <ogc/pad.h>
|
|
|
|
#include "sys.h"
|
|
#include "wpad.h"
|
|
|
|
/* Constants */
|
|
#define MAX_WIIMOTES 4
|
|
|
|
extern u8 shutdown;
|
|
|
|
void __Wpad_PowerCallback(s32 chan)
|
|
{
|
|
/* Poweroff console */
|
|
shutdown = 1;
|
|
}
|
|
|
|
s32 Wpad_Init(void)
|
|
{
|
|
s32 ret;
|
|
|
|
/* Initialize Wiimote subsystem */
|
|
ret = WPAD_Init();
|
|
if (ret < 0) return ret;
|
|
|
|
/* Set POWER button callback */
|
|
WPAD_SetPowerButtonCallback(__Wpad_PowerCallback);
|
|
|
|
return ret;
|
|
}
|
|
|
|
void Wpad_Disconnect(void)
|
|
{
|
|
u32 cnt;
|
|
|
|
/* Disconnect Wiimotes */
|
|
for (cnt = 0; cnt < MAX_WIIMOTES; cnt++)
|
|
WPAD_Disconnect(cnt);
|
|
|
|
/* Shutdown Wiimote subsystem */
|
|
WPAD_Shutdown();
|
|
}
|
|
|
|
bool IsWpadConnected()
|
|
{
|
|
int i = 0;
|
|
u32 test = 0;
|
|
int notconnected = 0;
|
|
for (i = 0; i < 4; i++)
|
|
{
|
|
if (WPAD_Probe(i, &test) == WPAD_ERR_NO_CONTROLLER)
|
|
{
|
|
notconnected++;
|
|
}
|
|
}
|
|
if (notconnected < 4)
|
|
return true;
|
|
else return false;
|
|
}
|
|
|
|
u32 ButtonsHold(void)
|
|
{
|
|
|
|
int i;
|
|
u32 buttons = 0;
|
|
|
|
WPAD_ScanPads();
|
|
PAD_ScanPads();
|
|
|
|
for (i = 3; i >= 0; i--)
|
|
{
|
|
buttons |= PAD_ButtonsHeld(i);
|
|
buttons |= WPAD_ButtonsHeld(i);
|
|
}
|
|
return buttons;
|
|
}
|
|
|
|
u32 ButtonsPressed(void)
|
|
{
|
|
int i;
|
|
u32 buttons = 0;
|
|
|
|
WPAD_ScanPads();
|
|
PAD_ScanPads();
|
|
|
|
for (i = 3; i >= 0; i--)
|
|
{
|
|
buttons |= PAD_ButtonsDown(i);
|
|
buttons |= WPAD_ButtonsDown(i);
|
|
}
|
|
return buttons;
|
|
}
|