@ -60,85 +60,87 @@ uint8_t Input::controllerCount{0};
std : : vector < Steam : : SteamInput > Input : : leftStickActionSets { Steam : : MOVE } ;
std : : vector < Steam : : SteamInput > Input : : rightStickActionSets { Steam : : SCROLL } ;
std : : array < std : : unordered_map < Steam : : SteamInput , std : : pair < std : : string , HWButton > > , 16 > Input : : enumToActionName ;
std : : array < std : : unordered_map < Steam : : SteamInput , std : : pair < std : : string , HWButton > > , STEAM_INPUT_MAX_COUNT > Input : : enumToActionName ;
std : : unordered_map < EInputActionOrigin , std : : string > Input : : steamIconToGameIcon {
{ k_EInputActionOrigin_SteamController_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_XBox360_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_Switch_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_S , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_SteamController_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_XBox360_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_Switch_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_W , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_SteamController_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_XBox360_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_Switch_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_E , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_SteamController_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_XBox360_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_Switch_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_N , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_SteamController_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_PS4_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_XBox360_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_Switch_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_SteamDeck_L1 , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_SteamController_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_PS4_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_XBox360_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_Switch_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_SteamDeck_R1 , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_SteamController_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_PS4_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBox360_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_Switch_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamDeck_R2_SoftPull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamController_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_PS4_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBox360_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_Switch_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamDeck_R2 , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamController_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_PS4_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBox360_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_Switch_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_SteamDeck_L2_SoftPull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_SteamController_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_PS4_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBox360_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_Switch_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_SteamDeck_L2 , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_PS4_X , " themes/button_d_ps.png " } ,
{ k_EInputActionOrigin_PS4_Circle , " themes/button_r_ps.png " } ,
{ k_EInputActionOrigin_PS4_Triangle , " themes/button_u_ps.png " } ,
{ k_EInputActionOrigin_PS4_Square , " themes/button_l_ps.png " } ,
{ k_EInputActionOrigin_SteamController_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS4_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS4_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBox360_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBox360_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_Switch_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_Switch_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS5_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS5_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_SteamDeck_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_SteamDeck_RightStick_Move , " themes/button_analogstick.png " } ,
# ifndef __EMSCRIPTEN__
{ k_EInputActionOrigin_SteamController_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_XBox360_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_Switch_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_S , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_A , " themes/button_d_xb.png " } ,
{ k_EInputActionOrigin_SteamController_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_XBox360_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_Switch_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_W , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_B , " themes/button_r_xb.png " } ,
{ k_EInputActionOrigin_SteamController_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_XBox360_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_Switch_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_E , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_X , " themes/button_l_xb.png " } ,
{ k_EInputActionOrigin_SteamController_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_XBoxOne_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_XBox360_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_Switch_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_Switch_JoyConButton_N , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_SteamDeck_Y , " themes/button_u_xb.png " } ,
{ k_EInputActionOrigin_SteamController_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_PS4_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_XBox360_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_Switch_LeftBumper , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_SteamDeck_L1 , " themes/button_l1.png " } ,
{ k_EInputActionOrigin_SteamController_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_PS4_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_XBox360_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_Switch_RightBumper , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_SteamDeck_R1 , " themes/button_r1.png " } ,
{ k_EInputActionOrigin_SteamController_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_PS4_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBox360_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_Switch_RightTrigger_Pull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamDeck_R2_SoftPull , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamController_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_PS4_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_XBox360_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_Switch_RightTrigger_Click , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamDeck_R2 , " themes/button_r2.png " } ,
{ k_EInputActionOrigin_SteamController_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_PS4_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBox360_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_Switch_LeftTrigger_Pull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_SteamDeck_L2_SoftPull , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_SteamController_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_PS4_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_XBox360_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_Switch_LeftTrigger_Click , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_SteamDeck_L2 , " themes/button_l2.png " } ,
{ k_EInputActionOrigin_PS4_X , " themes/button_d_ps.png " } ,
{ k_EInputActionOrigin_PS4_Circle , " themes/button_r_ps.png " } ,
{ k_EInputActionOrigin_PS4_Triangle , " themes/button_u_ps.png " } ,
{ k_EInputActionOrigin_PS4_Square , " themes/button_l_ps.png " } ,
{ k_EInputActionOrigin_SteamController_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS4_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS4_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBoxOne_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBoxOne_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBox360_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_XBox360_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_Switch_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_Switch_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS5_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_PS5_RightStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_SteamDeck_LeftStick_Move , " themes/button_analogstick.png " } ,
{ k_EInputActionOrigin_SteamDeck_RightStick_Move , " themes/button_analogstick.png " } ,
# endif
} ;
Input : : Input ( InputType type , int key )
@ -174,24 +176,26 @@ void Input::Initialize(){
void Input : : LoadSteamButtonIcons ( ) {
GFX . Unlock ( ) ;
for ( int i = 1 ; i < k_EInputActionOrigin_Count ; i + + ) {
const char * imageName { SteamInput ( ) - > GetGlyphPNGForActionOrigin ( EInputActionOrigin ( i ) , k_ESteamInputGlyphSize_Small , 0U ) } ;
if ( imageName ! = nullptr ) {
std : : string loadImage { imageName } ;
if ( loadImage . length ( ) > 0 & & ( ! GFX . count ( loadImage ) | | GFX . at ( loadImage ) . Decal ( ) = = nullptr ) ) {
LOG ( std : : format ( " Loading steam image {} " , loadImage ) ) ;
if ( ! GFX . count ( loadImage ) ) GFX [ loadImage ] ;
if ( GFX . at ( loadImage ) . Load ( loadImage ) ! = rcode : : OK ) {
LOG ( std : : format ( " WARNING! Failed to load steam image {}! " , loadImage ) ) ;
# ifndef __EMSCRIPTEN__
for ( int i = 1 ; i < k_EInputActionOrigin_Count ; i + + ) {
const char * imageName { SteamInput ( ) - > GetGlyphPNGForActionOrigin ( EInputActionOrigin ( i ) , k_ESteamInputGlyphSize_Small , 0U ) } ;
if ( imageName ! = nullptr ) {
std : : string loadImage { imageName } ;
if ( loadImage . length ( ) > 0 & & ( ! GFX . count ( loadImage ) | | GFX . at ( loadImage ) . Decal ( ) = = nullptr ) ) {
LOG ( std : : format ( " Loading steam image {} " , loadImage ) ) ;
if ( ! GFX . count ( loadImage ) ) GFX [ loadImage ] ;
if ( GFX . at ( loadImage ) . Load ( loadImage ) ! = rcode : : OK ) {
LOG ( std : : format ( " WARNING! Failed to load steam image {}! " , loadImage ) ) ;
}
}
}
}
}
# endif
GFX . SetInitialized ( ) ;
}
void Input : : UpdateSteamInput ( ) {
if ( SteamInput ( ) ) {
STEAMINPUT (
uint8_t prevControllerCount = controllerCount ;
controllerCount = SteamInput ( ) - > GetConnectedControllers ( steamControllers . data ( ) ) ;
if ( controllerCount < prevControllerCount & & Menu : : stack . size ( ) = = 0 & & GameState : : STATE = = GameState : : states [ States : : GAME_RUN ] ) Menu : : OpenMenu ( MenuType : : PAUSE ) ; //We unplugged a controller so we will automatically pause the game.
@ -224,7 +228,7 @@ void Input::UpdateSteamInput(){
steamGameInputToAnalogOrigin [ input ] . first = SteamInput ( ) - > GetAnalogActionOrigins ( steamControllers [ activeSteamControllerIndex ] , ingameControlsHandle , analogInputHnd , steamGameInputToAnalogOrigin [ input ] . second . data ( ) ) ;
}
}
}
)
}
bool Input : : Pressed ( ) {
@ -238,14 +242,16 @@ bool Input::Pressed(){
inputPressed = game - > GetMouse ( key ) . bPressed ;
} break ;
case CONTROLLER : {
if ( ! SteamInput ( ) ) {
STEAMINPUT ( ) else {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected & & gamepad - > getButton ( static_cast < GPButtons > ( key ) ) . bPressed ) inputPressed = true ;
}
}
} break ;
case STEAM : {
if ( enumToActionName [ activeSteamControllerIndex ] [ Steam : : SteamInput ( key ) ] . second . bPressed ) inputPressed = true ;
STEAMINPUT (
if ( enumToActionName [ activeSteamControllerIndex ] [ Steam : : SteamInput ( key ) ] . second . bPressed ) inputPressed = true ;
)
} break ;
case ANALOG : {
//An analog input can never be "pressed". No-op.
@ -255,7 +261,7 @@ bool Input::Pressed(){
}
}
if ( inputPressed ) {
usingGamepad = type = = CONTROLLER | | type = = STEAM ;
SetUsingGamepad ( type = = CONTROLLER | | type = = STEAM ) ;
return true ;
}
return false ;
@ -272,14 +278,16 @@ bool Input::Held(){
inputHeld | = game - > GetMouse ( key ) . bHeld ;
} break ;
case CONTROLLER : {
if ( ! SteamInput ( ) ) {
STEAMINPUT ( ) else {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) inputHeld | = gamepad - > getButton ( static_cast < GPButtons > ( key ) ) . bHeld ;
}
}
} break ;
case STEAM : {
inputHeld | = enumToActionName [ activeSteamControllerIndex ] [ Steam : : SteamInput ( key ) ] . second . bHeld ;
STEAMINPUT (
inputHeld | = enumToActionName [ activeSteamControllerIndex ] [ Steam : : SteamInput ( key ) ] . second . bHeld ;
)
} break ;
case ANALOG : {
//An analog input can never be "held". No-op.
@ -289,7 +297,7 @@ bool Input::Held(){
}
}
if ( inputHeld ) {
usingGamepad = type = = CONTROLLER | | type = = STEAM ;
SetUsingGamepad ( type = = CONTROLLER | | type = = STEAM ) ;
return true ;
}
return false ;
@ -306,14 +314,16 @@ bool Input::Released(){
inputReleased | = game - > GetMouse ( key ) . bReleased ;
} break ;
case CONTROLLER : {
if ( ! SteamInput ( ) ) {
STEAMINPUT ( ) else {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) inputReleased | = gamepad - > getButton ( static_cast < GPButtons > ( key ) ) . bReleased ;
}
}
} break ;
case STEAM : {
inputReleased | = enumToActionName [ activeSteamControllerIndex ] [ Steam : : SteamInput ( key ) ] . second . bReleased ;
STEAMINPUT (
inputReleased | = enumToActionName [ activeSteamControllerIndex ] [ Steam : : SteamInput ( key ) ] . second . bReleased ;
)
} break ;
case ANALOG : {
//An analog input can never be "released". No-op.
@ -323,7 +333,7 @@ bool Input::Released(){
}
}
if ( inputReleased ) {
usingGamepad = type = = CONTROLLER | | type = = STEAM ;
SetUsingGamepad ( type = = CONTROLLER | | type = = STEAM ) ;
return true ;
}
return false ;
@ -333,18 +343,7 @@ float Input::Analog(){
if ( ! game - > IsFocused ( ) ) return false ;
switch ( type ) {
case ANALOG : {
if ( ! SteamInput ( ) ) {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) {
float axisVal = gamepad - > getAxis ( static_cast < GPAxes > ( key ) ) ;
if ( axisVal ! = 0.f ) {
usingGamepad = true ;
return axisVal ;
}
}
}
} else {
STEAMINPUT (
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 ) ;
@ -412,6 +411,16 @@ float Input::Analog(){
case GPAxes : : DY : { } break ; //Unused. No-op
}
}
) else {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) {
float axisVal = gamepad - > getAxis ( static_cast < GPAxes > ( key ) ) ;
if ( axisVal ! = 0.f ) {
usingGamepad = true ;
return axisVal ;
}
}
}
}
} break ;
case KEY :
@ -702,10 +711,10 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
switch ( type ) {
case CONTROLLER : {
if ( SteamInput ( ) ) {
STEAMINPUT (
primaryKey = GetPrimaryKey ( STEAM ) ;
type = STEAM ;
} else {
) else {
primaryKey = GetPrimaryKey ( CONTROLLER ) ;
}
} break ;
@ -879,24 +888,26 @@ const bool Input::HasExtendedIcons()const{
}
const Renderable & Input : : GetIcon ( ) const {
if ( type = = STEAM ) {
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( key ) ) . second [ 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 ) ) ;
# ifndef __EMSCRIPTEN__
EInputActionOrigin action = Input : : steamGameInputToOrigin . at ( Steam : : SteamInput ( key ) ) . second [ 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 ) ) ;
}
}
}
# endif
}
return GFX . at ( GenericKey : : keyLiteral . at ( { type , key } ) . iconName ) ;
}
@ -1060,14 +1071,14 @@ const bool Input::UsingGamepad(){
const bool Input : : AxesActive ( ) {
float xAxis = 0.f , yAxis = 0.f ;
if ( SteamInput ( ) ) {
STEAMINPUT (
if ( fabs ( game - > KEY_SCROLLHORZ_R . Analog ( ) ) > 0.f ) {
return true ;
}
if ( fabs ( game - > KEY_SCROLLVERT_R . Analog ( ) ) > 0.f ) {
return true ;
}
} else {
) else {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) {
if ( fabs ( gamepad - > getAxis ( GPAxes : : RX ) ) > 0.f ) {
@ -1085,9 +1096,9 @@ const bool Input::AxesActive(){
void Input : : StartVibration ( const bool override ) {
if ( ! GameSettings : : RumbleEnabled ( override ) ) return ;
if ( UsingGamepad ( ) ) {
if ( SteamInput ( ) ) {
STEAMINPUT (
SteamInput ( ) - > TriggerVibration ( steamControllers [ activeSteamControllerIndex ] , std : : numeric_limits < unsigned short > : : max ( ) , std : : numeric_limits < unsigned short > : : max ( ) ) ;
} else {
) else {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) {
gamepad - > startVibration ( ) ;
@ -1097,11 +1108,11 @@ void Input::StartVibration(const bool override){
}
}
void Input : : StopVibration ( ) {
if ( SteamInput ( ) ) {
STEAMINPUT (
for ( int i = 0 ; i < controllerCount ; i + + ) {
SteamInput ( ) - > TriggerVibration ( steamControllers [ i ] , 0U , 0U ) ;
}
} else {
) else {
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) {
gamepad - > stopVibration ( ) ;
@ -1224,9 +1235,9 @@ const bool InputEngageGroup::GetLabelVisible()const{
}
void Input : : SetLightbar ( const Pixel col ) {
if ( SteamInput ( ) ) {
STEAMINPUT (
for ( int i = 0 ; i < controllerCount ; i + + ) {
SteamInput ( ) - > SetLEDColor ( steamControllers [ i ] , col . r , col . g , col . b , 0 ) ;
}
}
)
}