MCPcopy Create free account
hub / github.com/ZDoom/Raze / UpdateJoystickMenu

Function UpdateJoystickMenu

source/common/menu/joystickmenu.cpp:157–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156
157void UpdateJoystickMenu(IJoystickConfig *selected)
158{
159 DMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_JoystickOptions);
160 DMenuDescriptor **ddesc = MenuDescriptors.CheckKey("JoystickOptionsDefaults");
161 if (ddesc == nullptr) return; // without any data the menu cannot be set up and must remain empty.
162 if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DOptionMenuDescriptor)))
163 {
164 DOptionMenuDescriptor *opt = (DOptionMenuDescriptor *)*desc;
165 DOptionMenuDescriptor *dopt = (DOptionMenuDescriptor *)*ddesc;
166 if (dopt == nullptr) return;
167 DMenuItemBase *it;
168
169 int i;
170 int itemnum = -1;
171
172 I_GetJoysticks(Joysticks);
173 if ((unsigned)itemnum >= Joysticks.Size())
174 {
175 itemnum = Joysticks.Size() - 1;
176 }
177 if (selected != NULL)
178 {
179 for (i = 0; (unsigned)i < Joysticks.Size(); ++i)
180 {
181 if (Joysticks[i] == selected)
182 {
183 itemnum = i;
184 break;
185 }
186 }
187 }
188 opt->mItems = dopt->mItems;
189
190 it = opt->GetItem("ConfigureMessage");
191 if (it != nullptr) it->SetValue(0, !!Joysticks.Size());
192 it = opt->GetItem("ConnectMessage1");
193 if (it != nullptr) it->SetValue(0, !use_joystick);
194 it = opt->GetItem("ConnectMessage2");
195 if (it != nullptr) it->SetValue(0, !use_joystick);
196
197 for (int ii = 0; ii < (int)Joysticks.Size(); ++ii)
198 {
199 it = CreateOptionMenuItemJoyConfigMenu(Joysticks[ii]->GetName().GetChars(), Joysticks[ii]);
200 GC::WriteBarrier(opt, it);
201 opt->mItems.Push(it);
202 if (ii == itemnum) opt->mSelectedItem = opt->mItems.Size();
203 }
204 if (opt->mSelectedItem >= (int)opt->mItems.Size())
205 {
206 opt->mSelectedItem = opt->mItems.Size() - 1;
207 }
208 //opt->CalcIndent();
209
210 // If the joystick config menu is open, close it if the device it's open for is gone.
211 if (CurrentMenu != nullptr && (CurrentMenu->IsKindOf("JoystickConfigMenu")))
212 {
213 auto p = CurrentMenu->PointerVar<IJoystickConfig>("mJoy");
214 if (p != nullptr)

Callers 10

RunGameFunction · 0.85
BuildGameMenusFunction · 0.85
D_ProcessEventsFunction · 0.85
AttachedMethod · 0.85
DetachedMethod · 0.85
I_StartupXInputFunction · 0.85
AttachedMethod · 0.85
DetachedMethod · 0.85
I_StartupRawPS2Function · 0.85

Calls 11

IsKindOfMethod · 0.80
GetItemMethod · 0.80
I_GetJoysticksFunction · 0.50
CheckKeyMethod · 0.45
SizeMethod · 0.45
SetValueMethod · 0.45
GetCharsMethod · 0.45
GetNameMethod · 0.45
PushMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected