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")
Metadata
Release files for pyvjoyffb 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyvjoyffb-0.4.tar.gz | 523.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyvjoyffb-0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.0 MB
Release files / pyvjoyffb-0.4.tar.gz
| Download URL | pyvjoyffb-0.4.tar.gz |
|---|---|
| Size | 523.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a19279295f70fca8fc119405b5e0b63556bf9e5fb8b636d7a881e09c3020ed84
|
|
BLAKE2b-256 checksum How to use checksums |
1c99a39934b10e83a0a617bbe630770c2b5813ec1b747cb9e326d6655105b804
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 27, 2025.
Transparency logRelease files / pyvjoyffb-0.4-py3-none-any.whl
| Download URL | pyvjoyffb-0.4-py3-none-any.whl |
|---|---|
| Size | 523.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
263845993b76cbedb8ca2da6c4ed039329f9e889cbf5238da80b1c3d98c974ce
|
|
BLAKE2b-256 checksum How to use checksums |
6a3976759be4b9898152fc139f11936b3433275c1a678f55f0b346fca5d6dc2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 27, 2025.
Transparency log