Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicks not working in Dwarf Fortress (steam version) #15

Closed
mimuki opened this issue Dec 24, 2022 · 4 comments
Closed

Clicks not working in Dwarf Fortress (steam version) #15

mimuki opened this issue Dec 24, 2022 · 4 comments

Comments

@mimuki
Copy link

mimuki commented Dec 24, 2022

This issue also exists in keynav, but I figured it would be helpful to also mention it here. Any keynavish clicks in DF don't actually click anything in game. I've tried both fullscreen and windowed modes, with no luck. This might be something that has to be fixed by the DF devs, but I wanted to make an issue here so that when I tell them about it, I at least have someone familiar with the keynavish codebase to back me up when i say "hey DF devs pls fix".

Observed on Windows 10, version 2004

@mimuki
Copy link
Author

mimuki commented Dec 24, 2022

I've been asking around the internet, and someone more tech literate than me had this to say, which might be useful to know? I get the impression that this implies an incompatibility "higher up the chain", but make of it what you will.

DF uses SDL for input, and calls this -
https://wiki.libsdl.org/SDL2/SDL_PollEvent
KeyNavish on Windows uses standard Window messaging for clicks, and calls this -
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
I took a brief look in DF, SDL, and KeyNavish, and it's not obvious to me why they aren't communicating with each other properly without really getting into the weeds.
I'm not sure where you'd ask for support, but you'd probably be asking something along the lines of "Hey, my accessibility software uses SendInput(...) and an SDL-based game I like isn't recognizing the inputs properly".

@lesderid
Copy link
Owner

Interesting, looks like I can reproduce it with the free version of Dwarf Fortress. I'll try to debug it, but sadly I'm not very hopeful there is an easy fix for this.

@lesderid
Copy link
Owner

There seems to be something specific about the game code that is keeping it from working. The events received from SDL are identical. I added some debug output to SDL and got the following results:

Real click:

mouse button event: type:  down, device:  0, button:  1, state:  pressed, coords: (  590,   481),
mouse button event: type:    up, device:  0, button:  1, state: released, coords: (  590,   481),

keynavish click:

mouse button event: type:  down, device:  0, button:  1, state:  pressed, coords: (  590,   481),
mouse button event: type:    up, device:  0, button:  1, state: released, coords: (  590,   481),

@lesderid
Copy link
Owner

lesderid commented Dec 27, 2022

So apparently the game requires a delay between click events (mouse down and mouse up) for them to register. The commit I just pushed (binaries here: https://github.com/lesderid/keynavish/releases/tag/v1.5.0) adds an option to set a delay between the events.

You can configure it globally (just add a line with x-set-delay <milliseconds> somewhere in your config), or you can add it to a command sequence (e.g. space warp,x-set-delay <milliseconds>,click 1,x-set-delay 0,end) so it only applies to certain configured keys.

The command (x-set-delay) is prefixed with x- because it's not implemented in the original keynav.

Edit: For Dwarf Fortress, a value of 5 (milliseconds) seems to work. It might be tied to frame rate, so I'd play around with a few values to see what works for you.

Edit 2: FWIW, this a hack. The DF devs should keep processing events until SDL_PollEvent returns 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants