mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Add device preference option to prefer whichever device axis moved last
This commit is contained in:
parent
cff7282ae5
commit
fc958d2ca0
@ -182,7 +182,8 @@ UPaperSprite* UStevesGameSubsystem::GetInputImageSpriteFromAction(const FName& N
|
|||||||
|
|
||||||
const EInputMode LastInput = GetLastInputModeUsed(PlayerIdx);
|
const EInputMode LastInput = GetLastInputModeUsed(PlayerIdx);
|
||||||
const EInputMode LastButtonInput = GetLastInputButtonPressed(PlayerIdx);
|
const EInputMode LastButtonInput = GetLastInputButtonPressed(PlayerIdx);
|
||||||
const auto Preferred = GetPreferedActionOrAxisMapping<FInputActionKeyMapping>(GS_TempActionMap, Name, DevicePreference, LastInput, LastButtonInput);
|
const EInputMode LastAxisInput = GetLastInputAxisMoved(PlayerIdx);
|
||||||
|
const auto Preferred = GetPreferedActionOrAxisMapping<FInputActionKeyMapping>(GS_TempActionMap, Name, DevicePreference, LastInput, LastButtonInput, LastAxisInput);
|
||||||
if (Preferred)
|
if (Preferred)
|
||||||
{
|
{
|
||||||
return GetInputImageSpriteFromKey(Preferred->Key, PlayerIdx, Theme);
|
return GetInputImageSpriteFromKey(Preferred->Key, PlayerIdx, Theme);
|
||||||
@ -206,7 +207,8 @@ UPaperSprite* UStevesGameSubsystem::GetInputImageSpriteFromAxis(const FName& Nam
|
|||||||
|
|
||||||
const EInputMode LastInput = GetLastInputModeUsed(PlayerIdx);
|
const EInputMode LastInput = GetLastInputModeUsed(PlayerIdx);
|
||||||
const EInputMode LastButtonInput = GetLastInputButtonPressed(PlayerIdx);
|
const EInputMode LastButtonInput = GetLastInputButtonPressed(PlayerIdx);
|
||||||
const auto Preferred = GetPreferedActionOrAxisMapping<FInputAxisKeyMapping>(GS_TempAxisMap, Name, DevicePreference, LastInput, LastButtonInput);
|
const EInputMode LastAxisInput = GetLastInputAxisMoved(PlayerIdx);
|
||||||
|
const auto Preferred = GetPreferedActionOrAxisMapping<FInputAxisKeyMapping>(GS_TempAxisMap, Name, DevicePreference, LastInput, LastButtonInput, LastAxisInput);
|
||||||
if (Preferred)
|
if (Preferred)
|
||||||
{
|
{
|
||||||
return GetInputImageSpriteFromKey(Preferred->Key, PlayerIdx, Theme);
|
return GetInputImageSpriteFromKey(Preferred->Key, PlayerIdx, Theme);
|
||||||
|
@ -231,6 +231,10 @@ protected:
|
|||||||
{
|
{
|
||||||
Params.DevicePreference = EInputImageDevicePreference::Gamepad_Keyboard_Mouse_Button;
|
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
|
// Look up the initial sprite here
|
||||||
|
@ -30,7 +30,8 @@ template <typename T>
|
|||||||
const T* GetPreferedActionOrAxisMapping(const TArray<T>& AllMappings, const FName& Name,
|
const T* GetPreferedActionOrAxisMapping(const TArray<T>& AllMappings, const FName& Name,
|
||||||
EInputImageDevicePreference DevicePreference,
|
EInputImageDevicePreference DevicePreference,
|
||||||
EInputMode LastInputDevice,
|
EInputMode LastInputDevice,
|
||||||
EInputMode LastButtonInputDevice)
|
EInputMode LastButtonInputDevice,
|
||||||
|
EInputMode LastAxisInputDevice)
|
||||||
{
|
{
|
||||||
const T* MouseMapping = nullptr;
|
const T* MouseMapping = nullptr;
|
||||||
const T* KeyboardMapping = nullptr;
|
const T* KeyboardMapping = nullptr;
|
||||||
@ -43,7 +44,7 @@ const T* GetPreferedActionOrAxisMapping(const TArray<T>& AllMappings, const FNam
|
|||||||
{
|
{
|
||||||
GamepadMapping = &ActionMap;
|
GamepadMapping = &ActionMap;
|
||||||
}
|
}
|
||||||
else if (ActionMap.Key.IsMouseButton())
|
else if (ActionMap.Key.IsMouseButton()) // registers true for mouse axes too
|
||||||
{
|
{
|
||||||
MouseMapping = &ActionMap;
|
MouseMapping = &ActionMap;
|
||||||
}
|
}
|
||||||
@ -78,6 +79,10 @@ const T* GetPreferedActionOrAxisMapping(const TArray<T>& AllMappings, const FNam
|
|||||||
// Use the latest button press
|
// Use the latest button press
|
||||||
Preferred = (MouseMapping && LastButtonInputDevice == EInputMode::Mouse) ? MouseMapping : KeyboardMapping;
|
Preferred = (MouseMapping && LastButtonInputDevice == EInputMode::Mouse) ? MouseMapping : KeyboardMapping;
|
||||||
break;
|
break;
|
||||||
|
case EInputImageDevicePreference::Gamepad_Keyboard_Mouse_Axis:
|
||||||
|
// Use the latest button press
|
||||||
|
Preferred = (MouseMapping && LastAxisInputDevice == EInputMode::Mouse) ? MouseMapping : KeyboardMapping;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,8 @@ enum class EInputImageDevicePreference : uint8
|
|||||||
/// Gamepad first, then mouse, then keyboard - this is usually best for axes
|
/// Gamepad first, then mouse, then keyboard - this is usually best for axes
|
||||||
Gamepad_Mouse_Keyboard UMETA(DisplayName="Gamepad, Mouse, Keyboard"),
|
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 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")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,7 +94,8 @@ Alternatives are:
|
|||||||
|
|
||||||
* `prefer="gkm"`: prefer Gamepad, then Keyboard, then Mouse
|
* `prefer="gkm"`: prefer Gamepad, then Keyboard, then Mouse
|
||||||
* `prefer="gmk"`: prefer Gamepad, then Mouse, then Keyboard
|
* `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
|
## See Also
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user