Integrate C++11 branch into 5_1-new
This commit is contained in:
+32
-33
@@ -9,7 +9,6 @@
|
||||
#include "RageInput.h"
|
||||
#include "SpecialFiles.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "Foreach.h"
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
|
||||
#define AUTOMAPPINGS_DIR "/Data/AutoMappings/"
|
||||
@@ -26,12 +25,12 @@ namespace
|
||||
PlayerNumber g_JoinControllers;
|
||||
};
|
||||
|
||||
InputMapper* INPUTMAPPER = NULL; // global and accessible from anywhere in our program
|
||||
InputMapper* INPUTMAPPER = nullptr; // global and accessible from anywhere in our program
|
||||
|
||||
InputMapper::InputMapper()
|
||||
{
|
||||
g_JoinControllers = PLAYER_INVALID;
|
||||
m_pInputScheme = NULL;
|
||||
m_pInputScheme = nullptr;
|
||||
}
|
||||
|
||||
InputMapper::~InputMapper()
|
||||
@@ -79,20 +78,20 @@ void InputMapper::AddDefaultMappingsForCurrentGameIfUnmapped()
|
||||
vector<AutoMappingEntry> aMaps;
|
||||
aMaps.reserve( 32 );
|
||||
|
||||
FOREACH_CONST( AutoMappingEntry, g_DefaultKeyMappings.m_vMaps, iter )
|
||||
aMaps.push_back( *iter );
|
||||
FOREACH_CONST( AutoMappingEntry, m_pInputScheme->m_pAutoMappings->m_vMaps, iter )
|
||||
aMaps.push_back( *iter );
|
||||
for (AutoMappingEntry const &iter : g_DefaultKeyMappings.m_vMaps)
|
||||
aMaps.push_back( iter );
|
||||
for (AutoMappingEntry const &iter : m_pInputScheme->m_pAutoMappings->m_vMaps)
|
||||
aMaps.push_back( iter );
|
||||
|
||||
/* There may be duplicate GAME_BUTTON maps. Process the list backwards,
|
||||
* so game-specific mappings override g_DefaultKeyMappings. */
|
||||
std::reverse( aMaps.begin(), aMaps.end() );
|
||||
|
||||
FOREACH( AutoMappingEntry, aMaps, m )
|
||||
for (AutoMappingEntry const &m : aMaps)
|
||||
{
|
||||
DeviceButton key = m->m_deviceButton;
|
||||
DeviceButton key = m.m_deviceButton;
|
||||
DeviceInput DeviceI( DEVICE_KEYBOARD, key );
|
||||
GameInput GameI( m->m_bSecondController ? GameController_2 : GameController_1, m->m_gb );
|
||||
GameInput GameI( m.m_bSecondController ? GameController_2 : GameController_1, m.m_gb );
|
||||
if( !IsMapped(DeviceI) ) // if this key isn't already being used by another user-made mapping
|
||||
{
|
||||
if( !GameI.IsValid() )
|
||||
@@ -545,10 +544,10 @@ void InputMapper::Unmap( InputDevice id )
|
||||
void InputMapper::ApplyMapping( const vector<AutoMappingEntry> &vMmaps, GameController gc, InputDevice id )
|
||||
{
|
||||
map<GameInput, int> MappedButtons;
|
||||
FOREACH_CONST( AutoMappingEntry, vMmaps, iter )
|
||||
for (AutoMappingEntry const &iter : vMmaps)
|
||||
{
|
||||
GameController map_gc = gc;
|
||||
if( iter->m_bSecondController )
|
||||
if( iter.m_bSecondController )
|
||||
{
|
||||
map_gc = (GameController)(map_gc+1);
|
||||
|
||||
@@ -559,8 +558,8 @@ void InputMapper::ApplyMapping( const vector<AutoMappingEntry> &vMmaps, GameCont
|
||||
continue;
|
||||
}
|
||||
|
||||
DeviceInput di( id, iter->m_deviceButton );
|
||||
GameInput gi( map_gc, iter->m_gb );
|
||||
DeviceInput di( id, iter.m_deviceButton );
|
||||
GameInput gi( map_gc, iter.m_gb );
|
||||
int iSlot = MappedButtons[gi];
|
||||
++MappedButtons[gi];
|
||||
SetInputMap( di, gi, iSlot );//maps[k].iSlotIndex );
|
||||
@@ -578,10 +577,10 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
|
||||
// file automaps - Add these first so that they can match before the hard-coded mappings
|
||||
vector<RString> vs;
|
||||
GetDirListing( AUTOMAPPINGS_DIR "*.ini", vs, false, true );
|
||||
FOREACH_CONST( RString, vs, sFilePath )
|
||||
for (RString const &sFilePath : vs)
|
||||
{
|
||||
InputMappings km;
|
||||
km.ReadMappings( m_pInputScheme, *sFilePath, true );
|
||||
km.ReadMappings( m_pInputScheme, sFilePath, true );
|
||||
|
||||
AutoMappings mapping( m_pInputScheme->m_szName, km.m_sDeviceRegex, km.m_sDescription );
|
||||
|
||||
@@ -616,13 +615,13 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
|
||||
|
||||
// apply auto mappings
|
||||
int iNumJoysticksMapped = 0;
|
||||
FOREACH_CONST( InputDeviceInfo, vDevices, device )
|
||||
for (InputDeviceInfo const &device : vDevices)
|
||||
{
|
||||
InputDevice id = device->id;
|
||||
const RString &sDescription = device->sDesc;
|
||||
FOREACH_CONST( AutoMappings, vAutoMappings, mapping )
|
||||
InputDevice id = device.id;
|
||||
const RString &sDescription = device.sDesc;
|
||||
for (AutoMappings const &mapping : vAutoMappings)
|
||||
{
|
||||
Regex regex( mapping->m_sDriverRegex );
|
||||
Regex regex( mapping.m_sDriverRegex );
|
||||
if( !regex.Compare(sDescription) )
|
||||
continue; // driver names don't match
|
||||
|
||||
@@ -632,10 +631,10 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
|
||||
break; // stop mapping. We already mapped one device for each game controller.
|
||||
|
||||
LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)",
|
||||
iNumJoysticksMapped+1, mapping->m_sDriverRegex.c_str(), mapping->m_sControllerName.c_str() );
|
||||
iNumJoysticksMapped+1, mapping.m_sDriverRegex.c_str(), mapping.m_sControllerName.c_str() );
|
||||
|
||||
Unmap( id );
|
||||
ApplyMapping( mapping->m_vMaps, gc, id );
|
||||
ApplyMapping( mapping.m_vMaps, gc, id );
|
||||
|
||||
iNumJoysticksMapped++;
|
||||
}
|
||||
@@ -686,16 +685,16 @@ void InputMapper::CheckButtonAndAddToReason(GameButton menu, vector<RString>& fu
|
||||
if(!inputs.empty())
|
||||
{
|
||||
vector<DeviceInput> device_inputs;
|
||||
FOREACH(GameInput, inputs, inp)
|
||||
for(GameInput &inp : inputs)
|
||||
{
|
||||
for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot)
|
||||
{
|
||||
device_inputs.push_back(m_mappings.m_GItoDI[inp->controller][inp->button][slot]);
|
||||
device_inputs.push_back(m_mappings.m_GItoDI[inp.controller][inp.button][slot]);
|
||||
}
|
||||
}
|
||||
FOREACH(DeviceInput, device_inputs, inp)
|
||||
for(DeviceInput &inp : device_inputs)
|
||||
{
|
||||
if(!inp->IsValid())
|
||||
if(!inp.IsValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -706,7 +705,7 @@ void InputMapper::CheckButtonAndAddToReason(GameButton menu, vector<RString>& fu
|
||||
{
|
||||
for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot)
|
||||
{
|
||||
use_count+= ((*inp) == m_mappings.m_GItoDI[cont][gb][slot]);
|
||||
use_count+= (inp == m_mappings.m_GItoDI[cont][gb][slot]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1096,16 +1095,16 @@ void InputScheme::MenuButtonToGameInputs( GameButton MenuI, PlayerNumber pn, vec
|
||||
|
||||
vector<GameButton> aGameButtons;
|
||||
MenuButtonToGameButtons( MenuI, aGameButtons );
|
||||
FOREACH( GameButton, aGameButtons, gb )
|
||||
for (GameButton const &gb : aGameButtons)
|
||||
{
|
||||
if( pn == PLAYER_INVALID )
|
||||
{
|
||||
GameIout.push_back( GameInput(GameController_1, *gb) );
|
||||
GameIout.push_back( GameInput(GameController_2, *gb) );
|
||||
GameIout.push_back( GameInput(GameController_1, gb) );
|
||||
GameIout.push_back( GameInput(GameController_2, gb) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GameIout.push_back( GameInput((GameController)pn, *gb) );
|
||||
GameIout.push_back( GameInput((GameController)pn, gb) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1249,7 +1248,7 @@ void InputMappings::WriteMappings( const InputScheme *pInputScheme, RString sFil
|
||||
ini.DeleteKey( pInputScheme->m_szName );
|
||||
|
||||
XNode *pKey = ini.GetChild( pInputScheme->m_szName );
|
||||
if( pKey != NULL )
|
||||
if( pKey != nullptr )
|
||||
ini.RemoveChild( pKey );
|
||||
pKey = ini.AppendChild( pInputScheme->m_szName );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user