2010-04-24 00:44:10 +00:00
|
|
|
#include "Guitar.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace WiimoteEmu
|
|
|
|
{
|
|
|
|
|
|
|
|
static const u8 guitar_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
|
|
|
|
|
|
|
const u16 guitar_fret_bitmasks[] =
|
|
|
|
{
|
2010-07-09 22:11:12 +00:00
|
|
|
Guitar::FRET_GREEN,
|
|
|
|
Guitar::FRET_RED,
|
|
|
|
Guitar::FRET_YELLOW,
|
|
|
|
Guitar::FRET_BLUE,
|
|
|
|
Guitar::FRET_ORANGE,
|
2010-04-24 00:44:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const char* guitar_fret_names[] =
|
|
|
|
{
|
|
|
|
"Green","Red","Yellow","Blue","Orange",
|
|
|
|
};
|
|
|
|
|
|
|
|
const u16 guitar_button_bitmasks[] =
|
|
|
|
{
|
2010-07-09 22:11:12 +00:00
|
|
|
Guitar::BUTTON_MINUS,
|
|
|
|
Guitar::BUTTON_PLUS,
|
2010-04-24 00:44:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const u16 guitar_strum_bitmasks[] =
|
|
|
|
{
|
2010-07-09 22:11:12 +00:00
|
|
|
Guitar::BAR_UP,
|
|
|
|
Guitar::BAR_DOWN,
|
2010-04-24 00:44:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Guitar::Guitar() : Attachment( "Guitar" )
|
|
|
|
{
|
|
|
|
// frets
|
|
|
|
groups.push_back( m_frets = new Buttons( "Frets" ) );
|
|
|
|
for ( unsigned int i = 0; i < sizeof(guitar_fret_names)/sizeof(*guitar_fret_names); ++i )
|
|
|
|
m_frets->controls.push_back( new ControlGroup::Input( guitar_fret_names[i] ) );
|
|
|
|
|
|
|
|
// stick
|
|
|
|
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
|
|
|
|
|
|
|
|
// strum
|
|
|
|
groups.push_back( m_strum = new Buttons( "Strum" ) );
|
|
|
|
m_strum->controls.push_back( new ControlGroup::Input("Up") );
|
|
|
|
m_strum->controls.push_back( new ControlGroup::Input("Down") );
|
|
|
|
|
|
|
|
// whammy
|
|
|
|
groups.push_back( m_whammy = new Triggers( "Whammy" ) );
|
|
|
|
m_whammy->controls.push_back( new ControlGroup::Input("Bar") );
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
|
|
|
m_buttons->controls.push_back( new ControlGroup::Input("Minus") );
|
|
|
|
m_buttons->controls.push_back( new ControlGroup::Input("Plus") );
|
|
|
|
|
|
|
|
// set up register
|
|
|
|
// id
|
|
|
|
memcpy( ®[0xfa], guitar_id, sizeof(guitar_id) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Guitar::GetState(u8* const data, const bool focus)
|
|
|
|
{
|
|
|
|
wm_guitar_extension* const gdata = (wm_guitar_extension*)data;
|
|
|
|
|
|
|
|
// calibration data not figured out yet?
|
|
|
|
|
|
|
|
// stick
|
|
|
|
{
|
|
|
|
u8 x, y;
|
|
|
|
m_stick->GetState( &x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0 );
|
|
|
|
|
|
|
|
gdata->sx = x;
|
|
|
|
gdata->sy = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: touch bar, probably not
|
|
|
|
gdata->tb = 0x0F; // not touched
|
|
|
|
|
|
|
|
// whammy bar
|
|
|
|
u8 whammy;
|
|
|
|
m_whammy->GetState( &whammy, 0x1F );
|
|
|
|
gdata->whammy = whammy;
|
|
|
|
|
|
|
|
if (focus)
|
|
|
|
{
|
|
|
|
// buttons
|
|
|
|
m_buttons->GetState( &gdata->bt, guitar_button_bitmasks );
|
|
|
|
// frets
|
|
|
|
m_frets->GetState( &gdata->bt, guitar_fret_bitmasks );
|
|
|
|
// strum
|
|
|
|
m_strum->GetState( &gdata->bt, guitar_strum_bitmasks );
|
|
|
|
}
|
|
|
|
|
|
|
|
// flip button bits
|
|
|
|
gdata->bt ^= 0xFFFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|