New Wiimote Plugin: Added "Upright Wiimote" option. Fixed a nunchuk problem in ZTP and Wii Sports with some Hacks. Some work on emulated Swing and Speaker (disabled). Fixes/Cleanups. ControllerInterface: Fixed an issue when a DInput device reports the same axis more than once. Fixed some old comments.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5422 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2010-04-29 18:51:04 +00:00
parent 81f06220ce
commit 22c2276cef
17 changed files with 579 additions and 290 deletions

View File

@ -19,9 +19,9 @@ void GamepadPage::ConfigExtension( wxCommandEvent& event )
const std::size_t orig_size = control_groups.size();
ControlGroupsSizer* const szr = new ControlGroupsSizer( ex->attachments[ex->switch_extension], pnl, this, &control_groups );
pnl->SetSizerAndFit( szr );
pnl->SetSizerAndFit( szr ); // needed
pnl_szr->Add( pnl, 0, wxLEFT, 5 );
dlg->SetSizerAndFit( pnl_szr );
dlg->SetSizerAndFit( pnl_szr ); // needed
dlg->Center();
@ -131,7 +131,7 @@ ControlDialog::ControlDialog( wxWindow* const parent, ControllerInterface::Contr
szr->Add( d_szr, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
szr->Add( control_chooser, 0, wxEXPAND|wxALL, 5 );
SetSizerAndFit( szr );
SetSizerAndFit( szr ); // needed
}
@ -661,6 +661,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
case GROUP_TYPE_STICK :
case GROUP_TYPE_TILT :
case GROUP_TYPE_CURSOR :
case GROUP_TYPE_FORCE :
{
wxBitmap bitmap(64, 64);
wxMemoryDC dc;
@ -871,7 +872,7 @@ GamepadPage::GamepadPage( wxWindow* parent, const unsigned int pad_num, ConfigDi
UpdateGUI();
SetSizerAndFit( mapping );
SetSizerAndFit( mapping ); // needed
Layout();
};
@ -911,7 +912,8 @@ ConfigDialog::ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::s
szr->Add( m_pad_notebook, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
szr->Add( btns, 0, wxEXPAND|wxALL, 5 );
SetSizerAndFit( szr );
SetSizerAndFit( szr ); // needed
// not needed here it seems, but it cant hurt
//Layout();

View File

@ -10,7 +10,7 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
ge = current_page->control_groups.end();
for ( ; g != ge; ++g )
{
// if this control group has a bitmap
if ( (*g)->static_bitmap )
{
@ -22,6 +22,20 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
// just always update
m_plugin.controller_interface.UpdateInput();
wxMemoryDC dc;
wxBitmap bitmap((*g)->static_bitmap->GetBitmap());
dc.SelectObject(bitmap);
dc.Clear();
// label for sticks and stuff
if (64 == bitmap.GetHeight())
{
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
dc.SetFont(small_font);
dc.SetTextForeground(0xC0C0C0);
dc.DrawText(wxString::FromAscii((*g)->control_group->name).Upper(), 4, 2);
}
switch ( (*g)->control_group->type )
{
case GROUP_TYPE_TILT :
@ -55,12 +69,6 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
xx *= 32 - 1; xx += 32;
yy *= 32 - 1; yy += 32;
// setup
wxBitmap bitmap(64, 64);
wxMemoryDC dc;
dc.SelectObject(bitmap);
dc.Clear();
// draw the shit
// ir cursor forward movement
@ -75,7 +83,10 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.SetPen(*wxLIGHT_GREY_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
if ( GROUP_TYPE_STICK == (*g)->control_group->type )
{
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawCircle( 32, 32, 32);
}
else
dc.DrawRectangle( 16, 16, 32, 32 );
@ -106,27 +117,70 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
//dc.DrawRectangle( x-4, 64-y-1, 8, 2 );
}
// box outline
// Windows XP color
dc.SetPen(wxPen(_T("#7f9db9")));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(0, 0, 64, 64);
}
break;
case GROUP_TYPE_FORCE :
{
float raw_dot[3];
float adj_dot[3];
const float deadzone = 32 * ((*g)->control_group)->settings[0]->value;
// done drawing
dc.SelectObject(wxNullBitmap);
// adjusted
((ControllerEmu::Force*)(*g)->control_group)->GetState( adj_dot, 32.0, 32-1.5 );
// raw
for ( unsigned int i=0; i<3; ++i )
{
raw_dot[i] = (*g)->control_group->controls[i*2 + 1]->control_ref->State()
- (*g)->control_group->controls[i*2]->control_ref->State();
raw_dot[i] *= 32 - 1; raw_dot[i] += 32;
}
// deadzone rect for forward/backward visual
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.SetPen(*wxLIGHT_GREY_PEN);
dc.DrawRectangle( 0, 32 - deadzone, 64, deadzone * 2 );
// raw forward/background line
dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH);
dc.DrawRectangle( 0, raw_dot[2] - 1, 64, 2 );
// adjusted forward/background line
if ( adj_dot[2]!=32 )
{
dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxRED_BRUSH);
dc.DrawRectangle( 0, adj_dot[2] - 1, 64, 2 );
}
// a rectangle, for looks i guess
dc.SetBrush(*wxWHITE_BRUSH);
dc.SetPen(*wxLIGHT_GREY_PEN);
dc.DrawRectangle( 16, 16, 32, 32 );
// deadzone square
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.DrawRectangle( 32 - deadzone, 32 - deadzone, deadzone * 2, deadzone * 2 );
// raw dot
dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH);
dc.DrawRectangle( raw_dot[1] - 2, raw_dot[0] - 2, 4, 4 );
// adjusted dot
if ( adj_dot[1]!=32 || adj_dot[0]!=32 )
{
dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxRED_BRUSH);
dc.DrawRectangle( adj_dot[1]-2, adj_dot[0]-2, 4, 4 );
}
// set the shit
(*g)->static_bitmap->SetBitmap( bitmap );
}
break;
case GROUP_TYPE_BUTTONS :
{
const unsigned int button_count = ((unsigned int)(*g)->control_group->controls.size());
// setup
wxBitmap bitmap(12*button_count+1, 12);
wxMemoryDC dc;
dc.SelectObject(bitmap);
dc.Clear();
// draw the shit
dc.SetPen(*wxGREY_PEN);
@ -140,7 +194,6 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
for ( unsigned int n = 0; n<button_count; ++n )
{
// TODO: threshold stuff, actually redo this crap with the GetState func
if ( buttons & bitmasks[n] )
dc.SetBrush( *wxRED_BRUSH );
else
@ -152,28 +205,12 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
}
delete bitmasks;
// box outline
// Windows XP color
dc.SetPen(wxPen(_T("#7f9db9")));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
// done drawing
dc.SelectObject(wxNullBitmap);
// set the shit
(*g)->static_bitmap->SetBitmap( bitmap );
}
break;
case GROUP_TYPE_TRIGGERS :
{
const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size()));
// setup
wxBitmap bitmap( 64, 12*trigger_count+1);
wxMemoryDC dc;
dc.SelectObject(bitmap);
dc.Clear();
// draw the shit
dc.SetPen(*wxGREY_PEN);
@ -200,26 +237,11 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);
// box outline
// Windows XP color
dc.SetPen(wxPen(_T("#7f9db9")));
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
// done drawing
dc.SelectObject(wxNullBitmap);
// set the shit
(*g)->static_bitmap->SetBitmap( bitmap );
}
break;
case GROUP_TYPE_MIXED_TRIGGERS :
{
const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size() / 2));
// setup
wxBitmap bitmap( 64+12+1, 12*trigger_count+1);
wxMemoryDC dc;
dc.SelectObject(bitmap);
dc.Clear();
// draw the shit
dc.SetPen(*wxGREY_PEN);
@ -245,22 +267,21 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);
// box outline
// Windows XP color
dc.SetPen(wxPen(_T("#7f9db9")));
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
// done drawing
dc.SelectObject(wxNullBitmap);
// set the shit
(*g)->static_bitmap->SetBitmap( bitmap );
}
break;
default :
break;
}
// box outline
// Windows XP color
dc.SetPen(wxPen(_T("#7f9db9")));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
dc.SelectObject(wxNullBitmap);
(*g)->static_bitmap->SetBitmap(bitmap);
m_plugin.interface_crit.Leave();
}
}

View File

@ -251,18 +251,15 @@ ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _na
ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
{
controls.push_back( new Input( "X-" ) );
controls.push_back( new Input( "X+" ) );
controls.push_back( new Input( "Y-" ) );
controls.push_back( new Input( "Y+" ) );
controls.push_back( new Input( "Z-" ) );
controls.push_back( new Input( "Z+" ) );
}
controls.push_back( new Input( "Up" ) );
controls.push_back( new Input( "Down" ) );
controls.push_back( new Input( "Left" ) );
controls.push_back( new Input( "Right" ) );
controls.push_back( new Input( "Forward" ) );
controls.push_back( new Input( "Backward" ) );
controls.push_back( new Input( "Modifier" ) );
void ControllerEmu::Force::GetState( u8* data, const u8 base, const u8 range )
{
for ( unsigned int i=0; i<3; ++i,++data )
*data = u8( ( controls[i*2+1]->control_ref->State() - controls[i*2]->control_ref->State() ) * range + base );
settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
}
ControllerEmu::Tilt::Tilt( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TILT )
@ -287,10 +284,12 @@ ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize
{
for ( unsigned int i = 0; i < 4; ++i )
controls.push_back( new Input( named_directions[i] ) );
controls.push_back( new Input( "Forward" ) );
controls.push_back( new Input( "Hide" ) );
settings.push_back( new Setting("Center", 0.5f ) );
settings.push_back( new Setting("Width", 0.5f ) );
settings.push_back( new Setting("Height", 0.5f ) );
settings.push_back( new Setting("Top", 0.5f ) );
}

View File

@ -237,7 +237,20 @@ public:
public:
Force( const char* const _name );
void GetState( u8* data, const u8 base, const u8 range );
template <typename C, typename R>
void GetState( C* axis, const u8 base, const R range )
{
const float deadzone = settings[0]->value;
for ( unsigned int i=0; i<6; i+=2 )
{
const float state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
if (abs(state) > deadzone)
*axis++ = (C)((state - (deadzone * sign(state))) / (1 - deadzone) * range + base);
//*axis++ = state * range + base;
else
*axis++ = (C)(base);
}
}
};
class Tilt : public ControlGroup
@ -333,9 +346,9 @@ public:
// adjust cursor according to settings
if (adjusted)
{
xx *= ( settings[0]->value * 2 );
yy *= ( settings[1]->value * 2 );
yy += ( settings[2]->value - 0.5f );
xx *= ( settings[1]->value * 2 );
yy *= ( settings[2]->value * 2 );
yy += ( settings[0]->value - 0.5f );
}
*x = xx;