Fix music wheel weirdness:
tap Left + tap Right would sometimes jump 2 songs in one direction wheel stuck spinning if button release while wheel is flying_off_before_sort or flying_off_after_sort
This commit is contained in:
@@ -1418,8 +1418,18 @@ void MusicWheel::Move(int n)
|
|||||||
|
|
||||||
/* If we're not selecting, discard this. We won't ignore it; we'll
|
/* If we're not selecting, discard this. We won't ignore it; we'll
|
||||||
* get called again every time the key is repeated. */
|
* get called again every time the key is repeated. */
|
||||||
if( m_WheelState != STATE_SELECTING_MUSIC )
|
/* Still process Move(0) so we sometimes continue moving immediate
|
||||||
return;
|
* after the sort change finished and before the repeat event causes a
|
||||||
|
* Move(0). -Chris */
|
||||||
|
switch( m_WheelState )
|
||||||
|
{
|
||||||
|
case STATE_SELECTING_MUSIC:
|
||||||
|
case STATE_FLYING_OFF_BEFORE_NEXT_SORT:
|
||||||
|
case STATE_FLYING_ON_AFTER_NEXT_SORT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return; // don't continue
|
||||||
|
}
|
||||||
|
|
||||||
if(m_Moving != 0 && n == 0 && m_TimeBeforeMovingBegins == 0)
|
if(m_Moving != 0 && n == 0 && m_TimeBeforeMovingBegins == 0)
|
||||||
{
|
{
|
||||||
@@ -1438,9 +1448,6 @@ void MusicWheel::Move(int n)
|
|||||||
m_SpinSpeed = float(PREFSMAN->m_iMusicWheelSwitchSpeed);
|
m_SpinSpeed = float(PREFSMAN->m_iMusicWheelSwitchSpeed);
|
||||||
m_Moving = n;
|
m_Moving = n;
|
||||||
|
|
||||||
if( fabsf(m_fPositionOffsetFromSelection) > 0.5f ) // wheel is very busy spinning
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(m_Moving)
|
if(m_Moving)
|
||||||
ChangeMusic(m_Moving);
|
ChangeMusic(m_Moving);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -638,6 +638,7 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
|
|||||||
{
|
{
|
||||||
// LOG->Trace( "ScreenSelectMusic::Input()" );
|
// LOG->Trace( "ScreenSelectMusic::Input()" );
|
||||||
|
|
||||||
|
|
||||||
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_F9 )
|
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_F9 )
|
||||||
{
|
{
|
||||||
if( type != IET_FIRST_PRESS ) return;
|
if( type != IET_FIRST_PRESS ) return;
|
||||||
@@ -649,22 +650,66 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( MenuI.button == MENU_BUTTON_RIGHT || MenuI.button == MENU_BUTTON_LEFT )
|
if( MenuI.button == MENU_BUTTON_RIGHT || MenuI.button == MENU_BUTTON_LEFT )
|
||||||
{
|
{
|
||||||
if( !MenuI.IsValid() ) return;
|
|
||||||
if( !GAMESTATE->IsHumanPlayer(MenuI.player) ) return;
|
if( !GAMESTATE->IsHumanPlayer(MenuI.player) ) return;
|
||||||
|
|
||||||
/* If we're rouletting, hands off. */
|
/* If we're rouletting, hands off. */
|
||||||
if(m_MusicWheel.IsRouletting())
|
if(m_MusicWheel.IsRouletting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int dir = 0;
|
// TRICKY: There's lots of weirdness that can happen here when tapping
|
||||||
if(INPUTMAPPER->IsButtonDown( MenuInput(MenuI.player, MENU_BUTTON_RIGHT) ) )
|
// Left and Right quickly, like when changing sort.
|
||||||
dir++;
|
bool bLeftPressed = INPUTMAPPER->IsButtonDown( MenuInput(MenuI.player, MENU_BUTTON_LEFT) );
|
||||||
if(INPUTMAPPER->IsButtonDown( MenuInput(MenuI.player, MENU_BUTTON_LEFT) ) )
|
bool bRightPressed = INPUTMAPPER->IsButtonDown( MenuInput(MenuI.player, MENU_BUTTON_RIGHT) );
|
||||||
dir--;
|
bool bLeftAndRightPressed = bLeftPressed && bRightPressed;
|
||||||
|
bool bLeftOrRightPressed = bLeftPressed || bRightPressed;
|
||||||
|
|
||||||
m_MusicWheel.Move(dir);
|
switch( type )
|
||||||
|
{
|
||||||
|
case IET_RELEASE:
|
||||||
|
// when a key is released, stop moving the wheel
|
||||||
|
if( !bLeftOrRightPressed )
|
||||||
|
m_MusicWheel.Move( 0 );
|
||||||
|
|
||||||
|
// Reset the repeat timer when a key is released.
|
||||||
|
// This fixes jumping when you release Left and Right at the same
|
||||||
|
// 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
|
||||||
|
// and SLOW_REPEAT. Stop the wheel immediately after moving one
|
||||||
|
// item if both Left and Right are held. This way, we won't move
|
||||||
|
// another item
|
||||||
|
if( bLeftAndRightPressed )
|
||||||
|
m_MusicWheel.Move( 0 );
|
||||||
|
break;
|
||||||
|
case IET_SLOW_REPEAT:
|
||||||
|
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.
|
||||||
|
if( bLeftAndRightPressed )
|
||||||
|
{
|
||||||
|
// Don't spin if holding both buttons
|
||||||
|
m_MusicWheel.Move( 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( MenuI.button == MENU_BUTTON_RIGHT )
|
||||||
|
m_MusicWheel.Move( +1 );
|
||||||
|
else
|
||||||
|
m_MusicWheel.Move( -1 );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( type == IET_RELEASE ) return; // don't care
|
if( type == IET_RELEASE ) return; // don't care
|
||||||
@@ -693,6 +738,10 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
|
|||||||
|
|
||||||
PlayerNumber pn = GAMESTATE->GetCurrentStyleDef()->ControllerToPlayerNumber( GameI.controller );
|
PlayerNumber pn = GAMESTATE->GetCurrentStyleDef()->ControllerToPlayerNumber( GameI.controller );
|
||||||
|
|
||||||
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
||||||
|
|
||||||
|
// TRICKY: Process codes after handing MenuLeft, MenuRight, MenuStart.
|
||||||
|
// This
|
||||||
if( type == IET_FIRST_PRESS )
|
if( type == IET_FIRST_PRESS )
|
||||||
{
|
{
|
||||||
if( CodeDetector::EnteredEasierDifficulty(GameI.controller) )
|
if( CodeDetector::EnteredEasierDifficulty(GameI.controller) )
|
||||||
@@ -742,8 +791,6 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user