Version number updated to 1.0.0. Handle analog input hints for steam icons. Release Build 8348.

mac-build
sigonasr2 8 months ago
parent 78227b9c4c
commit f18cba0b97
  1. 12
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 42
      Adventures in Lestoria/InputHelper.cpp
  3. 47
      Adventures in Lestoria/Key.cpp
  4. 2
      Adventures in Lestoria/Key.h
  5. 4
      Adventures in Lestoria/TODO.txt
  6. 8
      Adventures in Lestoria/Version.h
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -2962,24 +2962,36 @@ void AiL::InitializeDefaultKeybinds(){
KEY_SCROLLLEFT.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLLEFT.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)});
KEY_SCROLLLEFT.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLRIGHT.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLRIGHT.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)});
KEY_SCROLLRIGHT.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLUP.AddKeybind({ANALOG,static_cast<int>(GPAxes::LY)});
KEY_SCROLLUP.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
KEY_SCROLLUP.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLDOWN.AddKeybind({ANALOG,static_cast<int>(GPAxes::LY)});
KEY_SCROLLDOWN.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
KEY_SCROLLDOWN.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast<int>(GPAxes::LY)});
KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
KEY_SCROLLVERT.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLVERT_L.AddKeybind({ANALOG,static_cast<int>(GPAxes::LY)});
KEY_SCROLLVERT_L.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLVERT_R.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
KEY_SCROLLVERT_R.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLHORZ_L.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLHORZ_L.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)});
KEY_SCROLLHORZ.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLL.AddKeybind({KEY,ARROWS});
KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::ALL)});
KEY_SCROLL.AddKeybind({STEAM,Steam::SCROLL});
KEY_SHOULDER.AddKeybind({KEY,SHOULDER});
KEY_SHOULDER.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::SHOULDER)});
KEY_SHOULDER.AddKeybind({STEAM,Steam::FAST_SCROLL_UP});
KEY_SHOULDER.AddKeybind({STEAM,Steam::FAST_SCROLL_DOWN});
KEY_FACEDOWN.AddKeybind({STEAM,Steam::FAST_SCROLL_DOWN});
KEY_FACEDOWN.AddKeybind({STEAM,Steam::FAST_SCROLL_UP});

@ -45,6 +45,8 @@ INCLUDE_game
INCLUDE_GFX
INCLUDE_WINDOW_SIZE
using IconScale=float;
InputHelper::InputHelper(){}
void InputHelper::Initialize(MenuInputGroups&inputGroups){
@ -62,13 +64,25 @@ const InputType InputHelper::InputMode()const{
void InputHelper::Draw(){
InputType mode=InputMode();
if(mode==CONTROLLER&&SteamInput())mode=STEAM;
if(mode==MOUSE)mode=KEY; //We're going to make it so the keyboard controls always show up when navigating using a mouse.
auto OriginalGameIcon=[](std::optional<Input>input)->bool{
if(input.has_value()){
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(input.value().key)).second[0];
EInputActionOrigin analogAction=Input::steamGameInputToAnalogOrigin.at(Steam::SteamInput(input.value().key)).second[0];
return Input::steamIconToGameIcon.count(action)+Input::steamIconToGameIcon.count(analogAction);
}
return true;
};
switch(mode){
case STEAM:
case CONTROLLER:
case KEY:{
float buttonImgWidth=0.f;
float buttonDescriptionWidth=0.f;
std::vector<std::vector<std::variant<Decal*,std::string>>>buttonImgs; //Store decals for buttons that actually have images, and strings for buttons that have labels. One button can have multiple icons. Store them all together.
std::vector<std::vector<std::pair<IconScale,std::variant<Decal*,std::string>>>>buttonImgs; //Store decals for buttons that actually have images, and strings for buttons that have labels. One button can have multiple icons. Store them all together.
std::vector<std::string>buttonDescriptions;
#pragma region Populate all buttons to display
inputGroups.clear();
@ -116,7 +130,7 @@ void InputHelper::Draw(){
}
buttonImgs.push_back({});
std::vector<std::variant<Decal*,std::string>>&iconList=buttonImgs.back();
std::vector<std::pair<IconScale,std::variant<Decal*,std::string>>>&iconList=buttonImgs.back();
for(InputGroup&group:inputGroupsToCheck){
if(Menu::UsingMouseNavigation()){
@ -125,14 +139,14 @@ void InputHelper::Draw(){
if(displayName.length()>0&&primaryKey.has_value()){
if(primaryKey.value().HasExtendedIcons()){//This means it follows the specialized icon controller schemes, now pick based on these icons.
buttonImgWidth+=primaryKey.value().GetIcon(GameSettings::GetIconType()).Sprite()->width+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal());
iconList.push_back({1.f,primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal()});
}else
if(primaryKey.value().HasIcon()){
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetIcon().Decal());
iconList.push_back({1.f,primaryKey.value().GetIcon().Decal()});
}else{
buttonImgWidth+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetDisplayName());
iconList.push_back({1.f,primaryKey.value().GetDisplayName()});
}
}
}
@ -142,14 +156,18 @@ void InputHelper::Draw(){
if(displayName.length()>0&&primaryKey.has_value()){
if(primaryKey.value().HasExtendedIcons()){//This means it follows the specialized icon controller schemes, now pick based on these icons.
buttonImgWidth+=primaryKey.value().GetIcon(GameSettings::GetIconType()).Sprite()->width+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal());
iconList.push_back({1.f,primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal()});
}else
if(primaryKey.value().HasIcon()){
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetIcon().Decal());
float alteredIconScale=1.f;
if(mode==STEAM&&!OriginalGameIcon(primaryKey))alteredIconScale/=2.85f; //They are initially 32x32.
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width*alteredIconScale+"Interface.InputHelperSpacing"_I;
iconList.push_back({alteredIconScale,primaryKey.value().GetIcon().Decal()});
}else{
buttonImgWidth+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetDisplayName());
iconList.push_back({1.f,primaryKey.value().GetDisplayName()});
}
}
}
@ -176,11 +194,11 @@ void InputHelper::Draw(){
#pragma region Draw all button inputs and descriptions
float xOffset="Interface.InputHelperSpacing"_I;
for(size_t index=0;auto&buttonList:buttonImgs){
for(std::variant<Decal*,std::string>button:buttonList){
for(auto&[iconScale,button]:buttonList){
if(std::holds_alternative<Decal*>(button)){
Decal*img=std::get<Decal*>(button);
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height)-4},img);
xOffset+=img->sprite->width+"Interface.InputHelperSpacing"_I;
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height*iconScale)-4},img,vf2d{1.f,1.f}*iconScale);
xOffset+=img->sprite->width*iconScale+"Interface.InputHelperSpacing"_I;
}else
if(std::holds_alternative<std::string>(button)){
std::string label=std::get<std::string>(button);

@ -53,6 +53,7 @@ std::vector<std::string>InputGroup::menuInputGroups;
std::vector<std::string>InputGroup::gameplayInputGroups;
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::steamGameInputToAnalogOrigin;
uint8_t Input::activeSteamControllerIndex;
uint8_t Input::controllerCount{0};
@ -165,7 +166,7 @@ void Input::Initialize(){
enumToActionName[i][Steam::DOWN]={"Down",{}};
enumToActionName[i][Steam::LEFT]={"Left",{}};
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_DOWN]={"Fast_Scroll_Down",{}};
}
@ -212,8 +213,11 @@ void Input::UpdateSteamInput(){
for(auto&[input,data]:enumToActionName[activeSteamControllerIndex]){
InputDigitalActionHandle_t inputHnd=SteamInput()->GetDigitalActionHandle(data.first.c_str());
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.
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;
case KEY:
case MOUSE:
case CONTROLLER:{
case CONTROLLER:
case STEAM:{
//Doesn't return analog inputs. No-op.
}break;
default:{
@ -572,7 +577,8 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
auto OriginalGameIcon=[](std::optional<Input>input)->bool{
if(input.has_value()){
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;
};
@ -596,9 +602,7 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
if(input.HasIcon()){
float alteredIconScale=1.f;
if(type==STEAM&&!OriginalGameIcon(input)){
alteredIconScale/=2.85f; //They are initially 32x32.
}
if(type==STEAM&&!OriginalGameIcon(input))alteredIconScale/=2.85f; //They are initially 32x32.
buttonImgSize.x+=input.GetIcon().Sprite()->width*alteredIconScale*textScale.x+"Interface.InputHelperSpacing"_F;
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{
if(input.has_value()){
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;
};
@ -737,9 +742,7 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
if(primaryKey.value().HasIcon()){
float alteredIconScale=1.f;
if(type==STEAM&&!OriginalGameIcon(primaryKey)){
alteredIconScale/=2.85f; //They are initially 32x32.
}
if(type==STEAM&&!OriginalGameIcon(primaryKey))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));
@ -860,7 +863,9 @@ std::string Input::GetProperIconName(std::string currentIconName)const{
const bool Input::HasIcon()const{
if(type==STEAM){
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;
}
@ -871,10 +876,22 @@ const bool Input::HasExtendedIcons()const{
const Renderable&Input::GetIcon()const{
if(type==STEAM){
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).second[0];
if(steamIconToGameIcon.count(action)){
return GFX.at(GetProperIconName(steamIconToGameIcon[action]));
}else{
return GFX.at(SteamInput()->GetGlyphPNGForActionOrigin(action,k_ESteamInputGlyphSize_Small,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)){
return GFX.at(GetProperIconName(steamIconToGameIcon[action]));
}else{
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);

@ -98,6 +98,7 @@ using NumOfOrigins=uint8_t;
class Input{
friend class InputGroup;
friend class State_MainMenu;
friend class InputHelper;
friend class AiL;
InputType type;
int key; //This will be interpreted differently depending on input type.
@ -106,6 +107,7 @@ class Input{
static std::array<std::unordered_map<Steam::SteamInput,std::pair<std::string,HWButton>>,STEAM_INPUT_MAX_COUNT>enumToActionName;
static std::unordered_map<EInputActionOrigin,std::string>steamIconToGameIcon;
static std::unordered_map<Steam::SteamInput,std::pair<NumOfOrigins,std::array<EInputActionOrigin,STEAM_INPUT_MAX_ORIGINS>>>steamGameInputToOrigin; //Store the origins that steam knows about inside either the gameplay or menu 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.
static std::unordered_map<Steam::SteamInput,std::pair<NumOfOrigins,std::array<EInputActionOrigin,STEAM_INPUT_MAX_ORIGINS>>>steamGameInputToAnalogOrigin;
static void Initialize();
static void UpdateSteamInput();
static std::array<InputHandle_t,16>steamControllers;

@ -48,4 +48,6 @@ Add game file debug logging
Automatically pause if controller is disconnected (while using a controller)
PS5 LED color support
PS5 LED color support
Manual Aim?

@ -36,10 +36,10 @@ All rights reserved.
*/
#pragma endregion
#pragma once
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 1
#define VERSION_BUILD 8339
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_PATCH 0
#define VERSION_BUILD 8348
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save