|
|
|
@ -56,6 +56,9 @@ std::array<InputHandle_t,16>Input::steamControllers; |
|
|
|
|
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::array<std::unordered_map<Steam::SteamInput,std::pair<std::string,HWButton>>,16>Input::enumToActionName; |
|
|
|
|
std::unordered_map<EInputActionOrigin,std::string>Input::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<controllerCount;i++){ |
|
|
|
|
switch(static_cast<GPAxes>(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
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|