Athena: Wiimote and Mac OS X
Battery Life Remaining
One thing I never understood about the Wiimote design, is that it is used for moving actions and gestures, so why not have a kinetic charger built into it to try and take some load off the batteries.
It is helpful to know how much power the battery has left, so to do so you just need to request a status report.
This will return with a message id of 0x20, that will contains details about the battery, as well as a few other things.
//
//
#define STATUS_REPORT_LOWBATTERY ( 1 << 0 )
#define STATUS_REPORT_EXTENSION ( 1 << 1 )
#define STATUS_REPORT_SPEAKER ( 1 << 2 )
#define STATUS_REPORT_ALWAYS ( 1 << 3 )
#define STATUS_REPORT_P1_LED ( 1 << 4 )
#define STATUS_REPORT_P2_LED ( 1 << 5 )
#define STATUS_REPORT_P3_LED ( 1 << 6 )
#define STATUS_REPORT_P4_LED ( 1 << 7 )
//
#define FULL_BATTERY ( 0xC0 )
//
//
void HIDInput::Wiimote::DeviceIOHIDReportCallback( const unsigned char * inReportData, const unsigned int inSize )
{
switch( inReportData[0] )
{
// Status
case 0x20:
{
//
GetButtonData( &inReport[1] );
//
printf( "P1 LED: %s\n", inReport[3] & STATUS_REPORT_P1_LED ? "true" : "false" );
printf( "P2 LED: %s\n", inReport[3] & STATUS_REPORT_P2_LED ? "true" : "false" );
printf( "P3 LED: %s\n", inReport[3] & STATUS_REPORT_P3_LED ? "true" : "false" );
printf( "P4 LED: %s\n", inReport[3] & STATUS_REPORT_P4_LED ? "true" : "false" );
printf( "Always: %s\n", inReport[3] & STATUS_REPORT_ALWAYS ? "true" : "false" );
printf( "Speaker: %s\n", inReport[3] & STATUS_REPORT_SPEAKER ? "true" : "false" );
printf( "Extension: %s\n", inReport[3] & STATUS_REPORT_EXTENSION ? "true" : "false" );
printf( "Low Battery: %s\n", inReport[3] & STATUS_REPORT_LOWBATTERY ? "true" : "false" );
printf( "Battery: %.2f%%\n", static_cast<Core::f32>( inReport[6] ) / static_cast<Core::f32>( FULL_BATTERY ) );
printf( "\n" );
}
break;
// Command Status
case 0x22:
{
// ...
}
break;
// Button Input Report
case 0x30:
{
// ...
}
break;
default:
break;
}
}
Whenever an extension is plugged in or removed, a status message will be sent to inform you, so whenever you get one of these messages, its usually good to check to see if the extension status has changed so you can request a new input report.
Well thats all for now, all I need is a Playstation 3 pad to play around with. As I've mentioned, I may expand it further when I've gotten the accelerometer and IR camera working properly.


