From aaa7a2d18a7755c5139fe42fd4e7a5d9cdaa9c43 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 30 Aug 2005 16:22:48 +0000 Subject: [PATCH] cleanup MultiPlayer/InputDevice mapping --- stepmania/src/InputMapper.cpp | 10 ++++++++++ stepmania/src/InputMapper.h | 3 +++ stepmania/src/ScreenGameplay.cpp | 2 +- stepmania/src/ScreenJoinMultiplayer.cpp | 8 ++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index 7a65e90bb4..4d7d72f126 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -695,6 +695,16 @@ void InputMapper::ResetKeyRepeat( StyleInput StyleI ) ResetKeyRepeat( GameI ); } +InputDevice InputMapper::MultiPlayerToInputDevice( MultiPlayer mp ) +{ + return (InputDevice)(mp + DEVICE_JOY1); +} + +MultiPlayer InputMapper::InputDeviceToMultiPlayer( InputDevice id ) +{ + return (MultiPlayer)(id - DEVICE_JOY1); +} + /* * (c) 2001-2003 Chris Danford * All rights reserved. diff --git a/stepmania/src/InputMapper.h b/stepmania/src/InputMapper.h index beeaa36245..2f49762d00 100644 --- a/stepmania/src/InputMapper.h +++ b/stepmania/src/InputMapper.h @@ -73,6 +73,9 @@ public: bool SecondController; }; + static InputDevice MultiPlayerToInputDevice( MultiPlayer mp ); + static MultiPlayer InputDeviceToMultiPlayer( InputDevice id ); + void ApplyMapping( const Mapping *maps, GameController gc, InputDevice device ); protected: diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 860ff998c4..661282dba1 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -2200,7 +2200,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ StyleInput _StyleI; INPUTMAPPER->GameToStyle( _GameI, _StyleI ); - mp = (MultiPlayer)(DeviceI.device - DEVICE_JOY1); + mp = InputMapper::InputDeviceToMultiPlayer( DeviceI.device ); if( mp>=0 && mpStep( _StyleI.col, DeviceI.ts ); diff --git a/stepmania/src/ScreenJoinMultiplayer.cpp b/stepmania/src/ScreenJoinMultiplayer.cpp index 108a1668f3..f1d7cc2526 100644 --- a/stepmania/src/ScreenJoinMultiplayer.cpp +++ b/stepmania/src/ScreenJoinMultiplayer.cpp @@ -46,8 +46,8 @@ void ScreenJoinMultiplayer::Init() GAMESTATE->m_pCurStyle.Set( v[0] ); GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR ); - GAMESTATE->m_bTemporaryEventMode = true; + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; FOREACH_MultiPlayer( p ) { @@ -113,12 +113,12 @@ void ScreenJoinMultiplayer::Input( const DeviceInput& DeviceI, const InputEventT GameInput gi; INPUTMAPPER->DeviceToGame( di, gi ); - if( GameI.IsValid() ) + if( gi.IsValid() ) { MenuInput mi; INPUTMAPPER->GameToMenu( gi, mi ); - MultiPlayer p = (MultiPlayer)(DeviceI.device - DEVICE_JOY1); + MultiPlayer p = InputMapper::InputDeviceToMultiPlayer( DeviceI.device ); // testing hack if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,KEY_LSHIFT) ) ) @@ -179,7 +179,7 @@ void ScreenJoinMultiplayer::UpdatePlayerStatus( bool bFirstUpdate ) { FOREACH_MultiPlayer( p ) { - InputDevice id = (InputDevice)p; + InputDevice id = InputMapper::MultiPlayerToInputDevice( p ); InputDeviceState idsOld = m_InputDeviceState[p]; bool bWasConnected = idsOld == InputDeviceState_Connected;