Enhanced Raw Input 1.0
Enhanced Raw Input for Unreal Engine
Loading...
Searching...
No Matches
EnhancedRawInput.h
1
2// (c) 2025 by Lemontree Softworks - All Rights Reserved.
3
4#pragma once
5
6#include "CoreMinimal.h"
7#include "Modules/ModuleManager.h"
8#include "IInputDeviceModule.h"
9#include "IInputDevice.h"
10#include "GenericPlatform/GenericApplicationMessageHandler.h"
11
12constexpr auto MaxEnhancedRawInputAxis = 8;
13constexpr auto MaxEnhancedRawInputButtons = 128;
14constexpr auto MaxEnhancedRawInputPovs = 4;
15
17DECLARE_DELEGATE_RetVal_TwoParams(bool, FEnhancedRawInputDataDelegate, int32 /*DataSize*/, const struct tagRAWINPUT* /*Data */);
18
20class IEnhancedRawInput : public IInputDevice
21{
22public:
23 explicit IEnhancedRawInput(const TSharedRef<FGenericApplicationMessageHandler> &InMessageHandler);
24 virtual ~IEnhancedRawInput() override {};
27 virtual void SetBindings(const FString InterfaceName) {}
28
33 virtual void SetAxisBinding(const FString InterfaceName, const int32 AxisUsage, const FName KeyName) {}
34
39 virtual void SetButtonBinding(const FString InterfaceName, const int32 ButtonIndex, const FName KeyName) {}
40
45 virtual void SetPovAxisBinding(const FString InterfaceName, const int32 PovIndex, FName KeyName) {}
46
51 virtual void SetPovButtonBinding(const FString InterfaceName, const int32 PovIndex, TArray<FName> KeyNames) {}
52
55 FEnhancedRawInputDataDelegate& GetDataReceivedHandler() { return DataReceivedHandler; }
56
57protected:
58 TSharedRef<FGenericApplicationMessageHandler> MessageHandler;
59
60 FEnhancedRawInputDataDelegate DataReceivedHandler;
61};
62
64class FEnhancedRawInputPlugin : public IInputDeviceModule
65{
66 virtual TSharedPtr<IInputDevice> CreateInputDevice(const TSharedRef<FGenericApplicationMessageHandler> &InMessageHandler) override;
67 TSharedPtr<class IEnhancedRawInput> EnhancedRawInput;
68
69public:
70
73 TSharedPtr<class IEnhancedRawInput>& GetEnhancedRawInput() { return EnhancedRawInput; }
74
75 virtual void StartupModule() override;
76 virtual void ShutdownModule() override;
77
81 {
82 return FModuleManager::LoadModuleChecked<FEnhancedRawInputPlugin>("EnhancedRawInput");
83 }
84
87 static inline bool IsAvailable()
88 {
89 return FModuleManager::Get().IsModuleLoaded("EnhancedRawInput");
90 }
91};
The Plugin class, implements IInputDeviceModule.
Definition EnhancedRawInput.h:65
static FEnhancedRawInputPlugin & Get()
Loads Enhanced Raw Input Plugin, checking to ensure it exists.
Definition EnhancedRawInput.h:80
static bool IsAvailable()
Checks if module is available.
Definition EnhancedRawInput.h:87
TSharedPtr< class IEnhancedRawInput > & GetEnhancedRawInput()
Gets a pointer to the Enhanced Raw Input object.
Definition EnhancedRawInput.h:73
virtual void SetPovButtonBinding(const FString InterfaceName, const int32 PovIndex, TArray< FName > KeyNames)
Binds a controller POV to a corresponding keys.
Definition EnhancedRawInput.h:51
virtual void SetPovAxisBinding(const FString InterfaceName, const int32 PovIndex, FName KeyName)
Binds a controller POV axis to a corresponding key.
Definition EnhancedRawInput.h:45
FEnhancedRawInputDataDelegate & GetDataReceivedHandler()
Delegate for raw, unprocessed HID data.
Definition EnhancedRawInput.h:55
virtual void SetAxisBinding(const FString InterfaceName, const int32 AxisUsage, const FName KeyName)
Binds a controller axis to a corresponding key.
Definition EnhancedRawInput.h:33
virtual void SetBindings(const FString InterfaceName)
Applies the key binding settings to the specified controller.
Definition EnhancedRawInput.h:27
virtual void SetButtonBinding(const FString InterfaceName, const int32 ButtonIndex, const FName KeyName)
Binds a controller button to a corresponding key.
Definition EnhancedRawInput.h:39