make mapping logic not dependent on the framerate. The "prefer non-
axes" logic may not have worked at all on fast systems with vsync off.
This commit is contained in:
@@ -19,7 +19,7 @@ static const ThemeMetric<apActorCommands> EVEN_LINE_OUT ("ScreenMapControllers",
|
|||||||
static const ThemeMetric<apActorCommands> ODD_LINE_IN ("ScreenMapControllers","OddLineIn");
|
static const ThemeMetric<apActorCommands> ODD_LINE_IN ("ScreenMapControllers","OddLineIn");
|
||||||
static const ThemeMetric<apActorCommands> ODD_LINE_OUT ("ScreenMapControllers","OddLineOut");
|
static const ThemeMetric<apActorCommands> ODD_LINE_OUT ("ScreenMapControllers","OddLineOut");
|
||||||
|
|
||||||
static const int FramesToWaitForInput = 2;
|
static const float g_fSecondsToWaitForInput = 0.05f;
|
||||||
|
|
||||||
// reserve the 3rd slot for hard-coded keys
|
// reserve the 3rd slot for hard-coded keys
|
||||||
static const int NUM_CHANGABLE_SLOTS = NUM_SHOWN_GAME_TO_DEVICE_SLOTS-1;
|
static const int NUM_CHANGABLE_SLOTS = NUM_SHOWN_GAME_TO_DEVICE_SLOTS-1;
|
||||||
@@ -110,7 +110,7 @@ void ScreenMapControllers::Init()
|
|||||||
m_iCurButton = 0;
|
m_iCurButton = 0;
|
||||||
m_iCurSlot = 0;
|
m_iCurSlot = 0;
|
||||||
|
|
||||||
m_iWaitingForPress = 0;
|
m_WaitingForPress.SetZero();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ void ScreenMapControllers::Update( float fDeltaTime )
|
|||||||
ScreenWithMenuElements::Update( fDeltaTime );
|
ScreenWithMenuElements::Update( fDeltaTime );
|
||||||
|
|
||||||
|
|
||||||
if( m_iWaitingForPress && m_DeviceIToMap.IsValid() ) // we're going to map an input
|
if( !m_WaitingForPress.IsZero() && m_DeviceIToMap.IsValid() ) // we're going to map an input
|
||||||
{
|
{
|
||||||
--m_iWaitingForPress;
|
if( m_WaitingForPress.PeekDeltaTime() < g_fSecondsToWaitForInput )
|
||||||
if( m_iWaitingForPress )
|
|
||||||
return; /* keep waiting */
|
return; /* keep waiting */
|
||||||
|
m_WaitingForPress.SetZero();
|
||||||
|
|
||||||
const KeyToMap *pKey = &m_KeysToMap[m_iCurButton];
|
const KeyToMap *pKey = &m_KeysToMap[m_iCurButton];
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ void ScreenMapControllers::Input( const InputEventPlus &input )
|
|||||||
int button = input.DeviceI.button;
|
int button = input.DeviceI.button;
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
if( !m_iWaitingForPress && input.DeviceI.device == DEVICE_JOY1 )
|
if( m_WaitingForPress.IsZero() && input.DeviceI.device == DEVICE_JOY1 )
|
||||||
{
|
{
|
||||||
// map the xbox controller buttons to the keyboard equivalents
|
// map the xbox controller buttons to the keyboard equivalents
|
||||||
if( input.DeviceI.button == JOY_HAT_LEFT )
|
if( input.DeviceI.button == JOY_HAT_LEFT )
|
||||||
@@ -209,7 +209,7 @@ void ScreenMapControllers::Input( const InputEventPlus &input )
|
|||||||
// that we get a chance to see all input events the user's press of a panel.
|
// that we get a chance to see all input events the user's press of a panel.
|
||||||
// Prefer non-axis events over axis events.
|
// Prefer non-axis events over axis events.
|
||||||
//
|
//
|
||||||
if( m_iWaitingForPress )
|
if( !m_WaitingForPress.IsZero() )
|
||||||
{
|
{
|
||||||
/* Don't allow function keys to be mapped. */
|
/* Don't allow function keys to be mapped. */
|
||||||
if( input.DeviceI.device == DEVICE_KEYBOARD && (input.DeviceI.button >= KEY_F1 && input.DeviceI.button <= KEY_F12) )
|
if( input.DeviceI.device == DEVICE_KEYBOARD && (input.DeviceI.button >= KEY_F1 && input.DeviceI.button <= KEY_F12) )
|
||||||
@@ -305,7 +305,7 @@ void ScreenMapControllers::Input( const InputEventPlus &input )
|
|||||||
break;
|
break;
|
||||||
case KEY_ENTER: /* Change the selection. */
|
case KEY_ENTER: /* Change the selection. */
|
||||||
case KEY_KP_ENTER:
|
case KEY_KP_ENTER:
|
||||||
m_iWaitingForPress = FramesToWaitForInput;
|
m_WaitingForPress.Touch();
|
||||||
m_DeviceIToMap.MakeInvalid();
|
m_DeviceIToMap.MakeInvalid();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ void ScreenMapControllers::Refresh()
|
|||||||
|
|
||||||
if( bSelected )
|
if( bSelected )
|
||||||
{
|
{
|
||||||
if( m_iWaitingForPress )
|
if( !m_WaitingForPress.IsZero() )
|
||||||
pText->PlayCommand( "Waiting" );
|
pText->PlayCommand( "Waiting" );
|
||||||
else
|
else
|
||||||
pText->PlayCommand( "Selected" );
|
pText->PlayCommand( "Selected" );
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ private:
|
|||||||
int m_iCurButton;
|
int m_iCurButton;
|
||||||
int m_iCurSlot;
|
int m_iCurSlot;
|
||||||
|
|
||||||
int m_iWaitingForPress;
|
RageTimer m_WaitingForPress;
|
||||||
DeviceInput m_DeviceIToMap;
|
DeviceInput m_DeviceIToMap;
|
||||||
|
|
||||||
struct KeyToMap
|
struct KeyToMap
|
||||||
|
|||||||
Reference in New Issue
Block a user