Open code-monet opened 1 week ago
I'm still really unclear how/what you intend this to work, I get forwarding FFB but not the actual mechanism so it's hard to actually say if any of that can/will work with Gremlin.
How it works:
Internals:
A vJoy device with FF enabled will by default simply drop all force feedback commands, while returning a success state at the driver level. The vJoy interface offers a function: FfbRegisterGenCB
which you use to register a callback function that handles all FF commands for all vJoy devices. This callback is called in a separate thread created by vJoy. Once you acquire the vJoy device via AcquireVJD
, FF handling is set in motion.
So I have a (C++) implementation of this function, which keeps track of FF state and forwards a single vJoy device's incoming FF commands to a single DirectInput FF capable device, which needs to be acquired in (DirectInput) exclusive mode. The whole thing is compiled into a DLL and a precompiled Python module; for Joystick Gremlin, the latter is more suitable. The plugin mechanism is used to import and register the callback function in the same process that acquires the vJoy device; if you ever isolate the plugins into their own process, a different hook will be needed.
Note re: acquiring the device via DirectInput: The same process can acquire the device multiple times in exclusive or inclusive mode so this isn't a conflict at all with how Joystick Gremlin acquires the device. I've also implemented my plugin to not reacquire the device if Joystick Gremlin releases it, which would turn off physical input forwarding as well as FF forwarding at the same time.
Note re: running a precompiled Python module via plugins - if the module has a crash at the C++ level (and I have found more than one segfault bug in DirectInput, sigh), Joystick Gremlin will be taken down with it. So it's my responsibility to ensure I find these bugs and take all steps to NOT hit them :) I'm currently testing out the plugin with R13.3 and a few different games and have to polish up the plugin interface before it can be released.
The idea at a high level is to use Joystick Gremlin to improve compatibility between games and wheels that either are unplayable or give crappy FF effects, for example:
Continuation of discussion at the Dill issues page, moving here for relevance.
I have a prototype force feedback bridge that works with the current release (R13) of Joystick Gremlin, via user plugins. The user plugin loads my library, which will be available as a precompiled Python extension. The user is offered an output device selection via
SelectionVariable
.I'm still working on finishing touches before making it widely available; meanwhile here are a few things that would be nice-to-have in the next release so that it keeps working, and can be made to work with less hackery:
_process_registry_value
inSelectionVariable
. I currently patch this function on that class.gremlin.input_devices.periodic
for my callback that passes the selection value to the library to set as output device. Ideally the decorated function would be called on value selection only, but using periodic isn't that different so this is low priority. The periodic decorator does seem to be broken as well (for me it doesn't fire on the first "Activate" but does fire on subsequent activations).The whole thing relies on a few things which I'm capturing below:
Looking forward to your next release!