@ -27,7 +27,7 @@ namespace Ship {
physicalDevices . clear ( ) ;
# ifndef __WIIU__
for ( int i = 0 ; i < SDL_NumJoysticks ( ) ; i + + ) {
for ( int 32_t i = 0 ; i < SDL_NumJoysticks ( ) ; i + + ) {
if ( SDL_IsGameController ( i ) ) {
auto sdl = std : : make_shared < SDLController > ( i ) ;
sdl - > Open ( ) ;
@ -44,7 +44,7 @@ namespace Ship {
gamepad - > Open ( ) ;
physicalDevices . push_back ( gamepad ) ;
for ( int i = 0 ; i < 4 ; i + + ) {
for ( int 32_t i = 0 ; i < 4 ; i + + ) {
auto controller = std : : make_shared < Ship : : WiiUController > ( ( WPADChan ) i ) ;
controller - > Open ( ) ;
physicalDevices . push_back ( controller ) ;
@ -53,20 +53,20 @@ namespace Ship {
physicalDevices . push_back ( std : : make_shared < DummyController > ( " Disconnected " , " None " , false ) ) ;
for ( const auto & device : physicalDevices ) {
for ( int i = 0 ; i < MAXCONTROLLERS ; i + + ) {
for ( const auto device : physicalDevices ) {
for ( int 32_t i = 0 ; i < MAXCONTROLLERS ; i + + ) {
device - > CreateDefaultBinding ( i ) ;
}
}
for ( int i = 0 ; i < MAXCONTROLLERS ; i + + ) {
for ( int 32_t i = 0 ; i < MAXCONTROLLERS ; i + + ) {
virtualDevices . push_back ( i = = 0 ? 0 : static_cast < int > ( physicalDevices . size ( ) ) - 1 ) ;
}
LoadControllerSettings ( ) ;
}
void ControlDeck : : SetPhysicalDevice ( int slot , in t deviceSlot ) {
void ControlDeck : : SetPhysicalDevice ( int 32_t slot , in t32_ t deviceSlot ) {
const std : : shared_ptr < Controller > backend = physicalDevices [ deviceSlot ] ;
virtualDevices [ slot ] = deviceSlot ;
* controllerBits | = ( backend - > Connected ( ) ) < < slot ;
@ -104,7 +104,7 @@ namespace Ship {
std : : shared_ptr < Mercury > Config = GlobalCtx2 : : GetInstance ( ) - > GetConfig ( ) ;
for ( auto const & val : Config - > rjson [ " Controllers " ] [ " Deck " ] . items ( ) ) {
int slot = std : : stoi ( val . key ( ) . substr ( 5 ) ) ;
int 32_t slot = std : : stoi ( val . key ( ) . substr ( 5 ) ) ;
for ( size_t dev = 0 ; dev < physicalDevices . size ( ) ; dev + + ) {
std : : string guid = physicalDevices [ dev ] - > GetGuid ( ) ;
@ -119,7 +119,7 @@ namespace Ship {
Config - > setString ( StringHelper : : Sprintf ( " Controllers.Deck.Slot_%d " , ( int ) i ) , backend - > GetGuid ( ) ) ;
}
for ( const auto & device : physicalDevices ) {
for ( const auto device : physicalDevices ) {
std : : string guid = device - > GetGuid ( ) ;
@ -128,35 +128,59 @@ namespace Ship {
if ( ! ( Config - > rjson [ " Controllers " ] . contains ( guid ) & & Config - > rjson [ " Controllers " ] [ guid ] . contains ( StringHelper : : Sprintf ( " Slot_%d " , virtualSlot ) ) ) ) continue ;
auto profile = device - > getProfile ( virtualSlot ) ;
auto rawProfile = Config - > rjson [ " Controllers " ] [ guid ] [ StringHelper : : Sprintf ( " Slot_%d " , virtualSlot ) ] ;
auto rawProfile = Config - > rjson [ " Controllers " ] [ guid ] [ StringHelper : : Sprintf ( " Slot_%d " , virtualSlot ) ] ;
profile - > Mappings . clear ( ) ;
profile - > AxisDeadzones . clear ( ) ;
profile - > Axis Sensitiviti es. clear ( ) ;
profile - > Axis Deadzon es. clear ( ) ;
profile - > GyroData . clear ( ) ;
profile - > Version = Config - > getInt ( NESTED ( " Version " , " " ) ) ;
profile - > UseRumble = Config - > getBool ( NESTED ( " Rumble.Enabled " , " " ) ) ;
profile - > RumbleStrength = Config - > getFloat ( NESTED ( " Rumble.Strength " , " " ) ) ;
profile - > UseGyro = Config - > getBool ( NESTED ( " Gyro.Enabled " , " " ) ) ;
for ( auto const & val : rawProfile [ " AxisDeadzones " ] . items ( ) ) {
profile - > AxisDeadzones [ std : : stoi ( val . key ( ) ) ] = val . value ( ) ;
}
profile - > Version = Config - > getInt ( NESTED ( " Version " , " " ) , DEVICE_PROFILE_VERSION_V0 ) ;
for ( auto const & val : rawProfile [ " AxisSensitivities " ] . items ( ) ) {
profile - > AxisSensitivities [ std : : stoi ( val . key ( ) ) ] = val . value ( ) ;
}
switch ( profile - > Version ) {
for ( auto const & val : rawProfile [ " AxisMinimumPress " ] . items ( ) ) {
profile - > AxisMinimumPress [ std : : stoi ( val . key ( ) ) ] = val . value ( ) ;
}
case DEVICE_PROFILE_VERSION_V0 :
for ( auto const & val : rawProfile [ " GyroData " ] . items ( ) ) {
profile - > GyroData [ std : : stoi ( val . key ( ) ) ] = val . value ( ) ;
}
// Load up defaults for the things we can't load.
device - > CreateDefaultBinding ( virtualSlot ) ;
for ( auto const & val : rawProfile [ " Mappings " ] . items ( ) ) {
device - > SetButtonMapping ( virtualSlot , std : : stoi ( val . key ( ) . substr ( 4 ) ) , val . value ( ) ) ;
profile - > UseRumble = Config - > getBool ( NESTED ( " Rumble.Enabled " , " " ) ) ;
profile - > RumbleStrength = Config - > getFloat ( NESTED ( " Rumble.Strength " , " " ) ) ;
profile - > UseGyro = Config - > getBool ( NESTED ( " Gyro.Enabled " , " " ) ) ;
for ( auto const & val : rawProfile [ " Mappings " ] . items ( ) ) {
device - > SetButtonMapping ( virtualSlot , std : : stoi ( val . key ( ) . substr ( 4 ) ) , val . value ( ) ) ;
}
break ;
case DEVICE_PROFILE_VERSION_V1 :
profile - > UseRumble = Config - > getBool ( NESTED ( " Rumble.Enabled " , " " ) ) ;
profile - > RumbleStrength = Config - > getFloat ( NESTED ( " Rumble.Strength " , " " ) ) ;
profile - > UseGyro = Config - > getBool ( NESTED ( " Gyro.Enabled " , " " ) ) ;
for ( auto const & val : rawProfile [ " AxisDeadzones " ] . items ( ) ) {
profile - > AxisDeadzones [ std : : stoi ( val . key ( ) ) ] = val . value ( ) ;
}
for ( auto const & val : rawProfile [ " AxisMinimumPress " ] . items ( ) ) {
profile - > AxisMinimumPress [ std : : stoi ( val . key ( ) ) ] = val . value ( ) ;
}
for ( auto const & val : rawProfile [ " GyroData " ] . items ( ) ) {
profile - > GyroData [ std : : stoi ( val . key ( ) ) ] = val . value ( ) ;
}
for ( auto const & val : rawProfile [ " Mappings " ] . items ( ) ) {
device - > SetButtonMapping ( virtualSlot , std : : stoi ( val . key ( ) . substr ( 4 ) ) , val . value ( ) ) ;
}
break ;
// Version is invalid.
default :
device - > CreateDefaultBinding ( virtualSlot ) ;
break ;
}
}
}
@ -194,10 +218,6 @@ namespace Ship {
Config - > setFloat ( NESTED ( " AxisDeadzones.%d " , key ) , val ) ;
}
for ( auto const & [ key , val ] : profile - > AxisSensitivities ) {
Config - > setFloat ( NESTED ( " AxisSensitivities.%d " , key ) , val ) ;
}
for ( auto const & [ key , val ] : profile - > AxisMinimumPress ) {
Config - > setFloat ( NESTED ( " AxisMinimumPress.%d " , key ) , val ) ;
}
@ -217,7 +237,7 @@ namespace Ship {
Config - > save ( ) ;
}
std : : shared_ptr < Controller > ControlDeck : : GetPhysicalDevice ( int deviceSlot ) {
std : : shared_ptr < Controller > ControlDeck : : GetPhysicalDevice ( int 32_t deviceSlot ) {
return physicalDevices [ deviceSlot ] ;
}
@ -225,7 +245,7 @@ namespace Ship {
return physicalDevices . size ( ) ;
}
int ControlDeck : : GetVirtualDevice ( in t slot ) {
int 32_t ControlDeck : : GetVirtualDevice ( in t32_ t slot ) {
return virtualDevices [ slot ] ;
}
@ -233,7 +253,7 @@ namespace Ship {
return virtualDevices . size ( ) ;
}
std : : shared_ptr < Controller > ControlDeck : : GetPhysicalDeviceFromVirtualSlot ( int slot ) {
std : : shared_ptr < Controller > ControlDeck : : GetPhysicalDeviceFromVirtualSlot ( int 32_t slot ) {
return GetPhysicalDevice ( GetVirtualDevice ( slot ) ) ;
}