MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / HandleControllerButtonEvent

Function HandleControllerButtonEvent

Source/controls/game_controls.cpp:347–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347bool HandleControllerButtonEvent(const SDL_Event &event, const ControllerButtonEvent ctrlEvent, GameAction &action)
348{
349 if (ctrlEvent.button == ControllerButton_IGNORE) {
350 return false;
351 }
352
353 struct ButtonReleaser {
354 ~ButtonReleaser()
355 {
356 if (ctrlEvent.up)
357 sgOptions.Padmapper.ButtonReleased(ctrlEvent.button, false);
358 }
359 ControllerButtonEvent ctrlEvent;
360 };
361
362 const ButtonReleaser buttonReleaser { ctrlEvent };
363 bool isGamepadMotion = IsControllerMotion(event);
364 if (!isGamepadMotion) {
365 SimulateRightStickWithPadmapper(ctrlEvent);
366 }
367 DetectInputMethod(event, ctrlEvent);
368 if (isGamepadMotion) {
369 return true;
370 }
371
372 if (ctrlEvent.button != ControllerButton_NONE && ctrlEvent.button == SuppressedButton) {
373 if (!ctrlEvent.up)
374 return true;
375 SuppressedButton = ControllerButton_NONE;
376 }
377
378 if (ctrlEvent.up && sgOptions.Padmapper.ActionNameTriggeredByButtonEvent(ctrlEvent) != "") {
379 // Button press may have brought up a menu;
380 // don't confuse release of that button with intent to interact with the menu
381 sgOptions.Padmapper.ButtonReleased(ctrlEvent.button);
382 return true;
383 } else if (GetGameAction(event, ctrlEvent, &action)) {
384 ProcessGameAction(action);
385 return true;
386 } else if (ctrlEvent.button != ControllerButton_NONE) {
387 if (!ctrlEvent.up)
388 PressControllerButton(ctrlEvent.button);
389 return true;
390 }
391
392 return false;
393}
394
395} // namespace devilution

Callers 1

GameEventHandlerFunction · 0.85

Calls 8

IsControllerMotionFunction · 0.85
DetectInputMethodFunction · 0.85
GetGameActionFunction · 0.85
ProcessGameActionFunction · 0.85
PressControllerButtonFunction · 0.85
ButtonReleasedMethod · 0.80

Tested by

no test coverage detected