1
0

download-gameinput-sdk.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python3
  2. import argparse
  3. import logging
  4. from pathlib import Path
  5. import urllib.request
  6. logger = logging.getLogger(__name__)
  7. DEFAULT_GAMEINPUT_VERSION = "v3.3.195.0"
  8. def download_sdk(tag: str, lowercase: bool, output: Path):
  9. base_url = f"https://raw.githubusercontent.com/microsoftconnect/GameInput/refs/tags/{tag}/"
  10. url_relpaths = (
  11. "include/GameInput.h",
  12. "include/v0/GameInput.h",
  13. "include/v1/GameInput.h",
  14. "include/v2/GameInput.h",
  15. "lib/arm64/GameInput.lib",
  16. "lib/x64/GameInput.lib",
  17. )
  18. for url_relpath in url_relpaths:
  19. url = base_url + url_relpath
  20. local_relpath = url_relpath
  21. if lowercase:
  22. local_relpath = local_relpath.lower()
  23. local_path = output / local_relpath
  24. local_dirpath = local_path.parent
  25. local_dirpath.mkdir(parents=True, exist_ok=True)
  26. logger.info("Downloading %s to %s...", url, local_path)
  27. urllib.request.urlretrieve(url, local_path)
  28. logger.info("... done")
  29. def main():
  30. logging.basicConfig(level=logging.INFO)
  31. parser = argparse.ArgumentParser(description="Download Microsoft.GameInput SDK", allow_abbrev=False)
  32. parser.add_argument("--version", help="GameInput release tag (see https://github.com/microsoftconnect/GameInput/tags)", default=DEFAULT_GAMEINPUT_VERSION)
  33. parser.add_argument("--no-lowercase", action="store_false", dest="lowercase", help="Don't lowercase downloaded files")
  34. parser.add_argument("-o", "--output", type=Path, default=Path.cwd(), help="SDK will be stored here (in include and lib subdirectories)")
  35. args = parser.parse_args()
  36. download_sdk(tag=args.version, lowercase=args.lowercase, output=args.output)
  37. if __name__ == "__main__":
  38. raise SystemExit(main())