Skip to content

Commit

Permalink
v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbouteiller committed Jan 26, 2021
1 parent 20c0c3e commit c86e02a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
```

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
```

Expand Down
17 changes: 15 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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=[
Expand Down
12 changes: 12 additions & 0 deletions vgamepad/win/virtual_gamepad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c86e02a

Please sign in to comment.