"""Null (no-op) UVC controller — used when no native library is available."""

from __future__ import annotations

import logging

from app.camera.uvc.base import UvcControllerBase, UvcParam, UvcParamInfo

logger = logging.getLogger(__name__)


class NullUvcController(UvcControllerBase):
    """
    Fallback controller that reports all controls as unsupported.

    Used on platforms where no UVC library is installed or when device
    enumeration fails.
    """

    def open(self, device_name: str) -> bool:  # noqa: ARG002
        return False

    def close(self) -> None:
        pass

    def is_open(self) -> bool:
        return False

    def get_param_info(self, param: UvcParam) -> UvcParamInfo:
        return UvcParamInfo(param=param, supported=False)

    def get_all_params(self) -> list[UvcParamInfo]:
        return [UvcParamInfo(param=p, supported=False) for p in UvcParam]

    def set_value(self, param: UvcParam, value: int) -> bool:  # noqa: ARG002
        logger.debug("NullUvcController: set_value ignored (%s=%d)", param.name, value)
        return False

    def set_auto(self, param: UvcParam, enabled: bool) -> bool:  # noqa: ARG002
        logger.debug(
            "NullUvcController: set_auto ignored (%s, auto=%s)", param.name, enabled
        )
        return False
