From c86e02a39a7e7b30193a19c01fefbe88ae89a517 Mon Sep 17 00:00:00 2001 From: yannbouteiller Date: Mon, 25 Jan 2021 23:24:11 -0500 Subject: [PATCH] v0.0.2 --- README.md | 39 +++++++++++++++++++++++++++------ setup.py | 17 ++++++++++++-- vgamepad/win/virtual_gamepad.py | 12 ++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8e90b21..bf9ee92 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,14 @@ Thus far, ```vgamepad``` is compatible with Windows only. --- ## Installation -Before installing ```vgamepad```, you must install ViGEmBus on your system. -Depending on your Windows version, download and execute the [ViGEmBus 64bit](https://github.com/ViGEm/ViGEmBus/releases/download/setup-v1.17.333/ViGEmBusSetup_x64.msi) -or the [ViGEmBus 32bit](https://github.com/ViGEm/ViGEmBus/releases/download/setup-v1.17.333/ViGEmBusSetup_x86.msi) installer. - -Now that ViGEmBus is installed, open your favorite terminal (e.g. anaconda prompt) and run: - +Open your favorite terminal (e.g. anaconda prompt) and run: ```bash pip install vgamepad ``` +This automatically runs the installer of the ViGEmBus driver. +Accept the licence agreement, click ```Install```, allow the installer to modify you PC, wait for completion and click ```Finish```. -This will install ```vgamepad``` in your active python environment. +```vgamepad``` is now installed in your active python environment. --- @@ -115,6 +112,13 @@ gamepad.right_joystick_float(x_value_float=-1.0, y_value_float=0.8) # values be gamepad.update() ``` +Reset to default state: +```python +gamepad.reset() + +gamepad.update() +``` + Full example: ```python import vgamepad as vg @@ -152,6 +156,13 @@ gamepad.right_joystick_float(x_value_float=0.0, y_value_float=0.0) gamepad.update() +time.sleep(1.0) + +# reset gamepad to default state +gamepad.reset() + +gamepad.update() + time.sleep(1.0) ``` @@ -259,6 +270,13 @@ class DS4_DPAD_DIRECTIONS(IntEnum): DS4_BUTTON_DPAD_NORTH = 0x0 ``` +Reset to default state: +```python +gamepad.reset() + +gamepad.update() +``` + Full example: ```python import vgamepad as vg @@ -296,6 +314,13 @@ gamepad.right_joystick_float(x_value_float=0.0, y_value_float=0.0) gamepad.update() +time.sleep(1.0) + +# reset gamepad to default state +gamepad.reset() + +gamepad.update() + time.sleep(1.0) ``` diff --git a/setup.py b/setup.py index 4f8225e..511d72c 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,35 @@ from setuptools import setup, find_packages import platform +from pathlib import Path +import subprocess +import sys assert platform.system() == 'Windows', "Sorry, this module is only compatible with Windows so far." +if platform.architecture()[0] == "64bit": + arch = "x64" +else: + arch = "x86" +pathMsi = Path(__file__).parent.absolute() / "vgamepad" / "win" / "vigem" / "install" / arch / ("ViGEmBusSetup_" + arch + ".msi") + +# Prompt installation of the ViGEmBus driver (blocking call) +if sys.argv[1] != 'egg_info': + 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.1', + version='0.0.2', 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/v0.0.1.tar.gz', + download_url='https://github.com/yannbouteiller/vgamepad/archive/v0.0.2.tar.gz', keywords=['virtual', 'gamepad', 'python', 'xbox', 'dualshock', 'controller', 'emulator'], install_requires=[], classifiers=[ diff --git a/vgamepad/win/virtual_gamepad.py b/vgamepad/win/virtual_gamepad.py index 3d0afe3..3268ff0 100644 --- a/vgamepad/win/virtual_gamepad.py +++ b/vgamepad/win/virtual_gamepad.py @@ -107,6 +107,12 @@ def get_default_report(self): sThumbRX=0, sThumbRY=0) + def reset(self): + """ + Resets the report to the default state + """ + self.report = self.get_default_report() + def press_button(self, button): """ Presses a button (no effect if already pressed) @@ -224,6 +230,12 @@ def get_default_report(self): vcom.DS4_REPORT_INIT(rep) return rep + def reset(self): + """ + Resets the report to the default state + """ + self.report = self.get_default_report() + def press_button(self, button): """ Presses a button (no effect if already pressed)