fix weird wheel jumps when 2 players scrolling
This commit is contained in:
@@ -829,61 +829,41 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
|
|||||||
|
|
||||||
if( MenuI.button == MENU_BUTTON_RIGHT || MenuI.button == MENU_BUTTON_LEFT )
|
if( MenuI.button == MENU_BUTTON_RIGHT || MenuI.button == MENU_BUTTON_LEFT )
|
||||||
{
|
{
|
||||||
|
|
||||||
/* If we're rouletting, hands off. */
|
/* If we're rouletting, hands off. */
|
||||||
if(m_MusicWheel.IsRouletting())
|
if( m_MusicWheel.IsRouletting() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TRICKY: There's lots of weirdness that can happen here when tapping
|
bool bLeftIsDown = false;
|
||||||
// Left and Right quickly, like when changing sort.
|
bool bRightIsDown = false;
|
||||||
bool bLeftPressed = INPUTMAPPER->IsButtonDown( MenuInput(MenuI.player, MENU_BUTTON_LEFT) );
|
FOREACH_EnabledPlayer( p )
|
||||||
bool bRightPressed = INPUTMAPPER->IsButtonDown( MenuInput(MenuI.player, MENU_BUTTON_RIGHT) );
|
|
||||||
bool bLeftAndRightPressed = bLeftPressed && bRightPressed;
|
|
||||||
bool bLeftOrRightPressed = bLeftPressed || bRightPressed;
|
|
||||||
|
|
||||||
switch( type )
|
|
||||||
{
|
{
|
||||||
case IET_RELEASE:
|
bLeftIsDown |= INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_LEFT) );
|
||||||
// when a key is released, stop moving the wheel
|
bRightIsDown |= INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_RIGHT) );
|
||||||
if( !bLeftOrRightPressed )
|
}
|
||||||
m_MusicWheel.Move( 0 );
|
|
||||||
|
|
||||||
// Reset the repeat timer when a key is released.
|
bool bBothDown = bLeftIsDown && bRightIsDown;
|
||||||
// This fixes jumping when you release Left and Right at the same
|
bool bNeitherDown = !bLeftIsDown && !bRightIsDown;
|
||||||
// time (e.g. after tapping Left+Right to change sort).
|
|
||||||
INPUTMAPPER->ResetKeyRepeat( MenuInput(MenuI.player, MENU_BUTTON_LEFT) );
|
|
||||||
INPUTMAPPER->ResetKeyRepeat( MenuInput(MenuI.player, MENU_BUTTON_RIGHT) );
|
|
||||||
break;
|
|
||||||
case IET_FIRST_PRESS:
|
|
||||||
if( MenuI.button == MENU_BUTTON_RIGHT )
|
|
||||||
m_MusicWheel.Move( +1 );
|
|
||||||
else
|
|
||||||
m_MusicWheel.Move( -1 );
|
|
||||||
|
|
||||||
// The wheel moves faster than one item between FIRST_PRESS
|
if( bBothDown || bNeitherDown )
|
||||||
// and SLOW_REPEAT. Stop the wheel immediately after moving one
|
m_MusicWheel.Move( 0 );
|
||||||
// item if both Left and Right are held. This way, we won't move
|
else if( bLeftIsDown )
|
||||||
// another item
|
m_MusicWheel.Move( -1 );
|
||||||
if( bLeftAndRightPressed )
|
else if( bRightIsDown )
|
||||||
m_MusicWheel.Move( 0 );
|
m_MusicWheel.Move( +1 );
|
||||||
break;
|
else
|
||||||
case IET_SLOW_REPEAT:
|
ASSERT(0);
|
||||||
case IET_FAST_REPEAT:
|
|
||||||
// We need to handle the repeat events to start the wheel spinning again
|
|
||||||
// when Left and Right are being held, then one is released.
|
// Reset the repeat timer when a key is released.
|
||||||
if( bLeftAndRightPressed )
|
// This fixes jumping when you release Left and Right at the same
|
||||||
|
// time (e.g. after tapping Left+Right to change sort).
|
||||||
|
if( type == IET_RELEASE )
|
||||||
|
{
|
||||||
|
FOREACH_EnabledPlayer( p )
|
||||||
{
|
{
|
||||||
// Don't spin if holding both buttons
|
INPUTMAPPER->ResetKeyRepeat( MenuInput(p, MENU_BUTTON_LEFT) );
|
||||||
m_MusicWheel.Move( 0 );
|
INPUTMAPPER->ResetKeyRepeat( MenuInput(p, MENU_BUTTON_RIGHT) );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if( MenuI.button == MENU_BUTTON_RIGHT )
|
|
||||||
m_MusicWheel.Move( +1 );
|
|
||||||
else
|
|
||||||
m_MusicWheel.Move( -1 );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user