Wait a couple frames for a second press, since inputs aren't coming

in a single update in Linux.

These really should tend to come in a single update, but I don't have
the adapter to investigate.  Probably something SDL-related ...
This commit is contained in:
Glenn Maynard
2003-09-11 03:47:13 +00:00
parent c8f322ca3c
commit 9a6b4560b1
2 changed files with 11 additions and 9 deletions
+10 -8
View File
@@ -29,6 +29,7 @@
#define ODD_LINE_IN THEME->GetMetric("ScreenMapControllers","OddLineIn") #define ODD_LINE_IN THEME->GetMetric("ScreenMapControllers","OddLineIn")
#define ODD_LINE_OUT THEME->GetMetric("ScreenMapControllers","OddLineOut") #define ODD_LINE_OUT THEME->GetMetric("ScreenMapControllers","OddLineOut")
const int FramesToWaitForInput = 2;
// reserve the 3rd slot for hard-coded keys // reserve the 3rd slot for hard-coded keys
const int NUM_CHANGABLE_SLOTS = NUM_GAME_TO_DEVICE_SLOTS-1; const int NUM_CHANGABLE_SLOTS = NUM_GAME_TO_DEVICE_SLOTS-1;
@@ -97,7 +98,7 @@ ScreenMapControllers::ScreenMapControllers() : Screen("ScreenMapControllers")
m_iCurButton = 0; m_iCurButton = 0;
m_iCurSlot = 0; m_iCurSlot = 0;
m_bWaitingForPress = false; m_iWaitingForPress = 0;
m_Menu.Load( "ScreenMapControllers", false ); // no timer m_Menu.Load( "ScreenMapControllers", false ); // no timer
this->AddChild( &m_Menu ); this->AddChild( &m_Menu );
@@ -120,9 +121,12 @@ void ScreenMapControllers::Update( float fDeltaTime )
Screen::Update( fDeltaTime ); Screen::Update( fDeltaTime );
if( m_bWaitingForPress && m_DeviceIToMap.IsValid() ) // we're going to map an input if( m_iWaitingForPress && m_DeviceIToMap.IsValid() ) // we're going to map an input
{ {
LOG->Trace("K"); --m_iWaitingForPress;
if( m_iWaitingForPress )
return; /* keep waiting */
GameInput curGameI( (GameController)m_iCurController, GameInput curGameI( (GameController)m_iCurController,
(GameButton)m_iCurButton ); (GameButton)m_iCurButton );
@@ -131,7 +135,6 @@ void ScreenMapControllers::Update( float fDeltaTime )
// commit to disk so we don't lose the changes! // commit to disk so we don't lose the changes!
INPUTMAPPER->SaveMappingsToDisk(); INPUTMAPPER->SaveMappingsToDisk();
m_bWaitingForPress = false;
Refresh(); Refresh();
} }
} }
@@ -166,7 +169,7 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
// Update so that a button presses are favored for mapping over axis presses. // Update so that a button presses are favored for mapping over axis presses.
// //
if( m_bWaitingForPress ) if( m_iWaitingForPress )
{ {
/* Don't allow function keys to be mapped. */ /* Don't allow function keys to be mapped. */
if ( DeviceI.device == DEVICE_KEYBOARD && (DeviceI.button >= SDLK_F1 && DeviceI.button <= SDLK_F12) ) if ( DeviceI.device == DEVICE_KEYBOARD && (DeviceI.button >= SDLK_F1 && DeviceI.button <= SDLK_F12) )
@@ -181,7 +184,6 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
} }
else else
{ {
LOG->Trace("set");
m_DeviceIToMap = DeviceI; m_DeviceIToMap = DeviceI;
} }
} }
@@ -244,7 +246,7 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
break; break;
case SDLK_RETURN: /* Change the selection. */ case SDLK_RETURN: /* Change the selection. */
case SDLK_KP_ENTER: case SDLK_KP_ENTER:
m_bWaitingForPress = true; m_iWaitingForPress = FramesToWaitForInput;
m_DeviceIToMap.MakeInvalid(); m_DeviceIToMap.MakeInvalid();
break; break;
} }
@@ -291,7 +293,7 @@ void ScreenMapControllers::Refresh()
bool bPulse; bool bPulse;
if( bSelected ) if( bSelected )
{ {
if( m_bWaitingForPress ) if( m_iWaitingForPress )
{ {
color = RageColor(1,0.5,0.5,1); // red color = RageColor(1,0.5,0.5,1); // red
bPulse = true; bPulse = true;
+1 -1
View File
@@ -45,7 +45,7 @@ private:
int m_iCurButton; int m_iCurButton;
int m_iCurSlot; int m_iCurSlot;
bool m_bWaitingForPress; int m_iWaitingForPress;
DeviceInput m_DeviceIToMap; DeviceInput m_DeviceIToMap;
BitmapText m_textError; BitmapText m_textError;