2010-04-24 00:44:10 +00:00
|
|
|
#include "Drums.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace WiimoteEmu
|
|
|
|
{
|
|
|
|
|
|
|
|
static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
static const u16 drum_pad_bitmasks[] =
|
2010-04-24 00:44:10 +00:00
|
|
|
{
|
2010-07-09 22:11:12 +00:00
|
|
|
Drums::PAD_RED,
|
|
|
|
Drums::PAD_YELLOW,
|
|
|
|
Drums::PAD_BLUE,
|
|
|
|
Drums::PAD_GREEN,
|
|
|
|
Drums::PAD_ORANGE,
|
|
|
|
Drums::PAD_BASS,
|
2010-04-24 00:44:10 +00:00
|
|
|
};
|
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
static const char* const drum_pad_names[] =
|
2010-04-24 00:44:10 +00:00
|
|
|
{
|
2010-04-24 20:09:01 +00:00
|
|
|
"Red","Yellow","Blue","Green","Orange","Bass"
|
2010-04-24 00:44:10 +00:00
|
|
|
};
|
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
static const u16 drum_button_bitmasks[] =
|
2010-04-24 00:44:10 +00:00
|
|
|
{
|
2010-07-09 22:11:12 +00:00
|
|
|
Drums::BUTTON_MINUS,
|
|
|
|
Drums::BUTTON_PLUS,
|
2010-04-24 00:44:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Drums::Drums() : Attachment( "Drums" )
|
|
|
|
{
|
|
|
|
// pads
|
|
|
|
groups.push_back( m_pads = new Buttons( "Pads" ) );
|
|
|
|
for ( unsigned int i = 0; i < sizeof(drum_pad_names)/sizeof(*drum_pad_names); ++i )
|
|
|
|
m_pads->controls.push_back( new ControlGroup::Input( drum_pad_names[i] ) );
|
|
|
|
|
|
|
|
// stick
|
|
|
|
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
2010-07-10 06:48:24 +00:00
|
|
|
m_buttons->controls.push_back( new ControlGroup::Input("-") );
|
|
|
|
m_buttons->controls.push_back( new ControlGroup::Input("+") );
|
2010-04-24 00:44:10 +00:00
|
|
|
|
|
|
|
// set up register
|
|
|
|
// id
|
|
|
|
memcpy( ®[0xfa], drums_id, sizeof(drums_id) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Drums::GetState(u8* const data, const bool focus)
|
|
|
|
{
|
|
|
|
wm_drums_extension* const ddata = (wm_drums_extension*)data;
|
2010-07-10 06:48:24 +00:00
|
|
|
ddata->bt = 0;
|
2010-04-24 00:44:10 +00:00
|
|
|
|
|
|
|
// calibration data not figured out yet?
|
|
|
|
|
|
|
|
// stick
|
|
|
|
{
|
|
|
|
u8 x, y;
|
|
|
|
m_stick->GetState( &x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0 );
|
|
|
|
|
|
|
|
ddata->sx = x;
|
|
|
|
ddata->sy = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: softness maybe
|
|
|
|
data[2] = 0xFF;
|
|
|
|
data[3] = 0xFF;
|
|
|
|
|
|
|
|
if (focus)
|
|
|
|
{
|
|
|
|
// buttons
|
|
|
|
m_buttons->GetState( &ddata->bt, drum_button_bitmasks );
|
|
|
|
// pads
|
|
|
|
m_pads->GetState( &ddata->bt, drum_pad_bitmasks );
|
|
|
|
}
|
|
|
|
|
|
|
|
// flip button bits
|
|
|
|
ddata->bt ^= 0xFFFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|