From 1dbb8cfac2960ed44983ed120b79b757c9e587da Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 23 Jan 2005 23:49:19 +0000 Subject: [PATCH] Fix shift not releasing g_iShiftAnchor. This call is cleaner and simpler than DeviceToEdit, and it shouldn't be less efficient to call it many times than calling DeviceToEdit once (since DeviceToEdit loops over all keys anyway). Maybe DeviceToEdit should be dropped. --- stepmania/src/ScreenEdit.cpp | 40 +++++++++++++++++++++++++++++++----- stepmania/src/ScreenEdit.h | 1 + 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 23120714ef..b813d6b8f2 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -250,6 +250,40 @@ bool ScreenEdit::DeviceToEdit( DeviceInput DeviceI, EditButton &button ) const return false; } +/* If DeviceI was just pressed, return true if button is triggered. (More than one + * function may be mapped to a key.) */ +bool ScreenEdit::EditPressed( EditButton button, const DeviceInput &DeviceI ) +{ + ASSERT( DeviceI.IsValid() ); + + const MapEditToDI *pCurrentMap = GetCurrentMap(); + + /* First, search to see if a key that requires a modifier is pressed. */ + bool bPrimaryButtonPressed = false; + for( int slot = 0; slot < NUM_EDIT_TO_DEVICE_SLOTS; ++slot ) + { + if( pCurrentMap->button[button][slot] == DeviceI ) + bPrimaryButtonPressed = true; + } + + if( !bPrimaryButtonPressed ) + return false; + + /* The button maps to this function. Does the function has one or more shift modifiers attached? */ + if( !pCurrentMap->hold[button][0].IsValid() ) + return true; + + for( int holdslot = 0; holdslot < NUM_EDIT_TO_DEVICE_SLOTS; ++holdslot ) + { + DeviceInput hDI = pCurrentMap->hold[button][holdslot]; + if( INPUTFILTER->IsBeingPressed(hDI) ) + return true; + } + + /* No shifted keys matched. */ + return false; +} + bool ScreenEdit::EditToDevice( EditButton button, int iSlotNum, DeviceInput &DeviceI ) const { ASSERT( iSlotNum < NUM_EDIT_TO_DEVICE_SLOTS ); @@ -839,12 +873,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ if( type == IET_RELEASE ) { - switch( EditB ) - { - case EDIT_BUTTON_SCROLL_SELECT: + if( EditPressed( EDIT_BUTTON_SCROLL_SELECT, DeviceI ) ) g_iShiftAnchor = -1; - break; - } return; } diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index ef9c3addb2..3e2209e2e5 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -294,6 +294,7 @@ public: void InitEditMappings(); bool DeviceToEdit( DeviceInput DeviceI, EditButton &button ) const; bool EditToDevice( EditButton button, int iSlotNum, DeviceInput &DeviceI ) const; + bool EditPressed( EditButton button, const DeviceInput &DeviceI ); bool EditIsBeingPressed( EditButton button ) const; const MapEditToDI *GetCurrentMap() const; MapEditToDI g_EditMappings, g_PlayMappings, g_RecordMappings;