WiimoteNew: Added button mappings for tables and crossfade slider on emulated turntable extension.(completely untested in game)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6260 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-10-05 21:43:51 +00:00
parent 0830e74d55
commit bfd04e380e
7 changed files with 87 additions and 34 deletions

View File

@ -259,6 +259,14 @@ ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _na
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) ); settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
} }
ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
{
controls.push_back(new Input("Left"));
controls.push_back(new Input("Right"));
settings.push_back(new Setting("Dead Zone", 0, 0, 50));
}
ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE ) ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
{ {
memset(m_swing, 0, sizeof(m_swing)); memset(m_swing, 0, sizeof(m_swing));

View File

@ -45,7 +45,8 @@ enum
GROUP_TYPE_TILT, GROUP_TYPE_TILT,
GROUP_TYPE_CURSOR, GROUP_TYPE_CURSOR,
GROUP_TYPE_TRIGGERS, GROUP_TYPE_TRIGGERS,
GROUP_TYPE_UDPWII GROUP_TYPE_UDPWII,
GROUP_TYPE_SLIDER,
}; };
const char * const named_directions[] = const char * const named_directions[] =
@ -247,6 +248,26 @@ public:
}; };
class Slider : public ControlGroup
{
public:
template <typename S>
void GetState(S* const slider, const unsigned int range, const unsigned int base = 0)
{
const float deadzone = settings[0]->value;
const float state = controls[1]->control_ref->State() - controls[0]->control_ref->State();
if (fabsf(state) > deadzone)
*slider = (S)((state - (deadzone * sign(state))) / (1 - deadzone) * range + base);
else
*slider = 0;
}
Slider(const char* const _name);
};
class Force : public ControlGroup class Force : public ControlGroup
{ {
public: public:

View File

@ -788,14 +788,17 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
break; break;
case GROUP_TYPE_MIXED_TRIGGERS: case GROUP_TYPE_MIXED_TRIGGERS:
case GROUP_TYPE_TRIGGERS: case GROUP_TYPE_TRIGGERS:
case GROUP_TYPE_SLIDER:
{ {
int height = (int)(6 * group->controls.size()); int height = (int)(12 * group->controls.size());
int width = 64+12+1; int width = 64;
if (GROUP_TYPE_TRIGGERS == group->type)
{ if (GROUP_TYPE_MIXED_TRIGGERS == group->type)
height *= 2; width = 64+12+1;
width = 64;
} if (GROUP_TYPE_TRIGGERS != group->type)
height /= 2;
wxBitmap bitmap(width, height+1); wxBitmap bitmap(width, height+1);
dc.SelectObject(bitmap); dc.SelectObject(bitmap);
dc.Clear(); dc.Clear();
@ -867,19 +870,24 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
ControlGroupsSizer::ControlGroupsSizer( ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* groups ) ControlGroupsSizer::ControlGroupsSizer( ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* groups )
: wxBoxSizer( wxHORIZONTAL ) : wxBoxSizer( wxHORIZONTAL )
{ {
size_t col_size = 0;
wxBoxSizer* stacked_groups = NULL; wxBoxSizer* stacked_groups = NULL;
for ( unsigned int i = 0; i < controller->groups.size(); ++i ) for ( unsigned int i = 0; i < controller->groups.size(); ++i )
{ {
ControlGroupBox* control_group = new ControlGroupBox( controller->groups[i], parent, eventsink ); ControlGroupBox* control_group = new ControlGroupBox( controller->groups[i], parent, eventsink );
if ( control_group->control_buttons.size() > 1 ) const size_t grp_size = controller->groups[i]->controls.size() + controller->groups[i]->settings.size();
col_size += grp_size;
if (col_size > 8 || NULL == stacked_groups)
{ {
if ( stacked_groups ) if ( stacked_groups )
Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 ); Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 );
stacked_groups = new wxBoxSizer( wxVERTICAL ); stacked_groups = new wxBoxSizer( wxVERTICAL );
stacked_groups->Add( control_group, 0, wxEXPAND ); stacked_groups->Add( control_group, 0, wxEXPAND );
col_size = grp_size;
} }
else else
stacked_groups->Add( control_group, 0, wxEXPAND ); stacked_groups->Add( control_group, 0, wxEXPAND );
@ -890,7 +898,6 @@ ControlGroupsSizer::ControlGroupsSizer( ControllerEmu* const controller, wxWindo
if ( stacked_groups ) if ( stacked_groups )
Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 ); Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 );
} }
GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog ) GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog )

View File

@ -308,6 +308,29 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
} }
break; break;
case GROUP_TYPE_SLIDER:
{
const ControlState deadzone = (*g)->control_group->settings[0]->value;
ControlState state = (*g)->control_group->controls[1]->control_ref->State() - (*g)->control_group->controls[0]->control_ref->State();
dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH);
dc.DrawRectangle(31 + state * 30, 0, 2, 14);
((ControllerEmu::Slider*)(*g)->control_group)->GetState(&state, 1);
if (state)
{
dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxRED_BRUSH);
dc.DrawRectangle(31 + state * 30, 0, 2, 14);
}
// deadzone box
dc.SetPen(*wxLIGHT_GREY_PEN);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(32 - deadzone * 32, 0, deadzone * 64, 14);
}
break;
default : default :
break; break;
} }

View File

@ -39,23 +39,23 @@ Guitar::Guitar() : Attachment( "Guitar" )
for ( unsigned int i = 0; i < sizeof(guitar_fret_names)/sizeof(*guitar_fret_names); ++i ) 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] ) ); m_frets->controls.push_back( new ControlGroup::Input( guitar_fret_names[i] ) );
// stick
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
// strum // strum
groups.push_back( m_strum = new Buttons( "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("Up") );
m_strum->controls.push_back( new ControlGroup::Input("Down") ); 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 // buttons
groups.push_back( m_buttons = new Buttons( "Buttons" ) ); groups.push_back( m_buttons = new Buttons( "Buttons" ) );
m_buttons->controls.push_back( new ControlGroup::Input("-") ); m_buttons->controls.push_back( new ControlGroup::Input("-") );
m_buttons->controls.push_back( new ControlGroup::Input("+") ); m_buttons->controls.push_back( new ControlGroup::Input("+") );
// stick
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
// whammy
groups.push_back( m_whammy = new Triggers( "Whammy" ) );
m_whammy->controls.push_back( new ControlGroup::Input("Bar") );
// set up register // set up register
// id // id
memcpy( &reg[0xfa], guitar_id, sizeof(guitar_id) ); memcpy( &reg[0xfa], guitar_id, sizeof(guitar_id) );

View File

@ -29,21 +29,23 @@ static const char* const turntable_button_names[] =
Turntable::Turntable() : Attachment("Turntable") Turntable::Turntable() : Attachment("Turntable")
{ {
// buttons // buttons
// TODO: separate buttons into Left and Right
groups.push_back(m_buttons = new Buttons("Buttons")); groups.push_back(m_buttons = new Buttons("Buttons"));
for (unsigned int i = 0; i < sizeof(turntable_button_names)/sizeof(*turntable_button_names); ++i) for (unsigned int i = 0; i < sizeof(turntable_button_names)/sizeof(*turntable_button_names); ++i)
m_buttons->controls.push_back(new ControlGroup::Input( turntable_button_names[i])); m_buttons->controls.push_back(new ControlGroup::Input( turntable_button_names[i]));
// turntables
groups.push_back(m_left_table = new Slider("Table Left"));
groups.push_back(m_right_table = new Slider("Table Right"));
// stick // stick
groups.push_back(m_stick = new AnalogStick("Stick")); groups.push_back(m_stick = new AnalogStick("Stick"));
// TODO: // effect dial
groups.push_back(m_effect_dial = new Triggers("Effect")); groups.push_back(m_effect_dial = new Triggers("Effect"));
m_effect_dial->controls.push_back(new ControlGroup::Input("Dial")); m_effect_dial->controls.push_back(new ControlGroup::Input("Dial"));
//m_left_turntable // crossfade
//m_right_turntable groups.push_back(m_crossfade = new Slider("Crossfade"));
//m_crossfade_slider
// set up register // set up register
// id // id
@ -65,20 +67,18 @@ void Turntable::GetState(u8* const data, const bool focus)
} }
// left table // left table
// TODO:
{ {
s8 tt = 0; s8 tt = 0;
//m_left_turntable->GetState(&tt .....); m_left_table->GetState(&tt, focus ? 0x1F : 0);
ttdata->ltable1 = tt; ttdata->ltable1 = tt;
ttdata->ltable2 = tt << 5; ttdata->ltable2 = tt << 5;
} }
// right table // right table
// TODO:
{ {
s8 tt = 0; s8 tt = 0;
//m_right_turntable->GetState(&tt .....); m_right_table->GetState(&tt, focus ? 0x1F : 0);
ttdata->rtable1 = tt; ttdata->rtable1 = tt;
ttdata->rtable2 = tt << 1; ttdata->rtable2 = tt << 1;
@ -96,10 +96,9 @@ void Turntable::GetState(u8* const data, const bool focus)
} }
// crossfade slider // crossfade slider
// TODO:
{ {
u8 cfs = 0; u8 cfs = 0;
//m_crossfade_slider->GetState(&cfs .....); m_crossfade->GetState(&cfs, 8, 7);
ttdata->slider = cfs; ttdata->slider = cfs;
} }

View File

@ -29,13 +29,8 @@ private:
Buttons* m_buttons; Buttons* m_buttons;
MixedTriggers* m_triggers; MixedTriggers* m_triggers;
AnalogStick* m_stick; AnalogStick* m_stick;
Triggers *m_effect_dial; Triggers *m_effect_dial;
Slider *m_left_table, *m_right_table, *m_crossfade;
// TODO:
//m_left_turntable
//m_right_turntable
//m_crossfade_slider
}; };