WhiteMagic / dill

Direct Input Listener Library - Provides joystick device information for DirectInput devices
BSD 2-Clause "Simplified" License
7 stars 5 forks source link

Adding FFB (Force Feedback) support #4

Open code-monet opened 3 weeks ago

code-monet commented 3 weeks ago

Dill doesn't currently have a concept of force feedback, this issue tracks implementing that. I'm prototyping it in my fork now, and will send pull requests your way when I have something.

In the meantime let me know if you have any preferences for the pull requests. I'll try to keep each PR small-ish and self-contained.

WhiteMagic commented 2 weeks ago

The main question would be what the purpose of this is. DILL is written for Gremlin, which has no notion of FFB, and I personally have no intention of adding support for that in Gremlin anytime soon. One main aspect is also that it shouldn't really break API compatibility with what Gremlin is running now, nor conflict with Gremln supporting XInput in the future which is a much more pressing aspect for DILL.

code-monet commented 2 weeks ago

All good points! I'm looking into adding support for FFB in Gremlin, but am having issues running that project at the moment, will open an issue there. I'll do it in a minimally invasive way so it shouldn't be a huge delta for the Gremlin Python and UI code.

I made a corresponding change for the API, once I can run the project I'll create a PR for that too.

XInput doesn't support FFB, so we'd simply not offer that option for XInput devices. Also just FYI that both DirectInput and XInput are deprecated in favor of GameInput, which sadly doesn't currently work with FFB racing wheels (and it's probably too green to be used on PC just as yet).

WhiteMagic commented 2 weeks ago

What would FFB in Gremlin look like? Just a pass-through or more involved operations?

The deprecation of those APIs really doesn't matter since DirectInput has been "deprecated" for ages by now, and it's not going anywhere as there are too many games relying on it and libraries supporting it. So, I wouldn't bet on it being a factor for ages.

code-monet commented 2 weeks ago

Just pass-through - FFB is latency sensitive so it would be best not to bring any FFB data into the Python layer. I was thinking, a DLL that you can call into to register the Vjoy FFB handler, and any functions needed to configure (e.g. specify which device to send FFB calls to).

WhiteMagic commented 2 weeks ago

That does seem quite out of scope for dill. The library's purpose is to receive device events, turn them into a specific structure, and inform a single registered callback of the new event. That scheme will work for XInput devices or inputs as well, but FFB is an entirely different sort of data. This is even before talking about pass-through functionality from one device to another, be that physical or virtual. Dill doesn't even know what vJoy is, nor should it ever do, as vJoy devices can be input or output devices for Gremlin, depending on their usage.

code-monet commented 1 week ago

Agreed with you that the FFB stuff doesn't belong in Dill - that would be a separate DLL that Joystick Gremlin would call into. For Dill, the existing pull request #6 is probably all that's needed - just enough to tell the DLL which FFB-capable device to send VJoy FFB data to.

I'm prototyping the code and it might take a while - feel free to ignore or drop the PR #6 and I can circle back to you later and see if you're interested.

WhiteMagic commented 1 week ago

Yeah, at this stage I can't tell what your design looks like, so can't really make any comments about whether that can realistically fit with Gremlin and/or dill as you imagine. When you have something concrete I may be able to better tell.