-- InspectInput/Inspect_ControllerMap.lua
-- Controller mapping per build.

InspectControllerMap = InspectControllerMap or {}

InspectControllerMap.B41 = {
    rotateX = "RightStickY",
    rotateY = "RightStickX",
    zoomIn = "RT",
    zoomOut = "LT",
    accept = "A",
    back = "B",
    photo = "Start",
    resetView = "R3",
    pageUp = "LB",
    pageDown = "RB",
    dpadUp = "DPadUp",
    dpadDown = "DPadDown",
    dpadLeft = "DPadLeft",
    dpadRight = "DPadRight",
    scrollDesc = "LeftStickY",
}

InspectControllerMap.B42 = InspectControllerMap.B41

local function parseVersion(version)
    if not version then return 0, 0 end
    local major, minor = string.match(version, "^(%d+)%.(%d+)")
    return tonumber(major) or 0, tonumber(minor) or 0
end

function InspectControllerMap.getMap()
    local core = getCore and getCore()
    local version = core and core.getGameVersion and core:getGameVersion() or ""
    local major = parseVersion(version)
    if major >= 42 then
        return InspectControllerMap.B42
    end
    return InspectControllerMap.B41
end

return InspectControllerMap
