@ -53,6 +53,7 @@ std::vector<std::string>InputGroup::menuInputGroups;
std : : vector < std : : string > InputGroup : : gameplayInputGroups ;
std : : vector < std : : string > InputGroup : : gameplayInputGroups ;
std : : array < InputHandle_t , STEAM_INPUT_MAX_COUNT > Input : : steamControllers ;
std : : array < InputHandle_t , STEAM_INPUT_MAX_COUNT > Input : : steamControllers ;
std : : unordered_map < Steam : : SteamInput , std : : pair < NumOfOrigins , std : : array < EInputActionOrigin , STEAM_INPUT_MAX_ORIGINS > > > Input : : steamGameInputToOrigin ;
std : : unordered_map < Steam : : SteamInput , std : : pair < NumOfOrigins , std : : array < EInputActionOrigin , STEAM_INPUT_MAX_ORIGINS > > > Input : : steamGameInputToOrigin ;
std : : unordered_map < Steam : : SteamInput , std : : pair < NumOfOrigins , std : : array < EInputActionOrigin , STEAM_INPUT_MAX_ORIGINS > > > Input : : steamGameInputToAnalogOrigin ;
uint8_t Input : : activeSteamControllerIndex ;
uint8_t Input : : activeSteamControllerIndex ;
uint8_t Input : : controllerCount { 0 } ;
uint8_t Input : : controllerCount { 0 } ;
@ -165,7 +166,7 @@ void Input::Initialize(){
enumToActionName [ i ] [ Steam : : DOWN ] = { " Down " , { } } ;
enumToActionName [ i ] [ Steam : : DOWN ] = { " Down " , { } } ;
enumToActionName [ i ] [ Steam : : LEFT ] = { " Left " , { } } ;
enumToActionName [ i ] [ Steam : : LEFT ] = { " Left " , { } } ;
enumToActionName [ i ] [ Steam : : RIGHT ] = { " Right " , { } } ;
enumToActionName [ i ] [ Steam : : RIGHT ] = { " Right " , { } } ;
enumToActionName [ i ] [ Steam : : LOCK_UNLOCK_ACC ] = { " Lock/Unlock Accessory " , { } } ;
enumToActionName [ i ] [ Steam : : LOCK_UNLOCK_ACC ] = { " Lock/Unlock_ Accessory " , { } } ;
enumToActionName [ i ] [ Steam : : FAST_SCROLL_UP ] = { " Fast_Scroll_Up " , { } } ;
enumToActionName [ i ] [ Steam : : FAST_SCROLL_UP ] = { " Fast_Scroll_Up " , { } } ;
enumToActionName [ i ] [ Steam : : FAST_SCROLL_DOWN ] = { " Fast_Scroll_Down " , { } } ;
enumToActionName [ i ] [ Steam : : FAST_SCROLL_DOWN ] = { " Fast_Scroll_Down " , { } } ;
}
}
@ -212,8 +213,11 @@ void Input::UpdateSteamInput(){
for ( auto & [ input , data ] : enumToActionName [ activeSteamControllerIndex ] ) {
for ( auto & [ input , data ] : enumToActionName [ activeSteamControllerIndex ] ) {
InputDigitalActionHandle_t inputHnd = SteamInput ( ) - > GetDigitalActionHandle ( data . first . c_str ( ) ) ;
InputDigitalActionHandle_t inputHnd = SteamInput ( ) - > GetDigitalActionHandle ( data . first . c_str ( ) ) ;
InputDigitalActionData_t buttonData = SteamInput ( ) - > GetDigitalActionData ( steamControllers [ activeSteamControllerIndex ] , inputHnd ) ;
InputDigitalActionData_t buttonData = SteamInput ( ) - > GetDigitalActionData ( steamControllers [ activeSteamControllerIndex ] , inputHnd ) ;
InputAnalogActionHandle_t analogInputHnd = SteamInput ( ) - > GetAnalogActionHandle ( data . first . c_str ( ) ) ;
InputAnalogActionData_t analogButtonData = SteamInput ( ) - > GetAnalogActionData ( steamControllers [ activeSteamControllerIndex ] , analogInputHnd ) ;
//Store the origins that steam knows about inside the gameplay input arrays provided. These are pairs where the first item is the number of origins for this input and the second item is the array itself.
//Store the origins that steam knows about inside the gameplay input arrays provided. These are pairs where the first item is the number of origins for this input and the second item is the array itself.
steamGameInputToOrigin [ input ] . first = SteamInput ( ) - > GetDigitalActionOrigins ( steamControllers [ activeSteamControllerIndex ] , ingameControlsHandle , inputHnd , steamGameInputToOrigin [ input ] . second . data ( ) ) ;
steamGameInputToOrigin [ input ] . first = SteamInput ( ) - > GetDigitalActionOrigins ( steamControllers [ activeSteamControllerIndex ] , ingameControlsHandle , inputHnd , steamGameInputToOrigin [ input ] . second . data ( ) ) ;
steamGameInputToAnalogOrigin [ input ] . first = SteamInput ( ) - > GetAnalogActionOrigins ( steamControllers [ activeSteamControllerIndex ] , ingameControlsHandle , analogInputHnd , steamGameInputToAnalogOrigin [ input ] . second . data ( ) ) ;
}
}
}
}
}
}
@ -408,7 +412,8 @@ float Input::Analog(){
} break ;
} break ;
case KEY :
case KEY :
case MOUSE :
case MOUSE :
case CONTROLLER : {
case CONTROLLER :
case STEAM : {
//Doesn't return analog inputs. No-op.
//Doesn't return analog inputs. No-op.
} break ;
} break ;
default : {
default : {
@ -572,7 +577,8 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
auto OriginalGameIcon = [ ] ( std : : optional < Input > input ) - > bool {
auto OriginalGameIcon = [ ] ( std : : optional < Input > input ) - > bool {
if ( input . has_value ( ) ) {
if ( input . has_value ( ) ) {
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( input . value ( ) . key ) ) . second [ 0 ] ;
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( input . value ( ) . key ) ) . second [ 0 ] ;
return Input : : steamIconToGameIcon . count ( action ) ;
EInputActionOrigin analogAction = Input : : steamGameInputToAnalogOrigin . at ( Steam : : SteamInput ( input . value ( ) . key ) ) . second [ 0 ] ;
return Input : : steamIconToGameIcon . count ( action ) + Input : : steamIconToGameIcon . count ( analogAction ) ;
}
}
return true ;
return true ;
} ;
} ;
@ -596,9 +602,7 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
if ( input . HasIcon ( ) ) {
if ( input . HasIcon ( ) ) {
float alteredIconScale = 1.f ;
float alteredIconScale = 1.f ;
if ( type = = STEAM & & ! OriginalGameIcon ( input ) ) {
if ( type = = STEAM & & ! OriginalGameIcon ( input ) ) alteredIconScale / = 2.85f ; //They are initially 32x32.
alteredIconScale / = 2.85f ; //They are initially 32x32.
}
buttonImgSize . x + = input . GetIcon ( ) . Sprite ( ) - > width * alteredIconScale * textScale . x + " Interface.InputHelperSpacing " _F ;
buttonImgSize . x + = input . GetIcon ( ) . Sprite ( ) - > width * alteredIconScale * textScale . x + " Interface.InputHelperSpacing " _F ;
buttonImgSize . y = std : : max ( buttonImgSize . y , float ( input . GetIcon ( ) . Sprite ( ) - > height * alteredIconScale ) ) ;
buttonImgSize . y = std : : max ( buttonImgSize . y , float ( input . GetIcon ( ) . Sprite ( ) - > height * alteredIconScale ) ) ;
@ -686,7 +690,8 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
auto OriginalGameIcon = [ ] ( std : : optional < Input > input ) - > bool {
auto OriginalGameIcon = [ ] ( std : : optional < Input > input ) - > bool {
if ( input . has_value ( ) ) {
if ( input . has_value ( ) ) {
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( input . value ( ) . key ) ) . second [ 0 ] ;
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( input . value ( ) . key ) ) . second [ 0 ] ;
return Input : : steamIconToGameIcon . count ( action ) ;
EInputActionOrigin analogAction = Input : : steamGameInputToAnalogOrigin . at ( Steam : : SteamInput ( input . value ( ) . key ) ) . second [ 0 ] ;
return Input : : steamIconToGameIcon . count ( action ) + Input : : steamIconToGameIcon . count ( analogAction ) ;
}
}
return true ;
return true ;
} ;
} ;
@ -737,9 +742,7 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
if ( primaryKey . value ( ) . HasIcon ( ) ) {
if ( primaryKey . value ( ) . HasIcon ( ) ) {
float alteredIconScale = 1.f ;
float alteredIconScale = 1.f ;
if ( type = = STEAM & & ! OriginalGameIcon ( primaryKey ) ) {
if ( type = = STEAM & & ! OriginalGameIcon ( primaryKey ) ) alteredIconScale / = 2.85f ; //They are initially 32x32.
alteredIconScale / = 2.85f ; //They are initially 32x32.
}
buttonImgSize . x + = primaryKey . value ( ) . GetIcon ( ) . Sprite ( ) - > width * alteredIconScale * textScale . x + " Interface.InputHelperSpacing " _F ;
buttonImgSize . x + = primaryKey . value ( ) . GetIcon ( ) . Sprite ( ) - > width * alteredIconScale * textScale . x + " Interface.InputHelperSpacing " _F ;
buttonImgSize . y = std : : max ( buttonImgSize . y , float ( primaryKey . value ( ) . GetIcon ( ) . Sprite ( ) - > height * alteredIconScale ) ) ;
buttonImgSize . y = std : : max ( buttonImgSize . y , float ( primaryKey . value ( ) . GetIcon ( ) . Sprite ( ) - > height * alteredIconScale ) ) ;
@ -860,7 +863,9 @@ std::string Input::GetProperIconName(std::string currentIconName)const{
const bool Input : : HasIcon ( ) const {
const bool Input : : HasIcon ( ) const {
if ( type = = STEAM ) {
if ( type = = STEAM ) {
return Input : : steamGameInputToOrigin . count ( Steam : : SteamInput ( key ) ) & &
return Input : : steamGameInputToOrigin . count ( Steam : : SteamInput ( key ) ) & &
Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( key ) ) . first > 0 ;
Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( key ) ) . first > 0 | |
Input : : steamGameInputToAnalogOrigin . count ( Steam : : SteamInput ( key ) ) & &
Input : : steamGameInputToAnalogOrigin . at ( Steam : : SteamInput ( key ) ) . first > 0 ;
}
}
return GenericKey : : keyLiteral . at ( { type , key } ) . iconName . length ( ) > 0 ;
return GenericKey : : keyLiteral . at ( { type , key } ) . iconName . length ( ) > 0 ;
}
}
@ -871,11 +876,23 @@ const bool Input::HasExtendedIcons()const{
const Renderable & Input : : GetIcon ( ) const {
const Renderable & Input : : GetIcon ( ) const {
if ( type = = STEAM ) {
if ( type = = STEAM ) {
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( key ) ) . second [ 0 ] ;
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( key ) ) . second [ 0 ] ;
EInputActionOrigin analogAction = Input : : steamGameInputToAnalogOrigin . at ( Steam : : SteamInput ( key ) ) . second [ 0 ] ;
if ( Input : : steamGameInputToOrigin . count ( Steam : : SteamInput ( key ) ) & &
Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( key ) ) . first > 0 ) {
if ( steamIconToGameIcon . count ( action ) ) {
if ( steamIconToGameIcon . count ( action ) ) {
return GFX . at ( GetProperIconName ( steamIconToGameIcon [ action ] ) ) ;
return GFX . at ( GetProperIconName ( steamIconToGameIcon [ action ] ) ) ;
} else {
} else {
return GFX . at ( SteamInput ( ) - > GetGlyphPNGForActionOrigin ( action , k_ESteamInputGlyphSize_Small , 0 ) ) ;
return GFX . at ( SteamInput ( ) - > GetGlyphPNGForActionOrigin ( action , k_ESteamInputGlyphSize_Small , 0 ) ) ;
}
}
} else
if ( Input : : steamGameInputToAnalogOrigin . count ( Steam : : SteamInput ( key ) ) & &
Input : : steamGameInputToAnalogOrigin . at ( Steam : : SteamInput ( key ) ) . first > 0 ) {
if ( steamIconToGameIcon . count ( analogAction ) ) {
return GFX . at ( GetProperIconName ( steamIconToGameIcon [ analogAction ] ) ) ;
} else {
return GFX . at ( SteamInput ( ) - > GetGlyphPNGForActionOrigin ( analogAction , k_ESteamInputGlyphSize_Small , 0 ) ) ;
}
}
}
}
return GFX . at ( GenericKey : : keyLiteral . at ( { type , key } ) . iconName ) ;
return GFX . at ( GenericKey : : keyLiteral . at ( { type , key } ) . iconName ) ;
}
}