mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
New GCPad/Wiimote: Hopefully fixed lock up issues with DirectInput devices. Wiimote tilt should work with keyboard keys/gamepad buttons now as well as IR Forward/Backward(which was added). Made input detection buttons display "[ waiting ]" while waiting for input. minor fixes/cleanups.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5651 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -384,29 +384,41 @@ void GamepadPage::ClearControl( wxCommandEvent& event )
|
||||
|
||||
void ControlDialog::DetectControl( wxCommandEvent& event )
|
||||
{
|
||||
wxButton* const btn = (wxButton*)event.GetEventObject();
|
||||
|
||||
// some hacks
|
||||
wxChar num = ((wxButton*)event.GetEventObject())->GetLabel()[0];
|
||||
if ( num > '9' )
|
||||
const wxString lbl = btn->GetLabel();
|
||||
wxChar num = lbl[0];
|
||||
if (num > '9')
|
||||
{
|
||||
num = 1;
|
||||
btn->SetLabel(wxT("[ waiting ]"));
|
||||
}
|
||||
else
|
||||
{
|
||||
num -= 0x30;
|
||||
btn->SetLabel(wxT("w"));
|
||||
}
|
||||
|
||||
g_plugin->controls_crit.Enter(); // enter
|
||||
if ( control_reference->Detect( DETECT_WAIT_TIME, num ) ) // if we got input, update gui
|
||||
if ( control_reference->Detect( DETECT_WAIT_TIME + (num - 1) * 500, num ) ) // if we got input, update gui
|
||||
control_chooser->UpdateListSelection();
|
||||
g_plugin->controls_crit.Leave(); // leave
|
||||
|
||||
btn->SetLabel(lbl);
|
||||
}
|
||||
|
||||
void GamepadPage::DetectControl( wxCommandEvent& event )
|
||||
{
|
||||
ControlButton* btn = (ControlButton*)event.GetEventObject();
|
||||
|
||||
btn->SetLabel(wxT("[ waiting ]"));
|
||||
|
||||
g_plugin->controls_crit.Enter(); // enter
|
||||
|
||||
btn->control_reference->Detect( DETECT_WAIT_TIME );
|
||||
btn->SetLabel( wxString::FromAscii( btn->control_reference->control_qualifier.name.c_str() ) );
|
||||
|
||||
g_plugin->controls_crit.Leave(); // leave
|
||||
|
||||
btn->SetLabel(wxString::FromAscii(btn->control_reference->control_qualifier.name.c_str()));
|
||||
}
|
||||
|
||||
void ControlDialog::SelectControl( wxCommandEvent& event )
|
||||
|
@ -72,11 +72,19 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
// draw the shit
|
||||
|
||||
// ir cursor forward movement
|
||||
if (z)
|
||||
if (GROUP_TYPE_CURSOR == (*g)->control_group->type)
|
||||
{
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
dc.DrawRectangle( 0, 64 - z*64, 64, 2);
|
||||
if (z)
|
||||
{
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
}
|
||||
dc.DrawRectangle( 0, 31 - z*31, 64, 2);
|
||||
}
|
||||
|
||||
// circle for visual aid for diagonal adjustment
|
||||
@ -95,19 +103,18 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
// deadzone circle
|
||||
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
dc.DrawCircle( 32, 32, ((*g)->control_group)->settings[0]->value * 32 );
|
||||
|
||||
// raw dot
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
// i like the dot better than the cross i think
|
||||
dc.DrawRectangle( xx - 2, yy - 2, 4, 4 );
|
||||
//dc.DrawRectangle( xx-1, 64-yy-4, 2, 8 );
|
||||
//dc.DrawRectangle( xx-4, 64-yy-1, 8, 2 );
|
||||
|
||||
}
|
||||
|
||||
// raw dot
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
// i like the dot better than the cross i think
|
||||
dc.DrawRectangle( xx - 2, yy - 2, 4, 4 );
|
||||
//dc.DrawRectangle( xx-1, 64-yy-4, 2, 8 );
|
||||
//dc.DrawRectangle( xx-4, 64-yy-1, 8, 2 );
|
||||
|
||||
// adjusted dot
|
||||
if ( x!=32 || y!=32 )
|
||||
if (x!=32 || y!=32)
|
||||
{
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
@ -223,9 +230,16 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
{
|
||||
ControlState trig_r = (*g)->control_group->controls[n]->control_ref->State();
|
||||
|
||||
// outline
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.DrawRectangle(0, n*12, 64, 14);
|
||||
|
||||
// raw
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
dc.DrawRectangle(0, n*12, trig_r*64, 14);
|
||||
|
||||
// deadzone affected
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
dc.DrawRectangle(0, n*12, trigs[n], 14);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ ControllerEmu::MixedTriggers::MixedTriggers( const char* const _name ) : Control
|
||||
|
||||
ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TRIGGERS )
|
||||
{
|
||||
settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
|
||||
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
|
||||
}
|
||||
|
||||
ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
|
||||
@ -272,8 +272,11 @@ ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GR
|
||||
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
|
||||
}
|
||||
|
||||
ControllerEmu::Tilt::Tilt( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TILT )
|
||||
ControllerEmu::Tilt::Tilt( const char* const _name )
|
||||
: ControlGroup( _name, GROUP_TYPE_TILT )
|
||||
{
|
||||
memset(m_tilt, 0, sizeof(m_tilt));
|
||||
|
||||
//for ( unsigned int i = 0; i < 4; ++i )
|
||||
//controls.push_back( new Input( named_directions[i] ) );
|
||||
controls.push_back( new Input( "Forward" ) );
|
||||
@ -289,12 +292,13 @@ ControllerEmu::Tilt::Tilt( const char* const _name ) : ControlGroup( _name, GROU
|
||||
|
||||
ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize )
|
||||
: ControlGroup( _name, GROUP_TYPE_CURSOR )
|
||||
//, z(0)
|
||||
, wiimote_initialize(_wiimote_initialize)
|
||||
, m_z(0)
|
||||
{
|
||||
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( "Backward" ) );
|
||||
controls.push_back( new Input( "Hide" ) );
|
||||
|
||||
settings.push_back( new Setting("Center", 0.5f ) );
|
||||
|
@ -307,9 +307,23 @@ public:
|
||||
xx = std::max( -1.0f, std::min( 1.0f, ang_cos * dist ) );
|
||||
}
|
||||
|
||||
*y = C( yy * range + base );
|
||||
*x = C( xx * range + base );
|
||||
// this is kinda silly here
|
||||
// gui being open will make this happen 2x as fast, o well
|
||||
if (xx > m_tilt[0])
|
||||
m_tilt[0] = std::min(m_tilt[0] + 0.1f, xx);
|
||||
else if (xx < m_tilt[0])
|
||||
m_tilt[0] = std::max(m_tilt[0] - 0.1f, xx);
|
||||
|
||||
if (yy > m_tilt[1])
|
||||
m_tilt[1] = std::min(m_tilt[1] + 0.1f, yy);
|
||||
else if (yy < m_tilt[1])
|
||||
m_tilt[1] = std::max(m_tilt[1] - 0.1f, yy);
|
||||
|
||||
*y = C( m_tilt[1] * range + base );
|
||||
*x = C( m_tilt[0] * range + base );
|
||||
}
|
||||
private:
|
||||
float m_tilt[2];
|
||||
};
|
||||
|
||||
class Cursor : public ControlGroup
|
||||
@ -318,18 +332,25 @@ public:
|
||||
Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize );
|
||||
|
||||
template <typename C>
|
||||
void GetState( C* const x, C* const y, C* const forward, const bool adjusted = false )
|
||||
void GetState( C* const x, C* const y, C* const z, const bool adjusted = false )
|
||||
{
|
||||
const ControlState z = controls[4]->control_ref->State();
|
||||
const float zz = controls[4]->control_ref->State() - controls[5]->control_ref->State();
|
||||
|
||||
// silly being here
|
||||
if (zz > m_z)
|
||||
m_z = std::min(m_z + 0.1f, zz);
|
||||
else if (zz < m_z)
|
||||
m_z = std::max(m_z - 0.1f, zz);
|
||||
|
||||
*z = m_z;
|
||||
|
||||
// hide
|
||||
if (controls[5]->control_ref->State() > 0.5f)
|
||||
if (controls[6]->control_ref->State() > 0.5f)
|
||||
{
|
||||
*x = 10000; *y = 0; *forward = 0;
|
||||
*x = 10000; *y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*forward = z;
|
||||
float xx, yy;
|
||||
GetMousePos(xx, yy, wiimote_initialize);
|
||||
|
||||
@ -359,6 +380,7 @@ public:
|
||||
private:
|
||||
const SWiimoteInitialize* const wiimote_initialize;
|
||||
|
||||
float m_z;
|
||||
};
|
||||
|
||||
class Extension : public ControlGroup
|
||||
|
@ -498,7 +498,7 @@ void Wiimote::Update()
|
||||
yy *= (-256 * 0.90f);
|
||||
yy += 490;
|
||||
|
||||
const unsigned int distance = (unsigned int)(100 + 100 * zz);
|
||||
const unsigned int distance = (unsigned int)(200 + 100 * zz);
|
||||
|
||||
// TODO: make roll affect the dot positions
|
||||
const unsigned int y = (unsigned int)yy;
|
||||
@ -509,13 +509,13 @@ void Wiimote::Update()
|
||||
x[2] = (unsigned int)(xx - 1.2f * distance);
|
||||
x[3] = (unsigned int)(xx + 1.2f * distance);
|
||||
|
||||
//0xFF report
|
||||
// 0xFF report / these memsets are silly
|
||||
if (rpt.ext)
|
||||
memset(data + rpt.ir, 0xFF, (rpt.ext - rpt.ir));
|
||||
else
|
||||
memset(data + rpt.ir, 0xFF, (46 - rpt.ir));
|
||||
|
||||
//Fill report with valid data when full handshake was done
|
||||
// Fill report with valid data when full handshake was done
|
||||
if (m_reg_ir->data[0x30] || m_reg_ir->data[0x33])
|
||||
// ir mode
|
||||
switch (m_reg_ir->mode)
|
||||
|
Reference in New Issue
Block a user