#!/system/bin/sh

MODE="${1:-consume}"
CONFIG_PATH="${OMNISIGHT_CONFIG:-/data/local/tmp/omnisight_android.cfg}"

case "${MODE}" in
    auto|consume|init_motion|off) ;;
    *)
        echo "usage: sh /data/local/tmp/set_omnisight_input_mode.sh [auto|consume|init_motion|off]"
        exit 1
        ;;
esac

cat > "${CONFIG_PATH}" <<EOF
# OmniSight Android external config.
# This file is applied automatically by inject_omnisight.sh.
input_hook_mode=${MODE}
EOF

chmod 666 "${CONFIG_PATH}" 2>/dev/null || true
echo "[OmniSight] input_hook_mode=${MODE} written to ${CONFIG_PATH}"
