Added icon displays for Steam. Removed the menu/gameplay action set split and condensed everything into one simple configuration. Release Build 8324.
This commit is contained in:
@@ -47,17 +47,17 @@ INCLUDE_GFX
|
||||
|
||||
bool Input::usingGamepad;
|
||||
uint64_t Input::ingameControlsHandle{0};
|
||||
uint64_t Input::menuControlsHandle{0};
|
||||
uint8_t activeSteamControllerIndex{0};
|
||||
safemap<std::string,InputGroup*>InputGroup::menuNamesToInputGroups;
|
||||
std::vector<std::string>InputGroup::menuInputGroups;
|
||||
std::vector<std::string>InputGroup::gameplayInputGroups;
|
||||
std::array<InputHandle_t,16>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;
|
||||
uint8_t Input::activeSteamControllerIndex;
|
||||
uint8_t Input::controllerCount{0};
|
||||
|
||||
std::vector<Steam::SteamInput>Input::leftStickActionSets{Steam::MOVE};
|
||||
std::vector<Steam::SteamInput>Input::rightStickActionSets{Steam::MANUAL_AIM,Steam::SCROLL};
|
||||
std::vector<Steam::SteamInput>Input::rightStickActionSets{Steam::SCROLL};
|
||||
|
||||
std::array<std::unordered_map<Steam::SteamInput,std::pair<std::string,HWButton>>,16>Input::enumToActionName;
|
||||
std::unordered_map<EInputActionOrigin,std::string>Input::steamIconToGameIcon{
|
||||
@@ -144,9 +144,8 @@ Input::Input(InputType type,int key)
|
||||
:type(type),key(key){}
|
||||
|
||||
void Input::Initialize(){
|
||||
for(int i=0;i<16;i++){
|
||||
for(int i=0;i<STEAM_INPUT_MAX_COUNT;i++){
|
||||
enumToActionName[i][Steam::MOVE]={"Move",{}};
|
||||
enumToActionName[i][Steam::MANUAL_AIM]={"Manual Aim",{}};
|
||||
enumToActionName[i][Steam::BASIC_ATTACK]={"Basic_Attack",{}};
|
||||
enumToActionName[i][Steam::DEFENSIVE]={"Defensive",{}};
|
||||
enumToActionName[i][Steam::MENU_PAUSE]={"Menu/Pause",{}};
|
||||
@@ -196,8 +195,6 @@ void Input::UpdateSteamInput(){
|
||||
HWButton prevState=data.second;
|
||||
InputDigitalActionHandle_t inputHnd=SteamInput()->GetDigitalActionHandle(data.first.c_str());
|
||||
InputDigitalActionData_t buttonData=SteamInput()->GetDigitalActionData(steamControllers[i],inputHnd);
|
||||
if(!buttonData.bActive)continue; //Ignore inputs that are not active.
|
||||
if(buttonData.bActive){std::cout<<input<<" is active"<<std::endl;}
|
||||
data.second.bPressed=data.second.bReleased=false;
|
||||
|
||||
if(!data.second.bHeld&&buttonData.bState){
|
||||
@@ -211,6 +208,14 @@ void Input::UpdateSteamInput(){
|
||||
data.second.bHeld=buttonData.bState;
|
||||
}
|
||||
}
|
||||
if(controllerCount>0){ //Setup display icons for steam controllers.
|
||||
for(auto&[input,data]:enumToActionName[activeSteamControllerIndex]){
|
||||
InputDigitalActionHandle_t inputHnd=SteamInput()->GetDigitalActionHandle(data.first.c_str());
|
||||
InputDigitalActionData_t buttonData=SteamInput()->GetDigitalActionData(steamControllers[activeSteamControllerIndex],inputHnd);
|
||||
//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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,6 +363,7 @@ float Input::Analog(){
|
||||
float axisVal=GetAnalogStickVal(i,input,Axis::X);
|
||||
if(axisVal!=0.f){
|
||||
usingGamepad=true;
|
||||
activeSteamControllerIndex=i;
|
||||
return axisVal;
|
||||
}
|
||||
}
|
||||
@@ -367,6 +373,7 @@ float Input::Analog(){
|
||||
float axisVal=GetAnalogStickVal(i,input,Axis::Y);
|
||||
if(axisVal!=0.f){
|
||||
usingGamepad=true;
|
||||
activeSteamControllerIndex=i;
|
||||
return axisVal;
|
||||
}
|
||||
}
|
||||
@@ -376,6 +383,7 @@ float Input::Analog(){
|
||||
float axisVal=GetAnalogStickVal(i,input,Axis::X);
|
||||
if(axisVal!=0.f){
|
||||
usingGamepad=true;
|
||||
activeSteamControllerIndex=i;
|
||||
return axisVal;
|
||||
}
|
||||
}
|
||||
@@ -385,6 +393,7 @@ float Input::Analog(){
|
||||
float axisVal=GetAnalogStickVal(i,input,Axis::Y);
|
||||
if(axisVal!=0.f){
|
||||
usingGamepad=true;
|
||||
activeSteamControllerIndex=i;
|
||||
return axisVal;
|
||||
}
|
||||
}
|
||||
@@ -410,6 +419,10 @@ float Input::Analog(){
|
||||
}
|
||||
|
||||
std::string Input::GetDisplayName()const{
|
||||
if(type==STEAM){
|
||||
return std::format("STEAM:{}",key);
|
||||
}
|
||||
if(!GenericKey::keyLiteral.count({type,key}))return "";
|
||||
return GenericKey::keyLiteral.at({type,key}).displayName;
|
||||
}
|
||||
|
||||
@@ -652,7 +665,13 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
|
||||
void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedView*const,ViewPort*const>renderer,const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type,vf2d textScale)const{
|
||||
std::optional<Input>primaryKey;
|
||||
switch(type){
|
||||
case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break;
|
||||
case CONTROLLER:{
|
||||
if(SteamInput()){
|
||||
primaryKey=GetPrimaryKey(STEAM);
|
||||
}else{
|
||||
primaryKey=GetPrimaryKey(CONTROLLER);
|
||||
}
|
||||
}break;
|
||||
case MOUSE:primaryKey=GetPrimaryKey(MOUSE);break;
|
||||
default:primaryKey=GetPrimaryKey(KEY);break;
|
||||
}
|
||||
@@ -660,7 +679,7 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
vf2d buttonImgSize{};
|
||||
std::vector<std::variant<Decal*,std::string>>buttonImgs;
|
||||
|
||||
if(type!=CONTROLLER&&type!=MOUSE){
|
||||
if(type!=STEAM&&type!=CONTROLLER&&type!=MOUSE){
|
||||
for(const Input&input:keyOrder){
|
||||
if(input.GetType()==MOUSE){
|
||||
if(input.HasExtendedIcons()){
|
||||
@@ -688,10 +707,15 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
buttonImgs.push_back(primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal());
|
||||
}else
|
||||
if(primaryKey.value().HasIcon()){
|
||||
buttonImgSize.x+=primaryKey.value().GetIcon().Sprite()->width*textScale.x+"Interface.InputHelperSpacing"_F;
|
||||
buttonImgSize.y=std::max(buttonImgSize.y,float(primaryKey.value().GetIcon().Sprite()->height));
|
||||
float alteredIconScale=1.f;
|
||||
|
||||
if(type==STEAM)alteredIconScale/=2.85f; //They are initially 32x32.
|
||||
|
||||
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));
|
||||
buttonImgs.push_back(primaryKey.value().GetIcon().Decal());
|
||||
}else{
|
||||
}else
|
||||
{
|
||||
buttonImgSize.x+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x*textScale.x+"Interface.InputHelperSpacing"_F;
|
||||
buttonImgSize.y=std::max(buttonImgSize.y,float(game->GetTextSizeProp(primaryKey.value().GetDisplayName()).y)+"Interface.InputHelperSpacing"_F);
|
||||
buttonImgs.push_back(primaryKey.value().GetDisplayName());
|
||||
@@ -706,7 +730,10 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
|
||||
#pragma region Render Macro
|
||||
#define Render(rendererType) \
|
||||
std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,textScale,{255,255,255,alpha});
|
||||
float alteredIconScale=1.f; \
|
||||
\
|
||||
if(type==STEAM)alteredIconScale/=2.85f; /*They are initially 32x32.*/ \
|
||||
std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,alteredIconScale*textScale,{255,255,255,alpha});
|
||||
#pragma endregion
|
||||
if(std::holds_alternative<AiL*const>(renderer)){
|
||||
Render(AiL);
|
||||
@@ -775,12 +802,21 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
}
|
||||
|
||||
const bool Input::HasIcon()const{
|
||||
if(type==STEAM){
|
||||
return Input::steamGameInputToOrigin.count(Steam::SteamInput(key))&&
|
||||
Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).first>0;
|
||||
}
|
||||
return GenericKey::keyLiteral.at({type,key}).iconName.length()>0;
|
||||
}
|
||||
const bool Input::HasExtendedIcons()const{
|
||||
if(type==STEAM)return false;
|
||||
return GenericKey::keyLiteral.at({type,key}).iconName.length()>0&&GenericKey::keyLiteral.at({type,key}).iconName2.length()>0&&GenericKey::keyLiteral.at({type,key}).iconName3.length()>0;
|
||||
}
|
||||
const Renderable&Input::GetIcon()const{
|
||||
if(type==STEAM){
|
||||
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).second[0];
|
||||
return GFX.at(SteamInput()->GetGlyphPNGForActionOrigin(action,k_ESteamInputGlyphSize_Small,0));
|
||||
}
|
||||
return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName);
|
||||
}
|
||||
const Renderable&Input::GetIcon(IconType type)const{
|
||||
|
||||
Reference in New Issue
Block a user