diff --git a/Source/StevesUEHelpers/Private/StevesGameSubsystem.cpp b/Source/StevesUEHelpers/Private/StevesGameSubsystem.cpp index 9a0b0a7..dcb9dd8 100644 --- a/Source/StevesUEHelpers/Private/StevesGameSubsystem.cpp +++ b/Source/StevesUEHelpers/Private/StevesGameSubsystem.cpp @@ -182,7 +182,8 @@ UPaperSprite* UStevesGameSubsystem::GetInputImageSpriteFromAction(const FName& N const EInputMode LastInput = GetLastInputModeUsed(PlayerIdx); const EInputMode LastButtonInput = GetLastInputButtonPressed(PlayerIdx); - const auto Preferred = GetPreferedActionOrAxisMapping(GS_TempActionMap, Name, DevicePreference, LastInput, LastButtonInput); + const EInputMode LastAxisInput = GetLastInputAxisMoved(PlayerIdx); + const auto Preferred = GetPreferedActionOrAxisMapping(GS_TempActionMap, Name, DevicePreference, LastInput, LastButtonInput, LastAxisInput); if (Preferred) { return GetInputImageSpriteFromKey(Preferred->Key, PlayerIdx, Theme); @@ -206,7 +207,8 @@ UPaperSprite* UStevesGameSubsystem::GetInputImageSpriteFromAxis(const FName& Nam const EInputMode LastInput = GetLastInputModeUsed(PlayerIdx); const EInputMode LastButtonInput = GetLastInputButtonPressed(PlayerIdx); - const auto Preferred = GetPreferedActionOrAxisMapping(GS_TempAxisMap, Name, DevicePreference, LastInput, LastButtonInput); + const EInputMode LastAxisInput = GetLastInputAxisMoved(PlayerIdx); + const auto Preferred = GetPreferedActionOrAxisMapping(GS_TempAxisMap, Name, DevicePreference, LastInput, LastButtonInput, LastAxisInput); if (Preferred) { return GetInputImageSpriteFromKey(Preferred->Key, PlayerIdx, Theme); diff --git a/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp b/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp index 7e9623e..24420af 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp +++ b/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp @@ -231,6 +231,10 @@ protected: { Params.DevicePreference = EInputImageDevicePreference::Gamepad_Keyboard_Mouse_Button; } + else if (PreferStr->Equals("gmkaxis", ESearchCase::IgnoreCase)) + { + Params.DevicePreference = EInputImageDevicePreference::Gamepad_Keyboard_Mouse_Axis; + } } // Look up the initial sprite here diff --git a/Source/StevesUEHelpers/Private/StevesUI/StevesUI.h b/Source/StevesUEHelpers/Private/StevesUI/StevesUI.h index 2227ce5..de0b41a 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/StevesUI.h +++ b/Source/StevesUEHelpers/Private/StevesUI/StevesUI.h @@ -30,7 +30,8 @@ template const T* GetPreferedActionOrAxisMapping(const TArray& AllMappings, const FName& Name, EInputImageDevicePreference DevicePreference, EInputMode LastInputDevice, - EInputMode LastButtonInputDevice) + EInputMode LastButtonInputDevice, + EInputMode LastAxisInputDevice) { const T* MouseMapping = nullptr; const T* KeyboardMapping = nullptr; @@ -43,7 +44,7 @@ const T* GetPreferedActionOrAxisMapping(const TArray& AllMappings, const FNam { GamepadMapping = &ActionMap; } - else if (ActionMap.Key.IsMouseButton()) + else if (ActionMap.Key.IsMouseButton()) // registers true for mouse axes too { MouseMapping = &ActionMap; } @@ -78,6 +79,10 @@ const T* GetPreferedActionOrAxisMapping(const TArray& AllMappings, const FNam // Use the latest button press Preferred = (MouseMapping && LastButtonInputDevice == EInputMode::Mouse) ? MouseMapping : KeyboardMapping; break; + case EInputImageDevicePreference::Gamepad_Keyboard_Mouse_Axis: + // Use the latest button press + Preferred = (MouseMapping && LastAxisInputDevice == EInputMode::Mouse) ? MouseMapping : KeyboardMapping; + break; default: break; } diff --git a/Source/StevesUEHelpers/Public/StevesHelperCommon.h b/Source/StevesUEHelpers/Public/StevesHelperCommon.h index 0208d4d..cdcf30e 100644 --- a/Source/StevesUEHelpers/Public/StevesHelperCommon.h +++ b/Source/StevesUEHelpers/Public/StevesHelperCommon.h @@ -60,6 +60,8 @@ enum class EInputImageDevicePreference : uint8 /// Gamepad first, then mouse, then keyboard - this is usually best for axes Gamepad_Mouse_Keyboard UMETA(DisplayName="Gamepad, Mouse, Keyboard"), /// Gamepad first, then whichever of mouse or keyboard last had a BUTTON pressed (ignore axes) - this is usually best for actions (buttons) - Gamepad_Keyboard_Mouse_Button UMETA(DisplayName="Gamepad, Most Recent Button Keyboard/Mouse") + Gamepad_Keyboard_Mouse_Button UMETA(DisplayName="Gamepad, Most Recent Button Keyboard/Mouse"), + /// Gamepad first, then whichever of mouse or keyboard last had an AXIS moved (ignore buttons) - this is usually best for directionals + Gamepad_Keyboard_Mouse_Axis UMETA(DisplayName="Gamepad, Most Recent Axis Keyboard/Mouse") }; diff --git a/doc/RichTextInputDecorator.md b/doc/RichTextInputDecorator.md index 2ba1629..2715cc0 100644 --- a/doc/RichTextInputDecorator.md +++ b/doc/RichTextInputDecorator.md @@ -94,7 +94,8 @@ Alternatives are: * `prefer="gkm"`: prefer Gamepad, then Keyboard, then Mouse * `prefer="gmk"`: prefer Gamepad, then Mouse, then Keyboard -* `prefer="gmkbutton"`: prefer Gamepad, then whichever of Mouse ot Keyboard last had a button pressed +* `prefer="gmkbutton"`: prefer Gamepad, then whichever of Mouse or Keyboard last had a button pressed +* `prefer="gmkaxis"`: prefer Gamepad, then whichever of Mouse or Keyboard last had an axis moved ## See Also