diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp index 78efab88..7b5247ed 100644 --- a/Adventures in Lestoria/Key.cpp +++ b/Adventures in Lestoria/Key.cpp @@ -56,6 +56,9 @@ std::arrayInput::steamControllers; uint8_t Input::activeSteamControllerIndex; uint8_t Input::controllerCount{0}; +std::vectorInput::leftStickActionSets{Steam::MOVE}; +std::vectorInput::rightStickActionSets{Steam::MANUAL_AIM,Steam::SCROLL}; + std::array>,16>Input::enumToActionName; std::unordered_mapInput::steamIconToGameIcon{ {k_EInputActionOrigin_SteamController_A,"themes/button_d_xb.png"}, @@ -154,7 +157,6 @@ void Input::Initialize(){ enumToActionName[i][Steam::ITEM_1]={"Item_1",{}}; enumToActionName[i][Steam::ITEM_2]={"Item_2",{}}; enumToActionName[i][Steam::ITEM_3]={"Item_3",{}}; - enumToActionName[i][Steam::NAVIGATE]={"Navigate",{}}; enumToActionName[i][Steam::SCROLL]={"Scroll",{}}; enumToActionName[i][Steam::CONFIRM]={"Confirm",{}}; enumToActionName[i][Steam::BACK]={"Back",{}}; @@ -328,32 +330,68 @@ float Input::Analog(){ } } }else{ + + auto GetAnalogStickVal=[&](uint8_t controller,Steam::SteamInput input,Axis axis){ + InputAnalogActionHandle_t inputHnd=SteamInput()->GetAnalogActionHandle(enumToActionName[controller][input].first.c_str()); + InputAnalogActionData_t data=SteamInput()->GetAnalogActionData(steamControllers[controller],inputHnd); + if(data.bActive){ + switch(axis){ + case Axis::X:{ + return data.x; + }break; + case Axis::Y:{ + return -data.y; //Invert the Y axis since Steam makes the right stick be a "camera look around" stick by default with inverted controls. + }break; + default:{ + ERR(std::format("WARNING! Invalid axis type given: {}! THIS SHOULD NOT BE HAPPENING!",int(axis))); + } + } + } + return 0.f; + }; + for(int i=0;i(key)){ case GPAxes::LX:{ - InputDigitalActionHandle_t inputHnd=SteamInput()->GetDigitalActionHandle(""); + for(Steam::SteamInput input:leftStickActionSets){ + float axisVal=GetAnalogStickVal(i,input,Axis::X); + if(axisVal!=0.f){ + usingGamepad=true; + return axisVal; + } + } }break; case GPAxes::LY:{ - + for(Steam::SteamInput input:leftStickActionSets){ + float axisVal=GetAnalogStickVal(i,input,Axis::Y); + if(axisVal!=0.f){ + usingGamepad=true; + return axisVal; + } + } }break; case GPAxes::RX:{ - + for(Steam::SteamInput input:rightStickActionSets){ + float axisVal=GetAnalogStickVal(i,input,Axis::X); + if(axisVal!=0.f){ + usingGamepad=true; + return axisVal; + } + } }break; case GPAxes::RY:{ - - }break; - case GPAxes::TL:{ - - }break; - case GPAxes::TR:{ - - }break; - case GPAxes::DX:{ - - }break; - case GPAxes::DY:{ - + for(Steam::SteamInput input:rightStickActionSets){ + float axisVal=GetAnalogStickVal(i,input,Axis::Y); + if(axisVal!=0.f){ + usingGamepad=true; + return axisVal; + } + } }break; + case GPAxes::TL:{}break;//Unused. No-op + case GPAxes::TR:{}break;//Unused. No-op + case GPAxes::DX:{}break;//Unused. No-op + case GPAxes::DY:{}break;//Unused. No-op } } } diff --git a/Adventures in Lestoria/Key.h b/Adventures in Lestoria/Key.h index 275e0038..9ef8c72d 100644 --- a/Adventures in Lestoria/Key.h +++ b/Adventures in Lestoria/Key.h @@ -59,6 +59,11 @@ enum InputType{ ANALOG, }; +enum class Axis{ + X, + Y, +}; + namespace Steam{ enum SteamInput{ //Gameplay Inputs @@ -75,7 +80,6 @@ namespace Steam{ ITEM_2, ITEM_3, //Menu Inputs - NAVIGATE, //This is the left stick analog input. Whenever we use this, we assume left stick is being used. SCROLL, //This is the right stick analog input. Whenever we use this, we assume right stick is being used. CONFIRM, BACK, @@ -109,6 +113,8 @@ class Input{ static std::arraysteamControllers; static uint8_t activeSteamControllerIndex; static uint8_t controllerCount; + static std::vectorleftStickActionSets; + static std::vectorrightStickActionSets; static void LoadSteamButtonIcons(); public: Input(InputType type,int key); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 56831a41..7027449f 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 5 #define VERSION_PATCH 1 -#define VERSION_BUILD 8290 +#define VERSION_BUILD 8293 #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 8deccdde..f073058a 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ