DayZ 1.24
Loading...
Searching...
No Matches
InputUtils Class Reference
Collaboration diagram for InputUtils:
[legend]

Static Protected Member Functions

static string GetButtonNameFromInput (string pInputName, int pInputDeviceType)
 
static map< int, ref TStringArrayGetComboButtonNamesFromInput (string pInputName, int pInputDeviceType)
 returns a map of button names, combo or not
 
static array< stringGetButtonIconPathFromInput (notnull UAInput pInput, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER)
 
static array< stringGetButtonIconPathFromInput (string pInputName, int pInputDeviceType)
 
static void GetImagesetAndIconFromInputAction (notnull UAInput pInput, int pInputDeviceType, out array< string > pImageSet, out array< string > pIconName)
 
static void GetImagesetAndIconFromInputAction (string pInputAction, int pInputDeviceType, out array< string > pImageSet, out array< string > pIconName)
 
static string GetRichtextButtonIconFromInputAction (notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
 
static string GetRichtextButtonIconFromInputAction (string pInputAction, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
 
static void UpdateConsolePresetID ()
 
static int GetConsolePresetID ()
 
static map< int, ref array< int > > GetInputActionSortingMap ()
 
static array< intGetUnsortedInputActions ()
 
static bool InitInputMetadata ()
 

Static Protected Attributes

ref map< int, ref array< int > > m_InputActionSortingMap
 
ref array< intm_UnsortedInputActions
 
static const float ICON_SCALE_NORMAL = 1.21
 
static const float ICON_SCALE_TOOLBAR = 1.81
 

Static Private Attributes

static const string PRESET_OLD = "#STR_UAPRESET_0"
 
static const string PRESET_NEW = "#STR_UAPRESET_1"
 
static const int VARIANT_OLD = 0
 
static const int VARIANT_NEW = 1
 
static int m_CurrentPresetIDConsole = -1
 

Detailed Description

Definition at line 1 of file InputUtils.c.

Member Function Documentation

◆ GetButtonIconPathFromInput() [1/2]

static array< string > InputUtils::GetButtonIconPathFromInput ( notnull UAInput pInput,
int pInputDeviceType = EUAINPUT_DEVICE_CONTROLLER )
inlinestaticprotected

Definition at line 71 of file InputUtils.c.

72 {
74
75 for (int i = 0; i < pInput.AlternativeCount(); i++)
76 {
77 pInput.SelectAlternative(i);
78 bool done = false;
79 for (int bk = 0; bk < pInput.BindKeyCount(); bk++)
80 {
81 if (pInput.CheckBindDevice(0, pInputDeviceType))
82 {
83 buttonIcons.Insert(GetUApi().GetButtonIcon(pInput.Binding(bk)));
84
85 if (bk == pInput.BindKeyCount() - 1)
86 done = true;
87 }
88 }
89
90 if (done)
91 {
92 buttonIcons.Invert();
93 return buttonIcons;
94 }
95 }
96
97 return buttonIcons;
98 }
proto native UAInputAPI GetUApi()

References GetUApi().

Referenced by GetButtonIconPathFromInput(), and GetImagesetAndIconFromInputAction().

◆ GetButtonIconPathFromInput() [2/2]

static array< string > InputUtils::GetButtonIconPathFromInput ( string pInputName,
int pInputDeviceType )
inlinestaticprotected

Definition at line 100 of file InputUtils.c.

101 {
102 UAInput inp = GetUApi().GetInputByName(pInputName);
103
106
107 return buttonIcons;
108 }
static array< string > GetButtonIconPathFromInput(notnull UAInput pInput, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER)
Definition InputUtils.c:71

References GetButtonIconPathFromInput(), and GetUApi().

◆ GetButtonNameFromInput()

static string InputUtils::GetButtonNameFromInput ( string pInputName,
int pInputDeviceType )
inlinestaticprotected

Definition at line 17 of file InputUtils.c.

18 {
19 UAInput inp = GetUApi().GetInputByName(pInputName);
20 for (int i = 0; i < inp.AlternativeCount(); i++)
21 {
22 inp.SelectAlternative(i);
23 if (inp.CheckBindDevice(0, pInputDeviceType))
24 return GetUApi().GetButtonName(inp.GetBindKey(0));
25 }
26
27 return "";
28 }

References GetUApi().

Referenced by ActionTargetsCursor::SetInteractActionIcon().

◆ GetComboButtonNamesFromInput()

static map< int, ref TStringArray > InputUtils::GetComboButtonNamesFromInput ( string pInputName,
int pInputDeviceType )
inlinestaticprotected

returns a map of button names, combo or not

Definition at line 31 of file InputUtils.c.

32 {
33 UAInput inp = GetUApi().GetInputByName(pInputName);
35 map<int, ref TStringArray> output; //<alternativeIDX<button_array>>
36 for (int i = 0; i < inp.AlternativeCount(); i++)
37 {
38 inp.SelectAlternative(i);
39 if (inp.BindingCount() > 0 && inp.Binding(0) != 0 && inp.CheckBindDevice(0, pInputDeviceType))
40 {
42 if (inp.IsCombo())
43 {
44 buttons.Insert(GetUApi().GetButtonName(inp.Binding(0)));
45
46 for (int j = 1; j < inp.BindingCount(); j++)
47 {
48 if (inp.Binding(j) != 0 && inp.CheckBindDevice(j, pInputDeviceType))
49 buttons.Insert(GetUApi().GetButtonName(inp.Binding(j)));
50 }
51 //return buttons;
52 }
53 else
54 {
55 buttons.Insert(GetUApi().GetButtonName(inp.GetBindKey(0)));
56 //return buttons;
57 }
58
59 if (buttons.Count() > 0)
60 {
61 if (!output)
63 output.Insert(i, buttons);
64 }
65 }
66 }
67
68 return output;
69 }
array< string > TStringArray
Definition EnScript.c:666

References GetUApi().

Referenced by GetBoundButtonText().

◆ GetConsolePresetID()

static int InputUtils::GetConsolePresetID ( )
inlinestaticprotected

Definition at line 198 of file InputUtils.c.

199 {
201 }
static int m_CurrentPresetIDConsole
Definition InputUtils.c:8

References m_CurrentPresetIDConsole.

Referenced by UIScriptedMenu::UpdateTabContent().

◆ GetImagesetAndIconFromInputAction() [1/2]

static void InputUtils::GetImagesetAndIconFromInputAction ( notnull UAInput pInput,
int pInputDeviceType,
out array< string > pImageSet,
out array< string > pIconName )
inlinestaticprotected

Asia vs Europe/N.America controller layout

Definition at line 110 of file InputUtils.c.

111 {
113 if (buttons.Count() == 0)
114 return;
115
116 for (int i = 0; i < buttons.Count(); i++)
117 {
119 buttons.Get(i).Split(":", parts);
120
121 if (parts.Count() < 2)
122 return;
123
124 pImageSet.Insert(parts[1].SubstringInverted(parts[1], parts[1].Length() - 6, parts[1].Length()));
125
127#ifdef PLATFORM_PS4
128 if (GetGame().GetInput().GetEnterButton() == GamepadButton.B)
129 {
131 if (parts[2] == "cross")
132 parts[2] = "circle";
133
135 if (parts[2] == "circle")
136 parts[2] = "cross";
137 }
138#endif
139
140 pIconName.Insert(parts[2]);
141 }
142 }
ActionInput GetInput()
Definition ActionBase.c:989
proto native CGame GetGame()
GamepadButton
Definition EnSystem.c:341

References GetButtonIconPathFromInput(), GetGame(), and GetInput().

Referenced by GetImagesetAndIconFromInputAction(), GetRichtextButtonIconFromInputAction(), and GetRichtextButtonIconFromInputAction().

◆ GetImagesetAndIconFromInputAction() [2/2]

static void InputUtils::GetImagesetAndIconFromInputAction ( string pInputAction,
int pInputDeviceType,
out array< string > pImageSet,
out array< string > pIconName )
inlinestaticprotected

Definition at line 144 of file InputUtils.c.

145 {
146 UAInput inp = GetUApi().GetInputByName(pInputAction);
147
149 }
static void GetImagesetAndIconFromInputAction(notnull UAInput pInput, int pInputDeviceType, out array< string > pImageSet, out array< string > pIconName)
Definition InputUtils.c:110

References GetImagesetAndIconFromInputAction(), and GetUApi().

◆ GetInputActionSortingMap()

static map< int, ref array< int > > InputUtils::GetInputActionSortingMap ( )
inlinestaticprotected

Definition at line 203 of file InputUtils.c.

204 {
206 }
ref map< int, ref array< int > > m_InputActionSortingMap
Definition InputUtils.c:11

References m_InputActionSortingMap.

Referenced by array::AddSubgroup(), array::CreateSubgroups(), and UIScriptedMenu::CreateTabs().

◆ GetRichtextButtonIconFromInputAction() [1/2]

static string InputUtils::GetRichtextButtonIconFromInputAction ( notnull UAInput pInput,
string pLocalizedDescription,
int pInputDeviceType = EUAINPUT_DEVICE_CONTROLLER,
float pScale = ICON_SCALE_NORMAL,
bool pVertical = false )
inlinestaticprotected

first element is already taken

Definition at line 151 of file InputUtils.c.

152 {
156
157 if (imageSets.Count() == 0)
158 return "";
159
160 string result = string.Format("<image set=\"%1\" name=\"%2\" scale=\"%3\" />", imageSets.Get(0), iconNames.Get(0), pScale);
161
162 string divider = " ";
163 if (pVertical)
164 divider = string.Format("\n%1\n", divider);
165
166 if (imageSets.Count() > 1)
167 {
169 for (int i = 1; i < imageSets.Count(); i++)
170 result = string.Format("%1%2<image set=\"%3\" name=\"%4\" scale=\"%5\" />", result, divider, imageSets.Get(i), iconNames.Get(i), pScale);
171 }
172
173 return string.Format("%1 %2", result, pLocalizedDescription);
174 }

References GetImagesetAndIconFromInputAction().

Referenced by GetRichtextButtonIconFromInputAction(), Init(), LoginScreenBase::Init(), UIScriptedMenu::Init(), Inventory(), ActionTargetsCursor::SetControllerIcon(), ScriptedWidgetEventHandler::SetControllerIcon(), UIScriptedMenu::UpdateControlsElements(), WarningMenuBase::UpdateControlsElements(), ScriptedWidgetEventHandler::UpdateControlsElements(), and UIScriptedMenu::UpdateInfoPanelText().

◆ GetRichtextButtonIconFromInputAction() [2/2]

static string InputUtils::GetRichtextButtonIconFromInputAction ( string pInputAction,
string pLocalizedDescription,
int pInputDeviceType = EUAINPUT_DEVICE_CONTROLLER,
float pScale = ICON_SCALE_NORMAL,
bool pVertical = false )
inlinestaticprotected

Definition at line 176 of file InputUtils.c.

177 {
178 UAInput inp = GetUApi().GetInputByName(pInputAction);
179
183
185 }
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition InputUtils.c:151

References GetImagesetAndIconFromInputAction(), GetRichtextButtonIconFromInputAction(), and GetUApi().

◆ GetUnsortedInputActions()

static array< int > InputUtils::GetUnsortedInputActions ( )
inlinestaticprotected

Definition at line 208 of file InputUtils.c.

209 {
211 }
ref array< int > m_UnsortedInputActions
Definition InputUtils.c:12

References m_UnsortedInputActions.

Referenced by array::AddSubgroup(), array::CreateSubgroups(), and UIScriptedMenu::CreateTabs().

◆ InitInputMetadata()

static bool InputUtils::InitInputMetadata ( )
inlinestaticprotected

Definition at line 213 of file InputUtils.c.

214 {
216 {
218
222 GetUApi().GetActiveInputs(m_UnsortedInputActions);
223
224 UAInput inp;
225
226 for (int i = 0; i < GetUApi().SortingCount(); i++)
227 {
228 int input_id;
230 for (int j = 0; j < m_UnsortedInputActions.Count(); j++)
231 {
233 inp = GetUApi().GetInputByID(input_id);
234 if (inp.HasSorting(i))
235 {
237 sorted_actions.Insert(input_id);
238 }
239 }
240
241 if (sorting_content.Count() > 0)
242 {
243 sorting_content.Sort();
245 }
246 }
247
248 //remove sorted used inputs
249 int count = sorted_actions.Count();
250 for (i = 0; i < count; i++)
252 return true;
253 }
254 return false;
255 }
array< int > TIntArray
Definition EnScript.c:668

References GetUApi(), m_InputActionSortingMap, and m_UnsortedInputActions.

Referenced by UIScriptedMenu::InitInputSortingMap().

◆ UpdateConsolePresetID()

static void InputUtils::UpdateConsolePresetID ( )
inlinestaticprotected

Definition at line 187 of file InputUtils.c.

188 {
189 string profile_name;
190 GetGame().GetInput().GetProfileName(GetUApi().PresetCurrent(), profile_name);
191
194 else
196 }
static const int VARIANT_NEW
Definition InputUtils.c:7
static const string PRESET_OLD
Definition InputUtils.c:4
static const int VARIANT_OLD
Definition InputUtils.c:6

References GetGame(), GetUApi(), m_CurrentPresetIDConsole, PRESET_OLD, VARIANT_NEW, and VARIANT_OLD.

Referenced by UIScriptedMenu::ComposeData(), and UIScriptedMenu::PerformSwitchPreset().

Member Data Documentation

◆ ICON_SCALE_NORMAL

const float InputUtils::ICON_SCALE_NORMAL = 1.21
staticprotected

Definition at line 14 of file InputUtils.c.

◆ ICON_SCALE_TOOLBAR

◆ m_CurrentPresetIDConsole

int InputUtils::m_CurrentPresetIDConsole = -1
staticprivate

Definition at line 8 of file InputUtils.c.

Referenced by GetConsolePresetID(), and UpdateConsolePresetID().

◆ m_InputActionSortingMap

ref map<int, ref array<int> > InputUtils::m_InputActionSortingMap
staticprotected

Definition at line 11 of file InputUtils.c.

Referenced by GetInputActionSortingMap(), and InitInputMetadata().

◆ m_UnsortedInputActions

ref array<int> InputUtils::m_UnsortedInputActions
staticprotected

Definition at line 12 of file InputUtils.c.

Referenced by GetUnsortedInputActions(), and InitInputMetadata().

◆ PRESET_NEW

const string InputUtils::PRESET_NEW = "#STR_UAPRESET_1"
staticprivate

Definition at line 5 of file InputUtils.c.

Referenced by UIScriptedMenu::UpdateToolbarText().

◆ PRESET_OLD

const string InputUtils::PRESET_OLD = "#STR_UAPRESET_0"
staticprivate

Definition at line 4 of file InputUtils.c.

Referenced by UpdateConsolePresetID(), and UIScriptedMenu::UpdateToolbarText().

◆ VARIANT_NEW

const int InputUtils::VARIANT_NEW = 1
staticprivate

Definition at line 7 of file InputUtils.c.

Referenced by UpdateConsolePresetID().

◆ VARIANT_OLD

const int InputUtils::VARIANT_OLD = 0
staticprivate

Definition at line 6 of file InputUtils.c.

Referenced by UpdateConsolePresetID().


The documentation for this class was generated from the following file: