Implement analog control detection. Invert Y axis for right analog stick because steam wants it to be inverted by default? Release Build 8293.
This commit is contained in:
		
							parent
							
								
									3be02315a5
								
							
						
					
					
						commit
						02ef18826d
					
				| @ -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
 | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| @ -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::array<InputHandle_t,16>steamControllers; | ||||
| 	static uint8_t activeSteamControllerIndex; | ||||
| 	static uint8_t controllerCount; | ||||
| 	static std::vector<Steam::SteamInput>leftStickActionSets; | ||||
| 	static std::vector<Steam::SteamInput>rightStickActionSets; | ||||
| 	static void LoadSteamButtonIcons(); | ||||
| public: | ||||
| 	Input(InputType type,int key); | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user