Skip to content

Commit

Permalink
Added vigembus detection
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbouteiller committed Mar 6, 2022
1 parent dcd9f23 commit 065e7f1
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

assert platform.system() == 'Windows', "Sorry, this module is only compatible with Windows so far."

VIGEMBUS_VERSION = "1.17.333.0"

archstr = platform.machine()
if archstr.endswith('64'):
arch = "x64"
Expand All @@ -24,24 +26,45 @@

pathMsi = Path(__file__).parent.absolute() / "vgamepad" / "win" / "vigem" / "install" / arch / ("ViGEmBusSetup_" + arch + ".msi")

# Try to detect vigembus:
try:
registry_str = subprocess.check_output(
['reg', 'query', r'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', '/s'], text=True).lower()
j = registry_str.find('vigembus')
if j > 0:
vigem_installed = True
i = registry_str[:j].rfind('displayversion')
if i != -1:
vigem_version = registry_str[i:j].split()[2]
if vigem_version != VIGEMBUS_VERSION:
warnings.warn(f"found vigembus version {vigem_version} on your system. Expected {VIGEMBUS_VERSION}.")
else:
vigem_installed = False
except Exception as e:
vigem_installed = False
warnings.warn(f"vgamepad could not run the vigembus detection on your system, \
an exception has been caught while trying: \n{e}")


# Prompt installation of the ViGEmBus driver (blocking call)
if sys.argv[1] != 'egg_info' and sys.argv[1] != 'sdist':
subprocess.call(['msiexec', '/i', '%s' % str(pathMsi)], shell=True)
if not vigem_installed:
subprocess.call(['msiexec', '/i', '%s' % str(pathMsi)], shell=True)

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='vgamepad',
packages=[package for package in find_packages()],
version='0.0.7',
version='0.0.8',
license='MIT',
description='Virtual XBox360 and DualShock4 gamepads in python',
long_description=long_description,
long_description_content_type="text/markdown",
author='Yann Bouteiller',
url='https://github.com/yannbouteiller/vgamepad',
download_url='https://github.com/yannbouteiller/vgamepad/archive/refs/tags/v0.0.7.tar.gz',
download_url='https://github.com/yannbouteiller/vgamepad/archive/refs/tags/v0.0.8.tar.gz',
keywords=['virtual', 'gamepad', 'python', 'xbox', 'dualshock', 'controller', 'emulator'],
install_requires=[],
classifiers=[
Expand Down

0 comments on commit 065e7f1

Please sign in to comment.