FCohtmlInputPreprocessor

Inherits from IInputProcessor

Public Types

Name
using ECohtmlGamepadBehaviourOnFocusLostEGamepadBehaviour

Public Functions

Name
FCohtmlInputPreprocessor()
virtual~FCohtmlInputPreprocessor()
virtual voidTick(const float DeltaTime, FSlateApplication & SlateApp, TSharedRef< ICursor > Cursor)
virtual boolHandleKeyDownEvent(FSlateApplication & SlateApp, const FKeyEvent & InKeyEvent) override
virtual boolHandleKeyUpEvent(FSlateApplication & SlateApp, const FKeyEvent & InKeyEvent) override
virtual boolHandleAnalogInputEvent(FSlateApplication & SlateApp, const FAnalogInputEvent & InAnalogInputEvent) override
virtual boolHandleMouseMoveEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseButtonDownEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseButtonUpEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseButtonDoubleClickEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseWheelOrGestureEvent(FSlateApplication & SlateApp, const FPointerEvent & InWheelEvent, const FPointerEvent * InGestureEvent) override
virtual boolHandleMotionDetectedEvent(FSlateApplication & SlateApp, const FMotionEvent & MotionEvent) override
virtual boolHandleMouseEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent, cohtml::MouseEventData::EventType EventType)
virtual boolShouldHandleInput()
virtual boolShouldDiscardMouseData(FCohtmlInputWorldData & WorldData)
virtual boolGetWorldData(FCohtmlInputWorldData & WorldData)
virtual cohtml::MouseEventDataGetCoherentMouseData(const FPointerEvent & MouseEvent, cohtml::MouseEventData::EventType EventType)
virtual FVector2DGetScaledWindowPosition(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent, FCohtmlInputWorldData & WorldData)
virtual TOptional< FSceneViewProjectionData >GetProjectionData(APlayerController * PlayerController)
virtual FReplyHandleHUDInput(FVector2D ConstrainedPos, UCohtmlBaseComponent * Component, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyHandleInWorldInput(UCohtmlBaseComponent * Component, COHERENT_FLOAT_FVECTOR2 & UV, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyTryForwardInWorldInput(const FCohtmlInputWorldData & WorldData, FVector2D ViewportPositionVec2D, TOptional< FSceneViewProjectionData > ProjectionData, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyTryForwardHUDInput(UWorld * World, FVector2D ViewportPositionVec2D, TOptional< FSceneViewProjectionData > ProjectionData, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyTryForwardUMGInput(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent)
virtual FReplyDiscardViewFocus(cohtml::MouseEventData::EventType EventType, const FPointerEvent & MouseEvent)
virtual voidRefocusView(UCohtmlBaseComponent * NewFocusedView, const FPointerEvent & MouseEvent =FPointerEvent())
virtual boolShouldPropagateKeyInput(const FKeyEvent & KeyEvent)
virtual voidProcessKeyEvent(const FInputEvent & Event, cohtml::KeyEventData::EventType Type)
virtual voidOnFocusReceived(const FPointerEvent & MouseEvent)
virtual voidOnFocusLost(const FPointerEvent & MouseEvent)

Public Attributes

Name
EGamepadBehaviourGamepadBehaviourOnFocusLost
boolbShouldPropagateInput
boolbReceivesInput
boolbPropagateInputToUMG
TWeakObjectPtr< UCohtmlBaseComponent >FocusedComponent
TUniquePtr< FCohtmlInputPreprocessorIME >IMEManager

Public Types Documentation

using EGamepadBehaviour

using FCohtmlInputPreprocessor::EGamepadBehaviour =  ECohtmlGamepadBehaviourOnFocusLost;

Public Functions Documentation

function FCohtmlInputPreprocessor

FCohtmlInputPreprocessor()

function ~FCohtmlInputPreprocessor

inline virtual ~FCohtmlInputPreprocessor()

function Tick

inline virtual void Tick(
    const float DeltaTime,
    FSlateApplication & SlateApp,
    TSharedRef< ICursor > Cursor
)

function HandleKeyDownEvent

virtual bool HandleKeyDownEvent(
    FSlateApplication & SlateApp,
    const FKeyEvent & InKeyEvent
) override

Key down input

function HandleKeyUpEvent

virtual bool HandleKeyUpEvent(
    FSlateApplication & SlateApp,
    const FKeyEvent & InKeyEvent
) override

Key up input

function HandleAnalogInputEvent

virtual bool HandleAnalogInputEvent(
    FSlateApplication & SlateApp,
    const FAnalogInputEvent & InAnalogInputEvent
) override

Analog axis input

function HandleMouseMoveEvent

virtual bool HandleMouseMoveEvent(
    FSlateApplication & SlateApp,
    const FPointerEvent & MouseEvent
) override

Mouse movement input

function HandleMouseButtonDownEvent

virtual bool HandleMouseButtonDownEvent(
    FSlateApplication & SlateApp,
    const FPointerEvent & MouseEvent
) override

Mouse button press

function HandleMouseButtonUpEvent

virtual bool HandleMouseButtonUpEvent(
    FSlateApplication & SlateApp,
    const FPointerEvent & MouseEvent
) override

Mouse button release

function HandleMouseButtonDoubleClickEvent

virtual bool HandleMouseButtonDoubleClickEvent(
    FSlateApplication & SlateApp,
    const FPointerEvent & MouseEvent
) override

Mouse button double clicked.

function HandleMouseWheelOrGestureEvent

virtual bool HandleMouseWheelOrGestureEvent(
    FSlateApplication & SlateApp,
    const FPointerEvent & InWheelEvent,
    const FPointerEvent * InGestureEvent
) override

Mouse wheel input

function HandleMotionDetectedEvent

virtual bool HandleMotionDetectedEvent(
    FSlateApplication & SlateApp,
    const FMotionEvent & MotionEvent
) override

Called when a motion-driven device has new input

function HandleMouseEvent

virtual bool HandleMouseEvent(
    FSlateApplication & SlateApp,
    const FPointerEvent & MouseEvent,
    cohtml::MouseEventData::EventType EventType
)

The root method for all mouse-related event handling. Should return false if it is unable to handle the event, so that it can be passed to UE4.

function ShouldHandleInput

virtual bool ShouldHandleInput()

Decides if a given input should be handled at all - can be used to skip event forwarding entirely, for example when the game window is minimized or there is no active UI in the game

function ShouldDiscardMouseData

virtual bool ShouldDiscardMouseData(
    FCohtmlInputWorldData & WorldData
)

Some of the mouse data passing through the InputPreprocessor is not relevant to the UI, for example mouse events over buttons in the editor in PIE. You can use this method to leave such events to Unreal Engine to handle by returning true.

function GetWorldData

virtual bool GetWorldData(
    FCohtmlInputWorldData & WorldData
)

Parameters:

  • WorldData - An out parameter to fill with the data

Return: Should return false to signal that the data is unable to be obtained, for example due to the game world still initializing.

Returns the basic engine data (world, controler, etc.) needed for event forwarding

function GetCoherentMouseData

virtual cohtml::MouseEventData GetCoherentMouseData(
    const FPointerEvent & MouseEvent,
    cohtml::MouseEventData::EventType EventType
)

Parameters:

  • MouseEvent - The current UE4 mouse event

Return: A cohtml::MouseEventData representation of the current event

Transforms a UE4 event into a Cohtml mouse event. Some of the event properties might get changed later on during processing, but you can use this to fill in the most trivial ones via a simple mapping

function GetScaledWindowPosition

virtual FVector2D GetScaledWindowPosition(
    FSlateApplication & SlateApp,
    const FPointerEvent & MouseEvent,
    FCohtmlInputWorldData & WorldData
)

Return: A scaled representation of the current event coordinates

Scales the coordinates of the current UE4 event to local window coordinates, possibly scaled for DPI, letterboxing, etc.

function GetProjectionData

virtual TOptional< FSceneViewProjectionData > GetProjectionData(
    APlayerController * PlayerController
)

Return: A (possibly empty) projection data

Gets the projection data, which might be used later on during forwarding. Can be empty, for example if the viewport of player character are invalid.

function HandleHUDInput

virtual FReply HandleHUDInput(
    FVector2D ConstrainedPos,
    UCohtmlBaseComponent * Component,
    cohtml::MouseEventData & CoherentMouseData,
    const FPointerEvent & MouseEvent
)

Parameters:

  • ConstrainedPos - The event coordinates inside the constrained window view.
  • Component - The component which holds the view.
  • CoherentMouseData - The current event that would be sent to Cohtml.
  • MouseEvent - The original UE4 event that this HUD is handling.

Return: FReply that signifies if the event was handled or not.

Called for every HUD view found during forwarding

function HandleInWorldInput

virtual FReply HandleInWorldInput(
    UCohtmlBaseComponent * Component,
    COHERENT_FLOAT_FVECTOR2 & UV,
    cohtml::MouseEventData & CoherentMouseData,
    const FPointerEvent & MouseEvent
)

Parameters:

  • Component - The component which holds the view.
  • UV - The hit UV coordinates.
  • CoherentMouseData - The current event that would be sent to Cohtml.
  • MouseEvent - The original UE4 event that this HUD is handling.

Return: FReply that signifies if the event was handled or not.

Called for every in-world Gameface component found during forwarding

function TryForwardInWorldInput

virtual FReply TryForwardInWorldInput(
    const FCohtmlInputWorldData & WorldData,
    FVector2D ViewportPositionVec2D,
    TOptional< FSceneViewProjectionData > ProjectionData,
    cohtml::MouseEventData & CoherentMouseData,
    const FPointerEvent & MouseEvent
)

function TryForwardHUDInput

virtual FReply TryForwardHUDInput(
    UWorld * World,
    FVector2D ViewportPositionVec2D,
    TOptional< FSceneViewProjectionData > ProjectionData,
    cohtml::MouseEventData & CoherentMouseData,
    const FPointerEvent & MouseEvent
)

function TryForwardUMGInput

virtual FReply TryForwardUMGInput(
    FSlateApplication & SlateApp,
    const FPointerEvent & MouseEvent
)

function DiscardViewFocus

virtual FReply DiscardViewFocus(
    cohtml::MouseEventData::EventType EventType,
    const FPointerEvent & MouseEvent
)

Parameters:

  • EventType the type of the pointer event

Return: Whether or not we will handle the event.

Called during error states or when we have reason to believe that we might have to release the input focus back to the engine.

function RefocusView

virtual void RefocusView(
    UCohtmlBaseComponent * NewFocusedView,
    const FPointerEvent & MouseEvent =FPointerEvent()
)

Parameters:

  • NewFocusedView the Component which holds the view.

Called when a new view should become the focused one.

function ShouldPropagateKeyInput

virtual bool ShouldPropagateKeyInput(
    const FKeyEvent & KeyEvent
)

Parameters:

  • KeyEvent - The event currently being handled

Return: Should return true if we want to propagate the event to the engine.

Called at the end of keyboard/gamepad input handling, to determine whether or not we will forward the event to the game. Will be called regardless of whether or not any Cohtml view handled the event.

function ProcessKeyEvent

virtual void ProcessKeyEvent(
    const FInputEvent & Event,
    cohtml::KeyEventData::EventType Type
)

Parameters:

  • Event - The UE4 event currently being handled
  • Type - The type of the event

Called on every key event to process it. This mainly consists of just forwarding the input to the currently focused component, if any.

function OnFocusReceived

virtual void OnFocusReceived(
    const FPointerEvent & MouseEvent
)

Parameters:

  • MouseEvent - The event that caused the focus to change.

Called when the focus switches from the Game to the UI

function OnFocusLost

virtual void OnFocusLost(
    const FPointerEvent & MouseEvent
)

Parameters:

  • MouseEvent - The event that caused the focus to change.

Called when the focus switches from the UI to the Game.

Public Attributes Documentation

variable GamepadBehaviourOnFocusLost

EGamepadBehaviour GamepadBehaviourOnFocusLost = EGamepadBehaviour::CohtmlResetState;

variable bShouldPropagateInput

bool bShouldPropagateInput = true;

variable bReceivesInput

bool bReceivesInput = true;

variable bPropagateInputToUMG

bool bPropagateInputToUMG = false;

variable FocusedComponent

TWeakObjectPtr< UCohtmlBaseComponent > FocusedComponent;

variable IMEManager

TUniquePtr< FCohtmlInputPreprocessorIME > IMEManager;