Line 23:
Line 23:
#include <gccore.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <wiiuse/wpad.h>
+
#include <ogc/system.h>
#define VERSION "INFO"
#define VERSION "INFO"
−
#define RELEASE_DATE "27-01-2009"
+
#define RELEASE_DATE "08-09-2009"
int numberOfAttachedControllers();
int numberOfAttachedControllers();
+
void waitForWiimote();
static u32 *xfb;
static u32 *xfb;
Line 83:
Line 85:
//find out how many wii remotes are attached at the start
//find out how many wii remotes are attached at the start
+
waitForWiimote();
totalWiiMotes = numberOfAttachedControllers();
totalWiiMotes = numberOfAttachedControllers();
}
}
Line 98:
Line 101:
void showWiiMoteAccelerometer(void) {
void showWiiMoteAccelerometer(void) {
+
printf("\x1b[2J");
while(1) {
while(1) {
u32 ext;//Extension type
u32 ext;//Extension type
−
u32 ret=0;//remote probe return
+
u32 ret = 0;//remote scan and probe return
−
ret=WPAD_Probe(WPAD_CHAN_0,&ext);//probe remote 1 with extension
+
ret = WPAD_ScanPads();
−
+
ret = WPAD_Probe(WPAD_CHAN_0, &ext);//probe remote 1 with extension
−
WPAD_ScanPads();//scan for input from remote
WPADData *Data = WPAD_Data(WPAD_CHAN_0);//store data from remote 1
WPADData *Data = WPAD_Data(WPAD_CHAN_0);//store data from remote 1
WPADData data = *Data;
WPADData data = *Data;
−
WPAD_IR(WPAD_CHAN_0, &data.ir);//get IR data
+
WPAD_IR(WPAD_CHAN_0, &(data.ir));//get IR data
−
WPAD_Orientation(WPAD_CHAN_0, &data.orient);//get rotation data
+
WPAD_Orientation(WPAD_CHAN_0, &(data.orient));//get rotation data
−
WPAD_GForce(WPAD_CHAN_0, &data.gforce);//get "speed" data
+
WPAD_GForce(WPAD_CHAN_0, &(data.gforce));//get "speed" data
−
WPAD_Accel(WPAD_CHAN_0, &data.accel);//get accelerometer data
+
WPAD_Accel(WPAD_CHAN_0, &(data.accel));//get accelerometer data
−
WPAD_Expansion(WPAD_CHAN_0, &data.exp);//get expansion data
+
WPAD_Expansion(WPAD_CHAN_0, &(data.exp));//get expansion data
−
printf("\x1b[1;0HWii Remote Info \n");
+
printf("\x1b[1;0HWii Remote Info \n");
//print gforce data for x, y, and z
//print gforce data for x, y, and z
−
printf("\x1b[2;0HGForce x: %1.3f \n", data.gforce.x);
+
printf("\x1b[2;0HGForce x: %1.3f \n", data.gforce.x);
−
printf("\x1b[3;0HGForce y: %1.3f \n", data.gforce.y);
+
printf("\x1b[3;0HGForce y: %1.3f \n", data.gforce.y);
−
printf("\x1b[4;0HGForce z: %1.3f \n", data.gforce.z);
+
printf("\x1b[4;0HGForce z: %1.3f \n", data.gforce.z);
Line 138:
Line 141:
}
}
−
printf("\x1b[5;0HxRotation: %d \n", xRotation);
+
printf("\x1b[5;0HxRotation: %d \n", xRotation);
−
printf("\x1b[6;0HyRotation: %d \n", yRotation);
+
printf("\x1b[6;0HyRotation: %d \n", yRotation);
−
printf("\x1b[7;0HzRotation: %d \n", zRotation);
+
printf("\x1b[7;0HzRotation: %d \n", zRotation);
//print different IR data
//print different IR data
−
printf("\x1b[9;0HIR x: %1.3f \n", data.ir.x);
+
printf("\x1b[9;0HIR x: %1.3f \n", data.ir.x);
−
printf("\x1b[10;0HIR y: %1.3f \n", data.ir.y);
+
printf("\x1b[10;0HIR y: %1.3f \n", data.ir.y);
−
printf("\x1b[11;0HIR RAW X %1.3f", data.ir.ax);
+
printf("\x1b[11;0HIR RAW X %1.3f ", data.ir.ax);
−
printf("\x1b[12;0HIR RAW Y %1.3f", data.ir.ay);
+
printf("\x1b[12;0HIR RAW Y %1.3f ", data.ir.ay);
−
printf("\x1b[13;0HIR SMOOTH X %1.3f", data.ir.sx);
+
printf("\x1b[13;0HIR SMOOTH X %1.3f ", data.ir.sx);
−
printf("\x1b[14;0HIR SMOOTH Y %1.3f", data.ir.sy);
+
printf("\x1b[14;0HIR SMOOTH Y %1.3f ", data.ir.sy);
−
printf("\x1b[15;0HIR ANGLE %1.3f", data.ir.angle);
+
printf("\x1b[15;0HIR ANGLE %1.3f ", data.ir.angle);
//print accelerometer data
//print accelerometer data
−
printf("\x1b[1;25HACCEL X %d\n", (int)data.accel.x);
+
printf("\x1b[1;25HACCEL X %d \n", (int)data.accel.x);
−
printf("\x1b[2;25HACCEL Y %d\n", (int)data.accel.y);
+
printf("\x1b[2;25HACCEL Y %d \n", (int)data.accel.y);
−
printf("\x1b[3;25HACCEL Z %d\n", (int)data.accel.z);
+
printf("\x1b[3;25HACCEL Z %d \n", (int)data.accel.z);
−
if(ret==WPAD_ERR_NONE && ext==WPAD_EXP_NUNCHUK)
+
if((ret == WPAD_ERR_NONE) && (ext == WPAD_EXP_NUNCHUK))
{
{
−
printf("\x1b[4;25HNCUHCK MIN X %d Y %d", (int)data.exp.nunchuk.js.min.x, (int)data.exp.nunchuk.js.min.y);
+
printf("\x1b[4;25HNCUHCK MIN X %d Y %d ", (int)data.exp.nunchuk.js.min.x, (int)data.exp.nunchuk.js.min.y);
−
printf("\x1b[5;25HNCUHCK MAX X %d Y %d", (int)data.exp.nunchuk.js.max.x, (int)data.exp.nunchuk.js.max.y);
+
printf("\x1b[5;25HNCUHCK MAX X %d Y %d ", (int)data.exp.nunchuk.js.max.x, (int)data.exp.nunchuk.js.max.y);
−
printf("\x1b[6;25HNCUHCK CENTER X %d Y %d", (int)data.exp.nunchuk.js.center.x, (int)data.exp.nunchuk.js.center.y);
+
printf("\x1b[6;25HNCUHCK CENTER X %d Y %d ", (int)data.exp.nunchuk.js.center.x, (int)data.exp.nunchuk.js.center.y);
−
printf("\x1b[7;25HNCUHCK POS X %d Y %d", (int)data.exp.nunchuk.js.pos.x, (int)data.exp.nunchuk.js.pos.y);
+
printf("\x1b[7;25HNCUHCK POS X %d Y %d ", (int)data.exp.nunchuk.js.pos.x, (int)data.exp.nunchuk.js.pos.y);
−
printf("\x1b[8;25HNCUHCK ANG %1.3f MAG %1.3f", (float)data.exp.nunchuk.js.ang, (float)data.exp.nunchuk.js.mag);
+
printf("\x1b[8;25HNCUHCK ANG %1.3f MAG %1.3f ", (float)data.exp.nunchuk.js.ang, (float)data.exp.nunchuk.js.mag);
−
−
printf("\x1b[9;25HGFORCE X %1.3f\n", (float)data.exp.nunchuk.gforce.x);
+
printf("\x1b[9;25HGFORCE X %1.3f \n", (float)data.exp.nunchuk.gforce.x);
−
printf("\x1b[10;25HGFORCE Y %1.3f\n", (float)data.exp.nunchuk.gforce.y);
+
printf("\x1b[10;25HGFORCE Y %1.3f \n", (float)data.exp.nunchuk.gforce.y);
−
printf("\x1b[11;25HGFORCE Z %1.3f\n", (float)data.exp.nunchuk.gforce.z);
+
printf("\x1b[11;25HGFORCE Z %1.3f \n", (float)data.exp.nunchuk.gforce.z);
−
printf("\x1b[11;25HROTATE X %1.3f\n", (float)data.exp.nunchuk.orient.roll);
+
printf("\x1b[12;25HROTATE X %1.3f \n", (float)data.exp.nunchuk.orient.roll);
−
printf("\x1b[11;25HROTATE Y %1.3f\n", (float)data.exp.nunchuk.orient.pitch);
+
printf("\x1b[13;25HROTATE Y %1.3f \n", (float)data.exp.nunchuk.orient.pitch);
−
printf("\x1b[11;25HROTATE Z %1.3f\n", (float)data.exp.nunchuk.orient.yaw);
+
printf("\x1b[14;25HROTATE Z %1.3f \n", (float)data.exp.nunchuk.orient.yaw);
−
printf("\x1b[11;25HACCEL X %1.3f\n", (float)data.exp.nunchuk.accel.x);
+
printf("\x1b[15;25HACCEL X %1.3f \n", (float)data.exp.nunchuk.accel.x);
−
printf("\x1b[11;25HACCEL Y %1.3f\n", (float)data.exp.nunchuk.accel.y);
+
printf("\x1b[16;25HACCEL Y %1.3f \n", (float)data.exp.nunchuk.accel.y);
−
printf("\x1b[11;25HACCEL Z %1.3f\n", (float)data.exp.nunchuk.accel.z);
+
printf("\x1b[17;25HACCEL Z %1.3f \n", (float)data.exp.nunchuk.accel.z);
}
}
u32 pressed = WPAD_ButtonsHeld(WPAD_CHAN_0);
u32 pressed = WPAD_ButtonsHeld(WPAD_CHAN_0);
u32 buttonDown = WPAD_ButtonsDown(WPAD_CHAN_0);
u32 buttonDown = WPAD_ButtonsDown(WPAD_CHAN_0);
−
if (pressed & WPAD_NUNCHUK_BUTTON_Z) printf("\x1b[18;0HButton Z pressed on Nunchuk");
if (pressed & WPAD_NUNCHUK_BUTTON_Z) printf("\x1b[18;0HButton Z pressed on Nunchuk");
Line 198:
Line 199:
if (pressed & WPAD_BUTTON_LEFT) printf("\x1b[22;25HButton LEFT pressed");
if (pressed & WPAD_BUTTON_LEFT) printf("\x1b[22;25HButton LEFT pressed");
if (pressed & WPAD_BUTTON_RIGHT) printf("\x1b[23;25HButton RIGHT pressed");
if (pressed & WPAD_BUTTON_RIGHT) printf("\x1b[23;25HButton RIGHT pressed");
+
+
printf("\x1b[24;25HNumber of wiimotes: %d", totalWiiMotes);
+
printf("\x1b[24;1Hret: %d", ret);
+
if (buttonDown & (WPAD_BUTTON_1 | WPAD_BUTTON_2)) {
if (buttonDown & (WPAD_BUTTON_1 | WPAD_BUTTON_2)) {
if ( rumbleOn == 0 ) {
if ( rumbleOn == 0 ) {
Line 216:
Line 221:
exitToHomebrewChannel();
exitToHomebrewChannel();
}
}
−
+
if(SYS_ResetButtonDown()) exitToHomebrewChannel();
−
+
VIDEO_WaitVSync();
+
printf("\x1b[2J");
}
}
}
}
Line 241:
Line 247:
while(1)
while(1)
{
{
+
printf("\x1b[20;20HWaiting for wiimote");
totalWiiMotes = numberOfAttachedControllers();
totalWiiMotes = numberOfAttachedControllers();
if (totalWiiMotes > 0) break;
if (totalWiiMotes > 0) break;
}
}
+
return;
}
}
Line 253:
Line 261:
Initialize();
Initialize();
−
−
waitForWiimote();
showWiiMoteAccelerometer();
showWiiMoteAccelerometer();