Add new input device processor
This commit is contained in:
63
Source/Integration/InputDeviceTracker.h
Normal file
63
Source/Integration/InputDeviceTracker.h
Normal file
@@ -0,0 +1,63 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InputDeviceTracker.h
|
||||
//
|
||||
// Tracks the most recently used input device, classifying
|
||||
// it as keyboard/mouse, Xbox gamepad, or PlayStation
|
||||
// gamepad. The subsystem registers a Slate input
|
||||
// preprocessor that watches button-down events; analog
|
||||
// and mouse-move events are ignored. Read the current
|
||||
// classification via the static accessor.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Subsystems/GameInstanceSubsystem.h"
|
||||
#include "Framework/Application/IInputProcessor.h"
|
||||
#include "Common.h"
|
||||
#include "InputDeviceTracker.generated.h"
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FInputDeviceTrackerProcessor
|
||||
//
|
||||
// Slate input preprocessor. Updates the device-class
|
||||
// static on each button-down event. Never consumes
|
||||
// events (always returns false).
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class FInputDeviceTrackerProcessor : public IInputProcessor
|
||||
{
|
||||
public:
|
||||
virtual void Tick(const float DeltaTime, FSlateApplication& SlateApp, TSharedRef<ICursor> Cursor) override {}
|
||||
virtual bool HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& KeyEvent) override;
|
||||
virtual bool HandleMouseButtonDownEvent(FSlateApplication& SlateApp, const FPointerEvent& MouseEvent) override;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// UlxInputDeviceTracker
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UlxInputDeviceTracker : public UGameInstanceSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void Deinitialize() override;
|
||||
|
||||
// Returns the classification of the most recently used
|
||||
// input device. Defaults to KeyboardMouse until the
|
||||
// first gamepad button event is observed.
|
||||
//
|
||||
static ElxControllerType GetLastControllerType();
|
||||
|
||||
private:
|
||||
TSharedPtr<FInputDeviceTrackerProcessor> Processor;
|
||||
};
|
||||
Reference in New Issue
Block a user