Skip to content

Gamepad

APHONIC edited this page Sep 15, 2026 · 2 revisions

Gamepad

Gamepad.lua: right-stick window dragging for console / gamepad-preferred mode.

LibAPH.CreateGamepadMover(target)

How it works: This polls the right analog stick, claims it via SetGamepadRightStickConsumedByUI so it doesn't also spin the camera, and moves target by tilt × elapsed time. Auto-stops after 3 seconds of no stick input.

Signature: returns a mover object.

local mover = LibAPH.CreateGamepadMover(target)

mover:ToggleGamepadMove(true)   -- start polling and dragging
mover:ToggleGamepadMove(false)  -- stop early

mover:RegisterCallback("", 0, function(pos)
    -- pos = { left = ..., top = ... }
    -- fires on stop, including the automatic 3-second idle timeout
    MyAddon.settings.window_left = pos.left
    MyAddon.settings.window_top = pos.top
end)

RegisterCallback takes (name, eventCode, callback); only the callback argument matters here.

Build one mover per target control and hold onto it: calling CreateGamepadMover again on the same target just creates a second, independent mover instance rather than reusing the first.


Home · Getting Started

Clone this wiki locally