JibbSmart / JoyShockLibrary

Read DualSense, DualShock 4, JoyCon, and Pro Controller input on PC -- compiled for Windows, but code should work on other platforms.
Other
232 stars 46 forks source link

JslSetRumble GetOverlappedResult (hidwrite/hid.c) doesn't return (blocks) #63

Open m-7761 opened 1 month ago

m-7761 commented 1 month ago

I can kind of get this API to work if I only use it every so many game frames, and disable the WAIT requirement on GetOverlappedResult.

Even still it freezes and crashes. If I take no countermeasures the game freezes (locks up) as soon as the rumble in nonzero.

This function is being called either way, so I imagine the device ignores values that don't change the rumble state.

I realize this is a different library, and my source code for your project is dated. I had/have a version that doesn't recognize the DualSense for JslSetRumble because the DS4 enum is used to test for it, but I can see that's been fixed in your code here on Github. Anyhow, that's how old my code is.

Edited: I'm just starting out and doing things in my main render thread. I'm thinking that might be a bad design.

JibbSmart commented 1 month ago

It's probably better to do input on a different thread. But still, JslSetRumble shouldn't be causing crashes. How often are you calling it? Is there some kind of error, or is it just taking too long to return? Does it always return eventually as far as you can tell?

Cheers

m-7761 commented 1 month ago

I'm kind of using it now, but it's finicky. It seems like manually setting it to 0 (or 0,0) helps. I'm initiating it from a main thread, and having it tail off in a utility thread that manages cursors and stuff.

BTW I'm trying to add it to this (https://swordofmoonlight.itch.io/k) project... and game maker system. I've also been able to use the motion feedback to let players spin "items" around as if they're in their hand. It helps in that case to get the initial state of the controller (when the item is selected) and cancel it out in the rotation. I assume that's something games that use motion (somehow) have to consider.

It's probably better to do input on a different thread. But still, JslSetRumble shouldn't be causing crashes. How often are you calling it? Is there some kind of error, or is it just taking too long to return? Does it always return eventually as far as you can tell?

It's never returning, but it eventually started crashing after a while. GetOverlappedResult is set to WAIT, and it just happily waits forever because the driver isn't responding or something. I'm not sure what is considered sensible usage of rumble. I'm trying to let it "telegraph" monster "attacks" because in this kind of game catching them by eye seems too slow/ambiguous to not frustrate.