diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 0d5c0ffcff..8471212002 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -2172,27 +2172,11 @@ void ScreenGameplay::Input( const InputEventPlus &input ) if( GAMESTATE->m_bMultiplayer ) { - MultiPlayer mp = MultiPlayer_INVALID; - - // Translate input and sent to the appropriate player. Assume that all - // joystick devices are mapped the same as the master player. - if( input.DeviceI.IsJoystick() ) + if( input.mp != MultiPlayer_INVALID && + input.StyleI.IsValid() && + GAMESTATE->IsMultiPlayerEnabled(input.mp) ) { - DeviceInput _DeviceI = input.DeviceI; - _DeviceI.device = DEVICE_JOY1; - GameInput _GameI; - INPUTMAPPER->DeviceToGame( _DeviceI, _GameI ); - - if( input.GameI.IsValid() ) - { - StyleInput _StyleI; - INPUTMAPPER->GameToStyle( _GameI, _StyleI ); - - mp = InputMapper::InputDeviceToMultiPlayer( input.DeviceI.device ); - - if( mp>=0 && mpStep( _StyleI.col, input.DeviceI.ts ); - } + m_vPlayerInfo[input.mp].m_pPlayer->Step( input.StyleI.col, input.DeviceI.ts ); } } else diff --git a/stepmania/src/ScreenJoinMultiplayer.cpp b/stepmania/src/ScreenJoinMultiplayer.cpp index 012768c4a0..3c07541021 100644 --- a/stepmania/src/ScreenJoinMultiplayer.cpp +++ b/stepmania/src/ScreenJoinMultiplayer.cpp @@ -45,7 +45,6 @@ void ScreenJoinMultiplayer::Init() GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, v, false ); GAMESTATE->m_pCurStyle.Set( v[0] ); - GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR ); GAMESTATE->m_bTemporaryEventMode = true; GAMESTATE->m_MasterPlayerNumber = PLAYER_1; @@ -106,57 +105,35 @@ void ScreenJoinMultiplayer::Input( const InputEventPlus &input ) // joystick devices are mapped the same as the master player. if( input.type == IET_FIRST_PRESS && input.DeviceI.device >= DEVICE_JOY1 && - input.DeviceI.device < DEVICE_JOY1 + NUM_MultiPlayer ) - { - DeviceInput di = input.DeviceI; - di.device = DEVICE_JOY1; - GameInput gi; - INPUTMAPPER->DeviceToGame( di, gi ); + input.DeviceI.device < DEVICE_JOY1 + NUM_MultiPlayer && + input.MenuI.IsValid() ) + { + MultiPlayerStatus old = m_MultiPlayerStatus[input.mp]; - if( gi.IsValid() ) + switch( input.MenuI.button ) { - MenuInput mi; - INPUTMAPPER->GameToMenu( gi, mi ); - - MultiPlayer p = InputMapper::InputDeviceToMultiPlayer( input.DeviceI.device ); - - // testing hack - if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LSHIFT) ) ) - p = (MultiPlayer)(p + 1); - if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LCTRL) ) ) - p = (MultiPlayer)(p + 2); - if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LALT) ) ) - p = (MultiPlayer)(p + 4); - - ASSERT( p>=0 && pPlayCommand( MultiPlayerStatusToString(m_MultiPlayerStatus[p]) ); - } - return; // input handled - case MENU_BUTTON_DOWN: - if( old == MultiPlayerStatus_Joined ) - { - m_soundUnjoin.Play(); - m_MultiPlayerStatus[p] = MultiPlayerStatus_NotJoined; - m_sprPlayer[p]->PlayCommand( MultiPlayerStatusToString(m_MultiPlayerStatus[p]) ); - } - return; // input handled - case MENU_BUTTON_BACK: - MenuBack( GAMESTATE->m_MasterPlayerNumber ); - return; // input handled - case MENU_BUTTON_START: - MenuStart( GAMESTATE->m_MasterPlayerNumber ); - return; // input handled + m_soundJoin.Play(); + m_MultiPlayerStatus[input.mp] = MultiPlayerStatus_Joined; + m_sprPlayer[input.mp]->PlayCommand( MultiPlayerStatusToString(m_MultiPlayerStatus[input.mp]) ); } + return; // input handled + case MENU_BUTTON_DOWN: + if( old == MultiPlayerStatus_Joined ) + { + m_soundUnjoin.Play(); + m_MultiPlayerStatus[input.mp] = MultiPlayerStatus_NotJoined; + m_sprPlayer[input.mp]->PlayCommand( MultiPlayerStatusToString(m_MultiPlayerStatus[input.mp]) ); + } + return; // input handled + case MENU_BUTTON_BACK: + //MenuBack( GAMESTATE->m_MasterPlayerNumber ); + return; // input handled + case MENU_BUTTON_START: + MenuStart( GAMESTATE->m_MasterPlayerNumber ); + return; // input handled } } @@ -183,8 +160,10 @@ void ScreenJoinMultiplayer::UpdatePlayerStatus( bool bFirstUpdate ) InputDeviceState idsOld = m_InputDeviceState[p]; bool bWasConnected = idsOld == InputDeviceState_Connected; - - InputDeviceState idsNew = INPUTMAN->GetInputDeviceState(id); + + // DEBUG + //InputDeviceState idsNew = INPUTMAN->GetInputDeviceState(id); + InputDeviceState idsNew = InputDeviceState_Connected; if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD,KEY_RSHIFT)) ) idsNew = InputDeviceState_Disconnected; bool bIsConnected = idsNew == InputDeviceState_Connected; @@ -235,8 +214,15 @@ void ScreenJoinMultiplayer::MenuBack( PlayerNumber pn ) } static LocalizedString JOIN_2_OR_MORE_PLAYERS ("ScreenJoinMultiplayer", "You must join 2 or more players before continuing."); +static LocalizedString ONLY_PLAYER_1_CAN_START ("ScreenJoinMultiplayer", "Only Player 1 can start the game."); void ScreenJoinMultiplayer::MenuStart( PlayerNumber pn ) { + if( pn != PLAYER_1 ) + { + ScreenPrompt::Prompt( SM_None, ONLY_PLAYER_1_CAN_START ); + return; + } + int iNumJoinedPlayers = 0; FOREACH_MultiPlayer( p ) { diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 4dcf59d315..e4e77ca90e 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1332,6 +1332,17 @@ void HandleInputEvents(float fDeltaTime) input.DeviceI = (DeviceInput)ieArray[i]; input.type = ieArray[i].type; + // hack for testing with only one joytick + if( input.DeviceI.IsJoystick() ) + { + if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LSHIFT) ) ) + input.DeviceI.device = (InputDevice)(input.DeviceI.device + 1); + if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LCTRL) ) ) + input.DeviceI.device = (InputDevice)(input.DeviceI.device + 2); + if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LALT) ) ) + input.DeviceI.device = (InputDevice)(input.DeviceI.device + 4); + } + INPUTMAPPER->DeviceToGame( input.DeviceI, input.GameI ); if( input.GameI.IsValid() && input.type == IET_FIRST_PRESS ) @@ -1342,37 +1353,31 @@ void HandleInputEvents(float fDeltaTime) INPUTMAPPER->GameToStyle( input.GameI, input.StyleI ); } - if( !GAMESTATE->m_bMultiplayer ) - { - input.mp = MultiPlayer_INVALID; - } - else + input.mp = MultiPlayer_INVALID; + + if( GAMESTATE->m_bMultiplayer ) { // Translate input and sent to the appropriate player. Assume that all // joystick devices are mapped the same as the master player. if( input.DeviceI.IsJoystick() ) { - DeviceInput _DeviceI = input.DeviceI; - _DeviceI.device = DEVICE_JOY1; - GameInput _GameI; - INPUTMAPPER->DeviceToGame( _DeviceI, _GameI ); + DeviceInput diTemp = input.DeviceI; + diTemp.device = DEVICE_JOY1; - if( input.GameI.IsValid() ) + //LOG->Trace( "device %d, %d", diTemp.device, diTemp.button ); + if( INPUTMAPPER->DeviceToGame(diTemp, input.GameI) ) { - StyleInput _StyleI; - INPUTMAPPER->GameToStyle( _GameI, _StyleI ); - input.mp = InputMapper::InputDeviceToMultiPlayer( input.DeviceI.device ); - } + //LOG->Trace( "game %d %d", input.GameI.controller, input.GameI.button ); + INPUTMAPPER->GameToStyle( input.GameI, input.StyleI ); + INPUTMAPPER->GameToMenu( input.GameI, input.MenuI ); - /* - // hack for testing with only one joytick - if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LSHIFT) ) ) - p = (MultiPlayer)(p + 1); - if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LCTRL) ) ) - p = (MultiPlayer)(p + 2); - if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LALT) ) ) - p = (MultiPlayer)(p + 4); - */ + //LOG->Trace( "style %d %d", input.StyleI.player, input.StyleI.col ); + //LOG->Trace( "menu %d %d", input.MenuI.player, input.MenuI.button ); + + input.mp = InputMapper::InputDeviceToMultiPlayer( input.DeviceI.device ); + //LOG->Trace( "multiplayer %d", input.mp ); + ASSERT( input.mp >= 0 && input.mp < NUM_MultiPlayer ); + } } }