add memcard blacklist by OsMountDir and UI to disable specific drives
This commit is contained in:
@@ -49,6 +49,9 @@ Preference1D<int> MemoryCardManager::m_iMemoryCardUsbBus( MemoryCardUsbBusInit,
|
||||
Preference1D<int> MemoryCardManager::m_iMemoryCardUsbPort( MemoryCardUsbPortInit, NUM_PLAYERS );
|
||||
Preference1D<int> MemoryCardManager::m_iMemoryCardUsbLevel( MemoryCardUsbLevelInit, NUM_PLAYERS );
|
||||
|
||||
Preference<CString> MemoryCardManager::m_sMemoryCardOsMountPointBlacklist( "MemoryCardOsMountPointBlacklist", "" );
|
||||
|
||||
|
||||
const CString MEM_CARD_MOUNT_POINT[NUM_PLAYERS] =
|
||||
{
|
||||
/* @ is importast; see RageFileManager LoadedDriver::GetPath */
|
||||
@@ -324,50 +327,33 @@ MemoryCardManager::~MemoryCardManager()
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCardManager::Update( float fDelta )
|
||||
bool MemoryCardManager::IsBlacklisted( const UsbStorageDevice &dev ) const
|
||||
{
|
||||
const vector<UsbStorageDevice> vOld = m_vStorageDevices; // copy
|
||||
if( !g_pWorker->StorageDevicesChanged( m_vStorageDevices ) )
|
||||
return;
|
||||
/* const vector<UsbStorageDevice> &vNew = m_vStorageDevices;
|
||||
vector<CString> vsMemoryCardOsMountPointBlacklist;
|
||||
split( m_sMemoryCardOsMountPointBlacklist, ",", vsMemoryCardOsMountPointBlacklist );
|
||||
|
||||
vector<UsbStorageDevice> vConnects; // fill these in below
|
||||
vector<UsbStorageDevice> vDisconnects; // fill these in below
|
||||
bool bBlacklisted = find( vsMemoryCardOsMountPointBlacklist.begin(), vsMemoryCardOsMountPointBlacklist.end(), dev.sOsMountDir ) != vsMemoryCardOsMountPointBlacklist.end();
|
||||
return bBlacklisted;
|
||||
}
|
||||
|
||||
void MemoryCardManager::Update( float fDelta, bool bForceUpdate )
|
||||
{
|
||||
vector<UsbStorageDevice> vOld;
|
||||
|
||||
// check for disconnects
|
||||
FOREACH_CONST( UsbStorageDevice, vOld, old )
|
||||
if( bForceUpdate )
|
||||
{
|
||||
vector<UsbStorageDevice>::const_iterator iter = find( vNew.begin(), vNew.end(), *old );
|
||||
if( iter == vNew.end() ) // card no longer present
|
||||
{
|
||||
LOG->Trace( "Disconnected bus %d port %d device %d path %s", old->iBus, old->iPort, old->iLevel, old->sOsMountDir.c_str() );
|
||||
vDisconnects.push_back( *old );
|
||||
}
|
||||
// force a redetect on the next update
|
||||
FOREACH_PlayerNumber( p )
|
||||
m_Device[p].MakeBlank();
|
||||
// leave vOld empty
|
||||
}
|
||||
|
||||
// check for connects
|
||||
FOREACH_CONST( UsbStorageDevice, vNew, newd )
|
||||
else
|
||||
{
|
||||
vector<UsbStorageDevice>::const_iterator iter = find( vOld.begin(), vOld.end(), *newd );
|
||||
if( iter == vOld.end() ) // card wasn't present last update
|
||||
{
|
||||
LOG->Trace( "Connected bus %d port %d device %d path %s", newd->iBus, newd->iPort, newd->iLevel, newd->sOsMountDir.c_str() );
|
||||
vConnects.push_back( *newd );
|
||||
}
|
||||
vOld = m_vStorageDevices; // copy
|
||||
if( !g_pWorker->StorageDevicesChanged( m_vStorageDevices ) )
|
||||
return;
|
||||
}
|
||||
|
||||
// unassign cards that were disconnected
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
UsbStorageDevice &assigned_device = m_Device[p];
|
||||
if( assigned_device.IsBlank() ) // not assigned a card
|
||||
continue;
|
||||
|
||||
vector<UsbStorageDevice>::iterator iter = find( vDisconnects.begin(), vDisconnects.end(), assigned_device );
|
||||
if( iter != vDisconnects.end() )
|
||||
assigned_device.MakeBlank();
|
||||
}
|
||||
*/
|
||||
|
||||
// make a list of unassigned
|
||||
vector<UsbStorageDevice> vUnassignedDevices = m_vStorageDevices; // copy
|
||||
|
||||
@@ -421,6 +407,9 @@ void MemoryCardManager::Update( float fDelta )
|
||||
d->sOsMountDir.CompareNoCase(m_sMemoryCardOsMountPoint[p].Get()) )
|
||||
continue; // not a match
|
||||
|
||||
if( IsBlacklisted(*d) )
|
||||
continue;
|
||||
|
||||
// search for USB bus match
|
||||
if( m_iMemoryCardUsbBus[p] != -1 &&
|
||||
m_iMemoryCardUsbBus[p] != d->iBus )
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
MemoryCardManager();
|
||||
~MemoryCardManager();
|
||||
|
||||
void Update( float fDelta );
|
||||
void Update( float fDelta, bool bForceUpdate = false );
|
||||
|
||||
MemoryCardState GetCardState( PlayerNumber pn ) const { return m_State[pn]; }
|
||||
CString GetCardError( PlayerNumber pn ) const { return m_sError[pn]; }
|
||||
@@ -39,17 +39,21 @@ public:
|
||||
bool IsNameAvailable( PlayerNumber pn ) const;
|
||||
CString GetName( PlayerNumber pn ) const;
|
||||
|
||||
const vector<UsbStorageDevice> &GetStorageDevices() { return m_vStorageDevices; }
|
||||
|
||||
static Preference1D<CString> m_sMemoryCardOsMountPoint;
|
||||
static Preference1D<int> m_iMemoryCardUsbBus;
|
||||
static Preference1D<int> m_iMemoryCardUsbPort;
|
||||
static Preference1D<int> m_iMemoryCardUsbLevel;
|
||||
|
||||
static Preference<CString> m_sMemoryCardOsMountPointBlacklist;
|
||||
bool IsBlacklisted( const UsbStorageDevice &dev ) const;
|
||||
|
||||
protected:
|
||||
void CheckStateChanges();
|
||||
|
||||
vector<UsbStorageDevice> m_vStorageDevices; // all currently connected
|
||||
|
||||
|
||||
bool m_bCardsLocked;
|
||||
bool m_bMounted[NUM_PLAYERS]; // card is currently mounted
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ struct OptionRowDefinition
|
||||
vector<CString> m_vsChoices;
|
||||
set<PlayerNumber> m_vEnabledForPlayers; // only players in this set may change focus to this row
|
||||
bool m_bExportOnChange;
|
||||
bool m_bAllowThemeItems; // if false, ignores ScreenOptions::THEME_ITEMS
|
||||
bool m_bAllowThemeTitles; // if false, ignores ScreenOptions::THEME_TITLES
|
||||
bool m_bAllowExplanation; // if false, ignores ScreenOptions::SHOW_EXPLANATIONS
|
||||
bool m_bAllowThemeItems; // if false, ignores ScreenOptions::THEME_ITEMS. Should be true for dynamic strings.
|
||||
bool m_bAllowThemeTitles; // if false, ignores ScreenOptions::THEME_TITLES. Should be true for dynamic strings.
|
||||
bool m_bAllowExplanation; // if false, ignores ScreenOptions::SHOW_EXPLANATIONS. Should be true for dynamic strings.
|
||||
bool m_bShowChoicesListOnSelect;
|
||||
|
||||
bool IsEnabledForPlayer( PlayerNumber pn ) const
|
||||
|
||||
@@ -327,7 +327,7 @@ PrefsManager::PrefsManager() :
|
||||
m_sLanguage ( "Language", "" ), // ThemeManager will deal with this invalid language
|
||||
m_sMemoryCardProfileSubdir ( "MemoryCardProfileSubdir", PRODUCT_NAME ),
|
||||
m_iProductID ( "ProductID", 1 ),
|
||||
m_bMemoryCards ( "MemoryCards", false ),
|
||||
m_bMemoryCards ( "MemoryCards", true ),
|
||||
m_iCenterImageTranslateX ( "CenterImageTranslateX", 0 ),
|
||||
m_iCenterImageTranslateY ( "CenterImageTranslateY", 0 ),
|
||||
m_fCenterImageAddWidth ( "CenterImageAddWidth", 0 ),
|
||||
|
||||
@@ -21,6 +21,7 @@ struct UsbStorageDevice
|
||||
idProduct = 0;
|
||||
sVendor = "";
|
||||
sProduct = "";
|
||||
sVolumeLabel = "";
|
||||
};
|
||||
int iBus;
|
||||
int iPort;
|
||||
@@ -58,6 +59,7 @@ struct UsbStorageDevice
|
||||
int idProduct;
|
||||
CString sVendor;
|
||||
CString sProduct;
|
||||
CString sVolumeLabel;
|
||||
|
||||
bool IsBlank() const { return m_State == STATE_NONE; }
|
||||
void SetOsMountDir( const CString &s );
|
||||
|
||||
@@ -19,7 +19,7 @@ MemoryCardDriverThreaded_Windows::~MemoryCardDriverThreaded_Windows()
|
||||
{
|
||||
}
|
||||
|
||||
static bool TestReady( const CString &sDrive )
|
||||
static bool TestReady( const CString &sDrive, CString &sVolumeLabelOut )
|
||||
{
|
||||
TCHAR szVolumeNameBuffer[MAX_PATH];
|
||||
DWORD dwVolumeSerialNumber;
|
||||
@@ -27,7 +27,7 @@ static bool TestReady( const CString &sDrive )
|
||||
DWORD lpFileSystemFlags;
|
||||
TCHAR szFileSystemNameBuffer[MAX_PATH];
|
||||
|
||||
return !!GetVolumeInformation(
|
||||
bool bRet = !!GetVolumeInformation(
|
||||
sDrive,
|
||||
szVolumeNameBuffer,
|
||||
sizeof(szVolumeNameBuffer),
|
||||
@@ -36,6 +36,8 @@ static bool TestReady( const CString &sDrive )
|
||||
&lpFileSystemFlags,
|
||||
szFileSystemNameBuffer,
|
||||
sizeof(szFileSystemNameBuffer) );
|
||||
sVolumeLabelOut = szVolumeNameBuffer;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
static bool TestWrite( const CString &sDrive )
|
||||
@@ -87,11 +89,13 @@ bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStora
|
||||
if( GetDriveType(sDrive) != DRIVE_REMOVABLE ) // is a removable drive
|
||||
continue;
|
||||
|
||||
if( !TestReady(sDrive) )
|
||||
CString sVolumeLabel;
|
||||
if( !TestReady(sDrive, sVolumeLabel) )
|
||||
continue;
|
||||
|
||||
UsbStorageDevice usbd;
|
||||
usbd.SetOsMountDir( sDrive );
|
||||
usbd.sVolumeLabel = sVolumeLabel;
|
||||
if( TestWrite(sDrive) )
|
||||
usbd.m_State = UsbStorageDevice::STATE_READY;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user