UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
HIDInputInterface.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include <IOKit/hid/IOHIDLib.h>
8
9#define MAX_NUM_HIDINPUT_CONTROLLERS 4
10
12#define MAX_NUM_CONTROLLER_BUTTONS 24
13
18{
19public:
20
22
24
29
30 bool IsGamepadAttached() const { return bIsGamepadAttached; }
31
32private:
33
35
36 void OnNewHIDController(IOReturn Result, IOHIDDeviceRef DeviceRef);
37
38 static CFMutableDictionaryRef CreateDeviceMatchingDictionary(UInt32 UsagePage, UInt32 Usage);
39 static void HIDDeviceMatchingCallback(void* Context, IOReturn Result, void* Sender, IOHIDDeviceRef DeviceRef);
40 static void HIDDeviceRemovalCallback(void* Context, IOReturn Result, void* Sender, IOHIDDeviceRef DeviceRef);
41
42private:
43
44 struct FHIDElementInfo
45 {
46 IOHIDElementRef ElementRef;
48 uint32 UsagePage;
49 uint32 Usage;
50 int32 MinValue;
51 int32 MaxValue;
52 };
53
54 struct FHIDDeviceInfo
55 {
56 IOHIDDeviceRef DeviceRef;
58 int8 ButtonsMapping[MAX_NUM_CONTROLLER_BUTTONS];
59 uint16 LeftAnalogXMapping;
60 uint16 LeftAnalogYMapping;
61 uint16 LeftTriggerAnalogMapping;
62 uint16 RightAnalogXMapping;
63 uint16 RightAnalogYMapping;
64 uint16 RightTriggerAnalogMapping;
65
66 void SetupMappings();
67 };
68
69 struct FXBox360ControllerID
70 {
71 const int32 VendorID;
72 const int32 ProductID;
73 };
74
75 struct FControllerState
76 {
78 bool ButtonStates[MAX_NUM_CONTROLLER_BUTTONS];
79
81 double NextRepeatTime[MAX_NUM_CONTROLLER_BUTTONS];
82
84 int32 LeftAnalogX;
85
87 int32 LeftAnalogY;
88
90 int32 RightAnalogX;
91
93 int32 RightAnalogY;
94
96 int32 LeftTriggerAnalog;
97
99 int32 RightTriggerAnalog;
100
102 int32 ControllerId;
103
104 FHIDDeviceInfo Device;
105 };
106
107private:
108
111
113 FControllerState ControllerStates[MAX_NUM_HIDINPUT_CONTROLLERS];
114
116 float InitialButtonRepeatDelay;
117
119 float ButtonRepeatDelay;
120
121 bool bIsGamepadAttached;
122
123 IOHIDManagerRef HIDManager;
124
126};
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define MAX_NUM_CONTROLLER_BUTTONS
Definition HIDInputInterface.h:12
#define MAX_NUM_HIDINPUT_CONTROLLERS
Definition HIDInputInterface.h:9
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
Definition HIDInputInterface.h:18
void SetMessageHandler(const TSharedRef< FGenericApplicationMessageHandler > &InMessageHandler)
Definition HIDInputInterface.h:25
void SendControllerEvents()
Definition HIDInputInterface.cpp:459
bool IsGamepadAttached() const
Definition HIDInputInterface.h:30
Definition Array.h:670
Definition SharedPointer.h:153