Alterra

getcontrollertouch

getcontrollertouch(controller?) reads the touchpads of a connected controller, or nil if the controller is missing or has no touchpads.

local pads = getcontrollertouch()
if pads and pads[1] then
    for _, finger in ipairs(pads[1].fingers) do
        if finger.touching then
            print(finger.position) -- Vector2, 0-1 from the top-left
        end
    end
end

Parameters

  • controller (number, optional): the controller index, starts at 1

Returns

An array of touchpads, each with:

  • pressed (boolean, optional): the pad click
  • fingers (array): each finger has touching (boolean), position (Vector2, 0-1 from the top-left), and id (number, optional)