diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 717a2e98..92d3bfc2 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2962,24 +2962,36 @@ void AiL::InitializeDefaultKeybinds(){ KEY_SCROLLLEFT.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); KEY_SCROLLLEFT.AddKeybind({ANALOG,static_cast(GPAxes::RX)}); + KEY_SCROLLLEFT.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLRIGHT.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); KEY_SCROLLRIGHT.AddKeybind({ANALOG,static_cast(GPAxes::RX)}); + KEY_SCROLLRIGHT.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLUP.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); KEY_SCROLLUP.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLUP.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLDOWN.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); KEY_SCROLLDOWN.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLDOWN.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLVERT.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLVERT_L.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); + KEY_SCROLLVERT_L.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLVERT_R.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLVERT_R.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); KEY_SCROLLHORZ_L.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); + KEY_SCROLLHORZ_L.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast(GPAxes::RX)}); + KEY_SCROLLHORZ.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLL.AddKeybind({KEY,ARROWS}); KEY_SCROLL.AddKeybind({ANALOG,static_cast(GPAxes::ALL)}); + KEY_SCROLL.AddKeybind({STEAM,Steam::SCROLL}); KEY_SHOULDER.AddKeybind({KEY,SHOULDER}); KEY_SHOULDER.AddKeybind({CONTROLLER,static_cast(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}); diff --git a/Adventures in Lestoria/InputHelper.cpp b/Adventures in Lestoria/InputHelper.cpp index 0a88727f..6b6881d0 100644 --- a/Adventures in Lestoria/InputHelper.cpp +++ b/Adventures in Lestoria/InputHelper.cpp @@ -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::optionalinput)->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>>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>>>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::vectorbuttonDescriptions; #pragma region Populate all buttons to display inputGroups.clear(); @@ -116,7 +130,7 @@ void InputHelper::Draw(){ } buttonImgs.push_back({}); - std::vector>&iconList=buttonImgs.back(); + std::vector>>&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::variantbutton:buttonList){ + for(auto&[iconScale,button]:buttonList){ if(std::holds_alternative(button)){ Decal*img=std::get(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(button)){ std::string label=std::get(button); diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp index 841ea8f8..a3d7d6ad 100644 --- a/Adventures in Lestoria/Key.cpp +++ b/Adventures in Lestoria/Key.cpp @@ -53,6 +53,7 @@ std::vectorInputGroup::menuInputGroups; std::vectorInputGroup::gameplayInputGroups; std::arrayInput::steamControllers; std::unordered_map>>Input::steamGameInputToOrigin; +std::unordered_map>>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::variantinput)->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::variantwidth*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::variantinput)->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::variantwidth*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); diff --git a/Adventures in Lestoria/Key.h b/Adventures in Lestoria/Key.h index ae668e52..8b879c2b 100644 --- a/Adventures in Lestoria/Key.h +++ b/Adventures in Lestoria/Key.h @@ -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>,STEAM_INPUT_MAX_COUNT>enumToActionName; static std::unordered_mapsteamIconToGameIcon; static std::unordered_map>>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>>steamGameInputToAnalogOrigin; static void Initialize(); static void UpdateSteamInput(); static std::arraysteamControllers; diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index a6bd2d32..d69be344 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -48,4 +48,6 @@ Add game file debug logging Automatically pause if controller is disconnected (while using a controller) -PS5 LED color support \ No newline at end of file +PS5 LED color support + +Manual Aim? \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 3c6caf1b..7f1adbf3 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -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 diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 9cee4a39..f336f87b 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ