Python bindings for vJoy with full force feedback support
Project description
Forked from tidzo/pyvjoy to support FFB callbacks.
Note: FFB support requires a 2.2.x version for the effect block index to work properly. The original vJoy project on vjoystick.sourceforge is not being updated anymore and does not support FFB properly.
It is recommended to use a fork like BrunnerInnovation/vJoy.
The interface dll from this fork is being used for FFB.
With this library you can easily set Axis and Button values on any vJoy device and receive force feedback effect data. Low-level bindings are provided in pyvjoy._sdk as well as a (hopefully) slightly more 'Pythonic' API in the pyvjoy.VJoyDevice() object.
The usage of non FFB functions is identical to the original pyvJoy project.
Standard pyvjoy usage:
import pyvjoy
#Pythonic API, item-at-a-time
j = pyvjoy.VJoyDevice(1)
#turn button number 15 on
j.set_button(15,1)
#turn button 15 off again
j.set_button(15,0)
#Set X axis to fully left
j.set_axis(pyvjoy.HID_USAGE_X, 0x1)
#Set X axis to fully right
j.set_axis(pyvjoy.HID_USAGE_X, 0x8000)
#Also implemented:
j.reset()
j.reset_buttons()
j.reset_povs()
#The 'efficient' method as described in vJoy's docs - set multiple values at once
j.data.lButtons = 19 # buttons number 1,2 and 5 (1+2+16)
j.data.wAxisX = 0x2000
j.data.wAxisY= 0x7500
#send data to vJoy device
j.update()
Simple FFB example with callbacks:
import pyvjoy
import time
j = pyvjoy.VJoyDevice(1)
# FFB functions
# Use effect manager helper to simplify effect handling
# idx (index in effect list) is blockindex-1 because blockindex always starts with 1.
# Effect events can be received using the separate callback functions or by overriding update_packet_cb, update_effect_dict_cb or __ffb_cb
class EffMan(pyvjoy.FFB_Effect_Manager):
def update_ctrl_cb(self,ctrl): # 1 = enable, 2 = disable
print("Control",ctrl)
def update_constant_cb(self,data,idx): # Constant force magnitude
print("CF",data["Magnitude"])
# Also implemented (Function dummys from FFB_Effect_Manager class)
def update_gain_cb(self,gain):
"""Gain packet callback. Device gain 0-255"""
return
def update_effect_op_cb(self,enabled,idx):
"""Change effect state callback"""
return
def update_effect_cb(self,data,idx):
"""Set effect (effect) callback"""
return
def update_envelope_cb(self,data,idx):
"""Set envelope callback"""
return
def update_condition_cb(self,data,idx):
"""Set condition (condX or condY) callback"""
return
def update_periodic_cb(self,data,idx):
"""Set periodic callback"""
return
def update_ramp_cb(self,data,idx):
"""Set ramp callback"""
return
def update_effect_dict_cb(self,packetdict,idx):
return
if j.ffb_supported(): # Only if FFB is actually enabled in device and driver
effectManager1 = EffMan()
effectManager1.ffb_register_callback(j)
time.sleep(100)
print("End")
Low level minimal FFB example without creating the FFB_Effect_Manager:
import pyvjoy
import time
j = pyvjoy.VJoyDevice(1)
def ffbcb(data,reptype):
packetdict,ebi = pyvjoy.FFB_Effect_Manager.ffb_packet_to_dict(data,reptype)
print(packetdict,ebi)
j.ffb_register_callback(ffbcb)
time.sleep(100)
print("End")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyvjoyffb-0.2.tar.gz.
File metadata
- Download URL: pyvjoyffb-0.2.tar.gz
- Upload date:
- Size: 523.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e947ec94ad8aec12c2cc6cb77d8e28269fd432193fa557a688972c1c59dbfc7
|
|
| MD5 |
b36a2228be799d402ba10d1ae2c395d5
|
|
| BLAKE2b-256 |
959d735f697d4dccbb05507d83c378c7466ca51c3ab3313968761947351355bb
|
Provenance
The following attestation bundles were made for pyvjoyffb-0.2.tar.gz:
Publisher:
publish-pypi.yml on Ultrawipf/pyvjoy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvjoyffb-0.2.tar.gz -
Subject digest:
3e947ec94ad8aec12c2cc6cb77d8e28269fd432193fa557a688972c1c59dbfc7 - Sigstore transparency entry: 159890381
- Sigstore integration time:
-
Permalink:
Ultrawipf/pyvjoy@fc0a66f7268d89185925527a6fee55988a2f5082 -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/Ultrawipf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@fc0a66f7268d89185925527a6fee55988a2f5082 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyvjoyffb-0.2-py3-none-any.whl.
File metadata
- Download URL: pyvjoyffb-0.2-py3-none-any.whl
- Upload date:
- Size: 523.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1891df2501da0e44efd1fa7c7180a94df3436204b6a42be2a2c919417e63e840
|
|
| MD5 |
257d51e21a8e7589486f9754ee2eaa42
|
|
| BLAKE2b-256 |
ad85527d54d50d339c1e3eaebdc5d1bf1b4be778a8a6b45c34980f89351f87f9
|
Provenance
The following attestation bundles were made for pyvjoyffb-0.2-py3-none-any.whl:
Publisher:
publish-pypi.yml on Ultrawipf/pyvjoy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvjoyffb-0.2-py3-none-any.whl -
Subject digest:
1891df2501da0e44efd1fa7c7180a94df3436204b6a42be2a2c919417e63e840 - Sigstore transparency entry: 159890382
- Sigstore integration time:
-
Permalink:
Ultrawipf/pyvjoy@fc0a66f7268d89185925527a6fee55988a2f5082 -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/Ultrawipf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@fc0a66f7268d89185925527a6fee55988a2f5082 -
Trigger Event:
push
-
Statement type: