MCPcopy Create free account
hub / github.com/diasurgical/devilution / HandleRightStickMotion

Function HandleRightStickMotion

SourceX/controls/plrctrls.cpp:879–905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877}
878
879void HandleRightStickMotion()
880{
881 static RightStickAccumulator acc;
882 // deadzone is handled in ScaleJoystickAxes() already
883 if (rightStickX == 0 && rightStickY == 0) {
884 acc.clear();
885 return;
886 }
887
888 if (IsAutomapActive()) { // move map
889 int dx = 0, dy = 0;
890 acc.pool(&dx, &dy, 32);
891 AutoMapXOfs += dy + dx;
892 AutoMapYOfs += dy - dx;
893 return;
894 }
895
896 { // move cursor
897 sgbControllerActive = false;
898 int x = MouseX;
899 int y = MouseY;
900 acc.pool(&x, &y, 2);
901 x = std::min(std::max(x, 0), SCREEN_WIDTH - 1);
902 y = std::min(std::max(y, 0), SCREEN_HEIGHT - 1);
903 SetCursorPos(x, y);
904 }
905}
906
907/**
908 * @brief Moves the mouse to the first inventory slot.

Callers 1

Calls 4

IsAutomapActiveFunction · 0.85
SetCursorPosFunction · 0.85
poolMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected