usbloadergx/source/wpad.c
giantpune 55a401e4a5 lots of changes here
changed gprintf() to use crediar's method because it is smaller and works just the same.

allow r-win's debug printf() stuff to be sent to the gecko to reduce redundant stuff there 

issue 1073.  headless mode - allow game to be booted via argv[1].

took out all the params from the exitprompt since they aren't used.

took out all the #ifdef stuff for building for a wii.  obviously this wont run on a gamecube so it isn't needed.

added a way to check what version of a IOS is installed before trying to boot into it.  added IOS_ReloadIOSsafe(). this should stop idiots with the 4.2 stubs from bitching about why stuff doesn't work.

use that check so you only see the "222v4 is needed" prompt in the settings if you don't already have that installed.

fix issue 1039. (must still be compiled without NO_DEBUG defined because technically WiiRD is a debugger)
2009-12-03 01:06:09 +00:00

117 lines
3.3 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;
}
void WPad_SetIdleTime(u32 seconds) {
/*Set idle time for wiimote*/
WPAD_SetIdleTimeout(seconds);
}
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;
/* Don't remove this commented out code it might be useful for checking which buttons were pressed/hold
if(buttons & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP
| PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_MENU
| PAD_BUTTON_START | WPAD_BUTTON_2 | WPAD_BUTTON_1
| WPAD_BUTTON_B | WPAD_BUTTON_A | WPAD_BUTTON_MINUS
| WPAD_BUTTON_HOME | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT
| WPAD_BUTTON_DOWN | WPAD_BUTTON_UP | WPAD_BUTTON_PLUS
| WPAD_NUNCHUK_BUTTON_Z | WPAD_NUNCHUK_BUTTON_C
| WPAD_CLASSIC_BUTTON_UP | WPAD_CLASSIC_BUTTON_LEFT
| WPAD_CLASSIC_BUTTON_ZR | WPAD_CLASSIC_BUTTON_X
| WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_Y
| WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_ZL
| WPAD_CLASSIC_BUTTON_FULL_R | WPAD_CLASSIC_BUTTON_PLUS
| WPAD_CLASSIC_BUTTON_HOME | WPAD_CLASSIC_BUTTON_MINUS
| WPAD_CLASSIC_BUTTON_FULL_L | WPAD_CLASSIC_BUTTON_DOWN
| WPAD_CLASSIC_BUTTON_RIGHT | WPAD_GUITAR_HERO_3_BUTTON_STRUM_UP
| WPAD_GUITAR_HERO_3_BUTTON_YELLOW | WPAD_GUITAR_HERO_3_BUTTON_GREEN
| WPAD_GUITAR_HERO_3_BUTTON_BLUE | WPAD_GUITAR_HERO_3_BUTTON_RED
| WPAD_GUITAR_HERO_3_BUTTON_ORANGE | WPAD_GUITAR_HERO_3_BUTTON_PLUS
| WPAD_GUITAR_HERO_3_BUTTON_MINUS | WPAD_GUITAR_HERO_3_BUTTON_STRUM_DOWN)
)
*/
}