Qiasfah / Null-Movement-Script

170 stars 19 forks source link

Key stuck #8

Closed skyhilade closed 2 months ago

skyhilade commented 3 months ago

I don't know if that's a problem on my side but sometimes while i'm playing my keys will get stucked, like for example: If i press A and then D and A again and release A, sometimes my character will just keep moving for D direction like the key is pressed (it's not always like that but i think u can get what i mean with this) Hope there's a fix for that since i really liked the project

dresiarz222 commented 3 months ago

im also experiencing this issue, the lack of movement consistency makes this script do more bad than good in pro gameplay, please take a look at this issue, this is an amazing script for people without the razer/wooting keyboards @Qiasfah

tkp206093 commented 3 months ago

+1

Qiasfah commented 3 months ago

Are you guys using the v2 script? What game are you seeing this on?

Getting a key stuck makes this pretty useless, I used it for years with none of these issues, but that was with the previous v1 script: https://github.com/Qiasfah/Null-Movement-Script/blob/46b045cd9b100b2b59de4f3820cc405721a63e26/Null%20Movement.ahk

Qiasfah commented 3 months ago

I haven't been able to reproduce this, also it'd be helpful to know what keyboards yall are seeing this on (I'm wondering if the n-key rollover limits some keyboards have could cause interesting interactions here)

skyhilade commented 3 months ago

I tried with Valorant & Overwatch but it seems like it's a problem with ahk 2.0 for some reason, i tested theawful-falafel fork and it started working as intended (his is in 1.1), should probably be due to some conflict that requires code workaround idk My keyboard is an Akko 5075s

tkp206093 commented 3 months ago

Using the v2 script I tried with Apex Legends My keyboard is an G915

herovaxy commented 3 months ago

Same issue. It's sometimes go D key even if I already releasing the D key. To reset it, I need to press D once more.

I'm using 𝗞𝗲𝘆𝗰𝗵𝗿𝗼𝗻 𝗩𝟭 𝗤𝗠𝗞 𝗖𝘂𝘀𝘁𝗼𝗺 𝗠𝗲𝗰𝗵𝗮𝗻𝗶𝗰𝗮𝗹 𝗞𝗲𝘆𝗯𝗼𝗮𝗿𝗱 (𝗥𝗲𝗱 𝗦𝘄𝗶𝘁𝗰𝗵).

Edit: I can confirm this version by awful-falafel fixed the key stuck issue. https://github.com/awful-falafel/Null-Movement-Script

Qiasfah commented 3 months ago

Yea, I hadn't seen these issues with the v1 script either, I made some changes to the v2 script here to hopefully fix it

dresiarz222 commented 3 months ago

im using razer ornata chroma on roblox and the awful-falafel fork indeed fixed the issue

dresiarz222 commented 3 months ago

issue still reoccuring on the updated Qiasfah version, i think ahk v2 is at fault

Qiasfah commented 3 months ago

Interesting, well I found another potential cause and pushed a change to set some threading things and allow buffering of events. My idea here is that if two things happen too close together, and there's not a ton of CPU time available, both events may be handled in parallel (causing race conditions with the variables if and value sets) in combination with it not buffering inputs so that every keyboard event is properly handled. Let me know if this helps (I still haven't been able to reproduce, but my machine is pretty fast so it may not run into these resource limitations)

FireNinja7365 commented 3 months ago

i made this fancy little debug thing that is mostly useless, but maybe it'll be helpful

debug thingy.txt

Qiasfah commented 3 months ago

That's pretty great, can anyone tell me what that says when the d key is stuck?

Mqrch commented 3 months ago

when D key stuck:

A: held=0 script=0 actual=0 D: held=1 script=1 actual=1

Qiasfah commented 3 months ago

That's fascinating, ahk thinks the key is pressed but it's not?!

Mqrch commented 3 months ago

not sure, but the script from 2023 (the one that uses autohotkey v1.1) works fine, only the autohotkey v2 one gets the key stuck for me

FireNinja7365 commented 3 months ago

the old version also gets stuck it's just much less common

Mqrch commented 3 months ago

Added the keyboard hook: InstallKeybdHook and replaced the held key values with a GetKeyState statement. It doesn't seem to get stuck anymore but I'll keep testing it. Let me know if it solves the issue for anyone else Null Movement stuck fix.txt

Mqrch commented 3 months ago

Okay nevermind, it's still happening. This didn't fix anything, maybe it happens less often but I think it's probably more less the same.

For some reason even with the keyboard hook, AHK still thinks I'm pressing the A or D key. The debugging is exactly the same as before: A: held=0 script=0 actual=0 D: held=1 script=1 actual=1

Qiasfah commented 3 months ago

I'm not sure how to even fix this, if AHK thinks the key is pressed and it's not, that's a problem with AHK.

If this printout showed a case where actual differed from script, then it could be a bug in the script.

Qiasfah commented 3 months ago

Perchance have you tried running the script as admin?

Mqrch commented 3 months ago

Yeah, I always run it as admin because otherwise it doesn't work on some games that are also running as admin

Nephyres commented 3 months ago

Same issue as previous, I'm using a zoom75 custom board. My best guess based on comments is the boards actuation timing. a g915 has a 1.5mm actuation which is fairly fast, same with higher end custom boards and some switches. the keychron with reds would probably be pretty fast actuation too depending on which red switches. I would guess ahk isnt detecting the deactivation of a key because it happens too soon. Will test the awful-falafel fork soon. Looking at the scripts i can see 'Sendinput' vs 'send' awful-falafel fork uses send which is slower, and sendinput is faster, if ahk is having issues with detecting deactivation then giving it extra time could potentially be whats solving the issue. i also noticed ur limiting the threads to 1. If the A or D key events are being processed, it can prevent other key events from being handled promptly, causing the keys to appear "stuck". The variables are also defined at the beginning which could prevent some latency/delay but thats so minimal its hardly worth mentioning tbh. food for thought

could also entirely be because its using ahk1 instead

GangsterVogel commented 3 months ago

hey man i hope this works i also have added some more keybinds like control,shift,z,c,space without delay i hope it works without getting stuck! cool.zip

FireNinja7365 commented 3 months ago

Gangster you forgot the source code in that latest one, and i don't exactly trust random .exe files

GangsterVogel commented 3 months ago

Gangster you forgot the source code in that latest one, and i don't exactly trust random .exe files null-movement-script.txt

FireNinja7365 commented 3 months ago

ah, did you give up on trying to get it to work with the HandleKeyPress functions and stuff? (it still let's us look at the old edited versions of your post)

GangsterVogel commented 3 months ago

ah, did you give up on trying to get it to work with the HandleKeyPress functions and stuff? (it still let's us look at the old edited versions of your post)

updated version null movement with source.zip

Yes, i was sleeping but its working it runs you can now play every game with the previous keymapping + includes HandleKeyPress and control,shift,z,c,space

GangsterVogel commented 3 months ago

ah, did you give up on trying to get it to work with the HandleKeyPress functions and stuff? (it still let's us look at the old edited versions of your post)

updated version null movement with source.zip

Yes, i was sleeping but its working it runs you can now play every game with the previous keymapping + includes HandleKeyPress and control,shift,z,c,space

@Qiasfah i have updated your script can you include those two versions

GangsterVogel commented 3 months ago

ah, did you give up on trying to get it to work with the HandleKeyPress functions and stuff? (it still let's us look at the old edited versions of your post)

hey man i have updated it once more ehm, i added a delay of 1 milisecond (inf things) but it removed the rapid fire stuff what removed the multiple keybind stuff, so here is the new file, i tried testing it but it keeps spamming b or m when i press w,s,d,a but fixed it too with a little extra delay of yeah you can see in the source its a mini-delay like 1 milisecond but dont worry its not impactable on your gameplay or change it what you like! updated version null movement with source.zip

FireNinja7365 commented 3 months ago

i'll test it and see if it actually fixes the keystuck stuff

GangsterVogel commented 3 months ago

i'll test it and see if it actually fixes the keystuck stuff

works?

FireNinja7365 commented 3 months ago

after some testing i've found a few things..

1 your passthroughs for the control, shift, c, and z are completely pointless, all it does is adds more latency, i could be wrong though because i'm having a few issues with one of my scripts that looks similar

2 as an example, if you press A and then press D, when you release D and are still holding A it doesn't press A back down

GangsterVogel commented 3 months ago

after some testing i've found a few things..

1 your passthroughs for the control, shift, c, and z are completely pointless, all it does is adds more latency, i could be wrong though because i'm having a few issues with one of my scripts that looks similar

2 as an example, if you press A and then press D, when you release D and are still holding A it doesn't press A back down

ehm, i can try and fix it

Qiasfah commented 3 months ago

Why are you defining key handlers for the other buttons in the first place? The * modifier and {Blind} is intended on supporting any combination of those keypresses at the same time as the null keys: https://www.autohotkey.com/docs/v2/lib/Send.htm#Blind

AnasAlzhr commented 3 months ago

I played overwatch 2, cs2, and valorant using this keybind code and faced similar issues. On cs2 I followed a different method to apply the feature and it works flawlessly. I understand the coding language is different but this was the guide I followed: https://www.youtube.com/watch?v=z65SgdAFP54&t=1s

I use a GMMK Pro - I use different keybinds as well. Instead WASD, I use ESDF. In which I only changed the key identification codes and the letter changes within the code and it works great. I did use ChatGPT to ensure I didn't miss anything and it worked fine without changing anything in the code.

The issue I faced is also with the D key. My character would backwards in game without any input from my end. However, when I do press the opposing key (E - being forward) there would a null input and my character wouldn't move. I'd have to let go of all buttons, my character would move backward, then press D and it would stop. Although the code is made to overlap inputs. This issue seems interesting because at some point the overlapping completely stops.

I tried to read through the comments here hoping I wouldn't a duplicated message. sorry if i do so lol.

Hope this helps and thank you so much for this it is really fun to use while being able to save up some money.

FireNinja7365 commented 2 months ago

null binds with handlekeypress function.txt

try this one out, i fixed gangster's ai written code to actually work (sorry gangster but that code really does look ai written) @GangsterVogel @Qiasfah

edit: i don't have the time to test it too much because i only tested it on a laptop for 15 seconds so idk if it will fix the keystuck stuff or not. also i might make a more advanced version with an options.txt that lets you pick custom key pairs

FireNinja7365 commented 2 months ago

after testing it on my pc i can confirm that it does not fix the issue :(

Qiasfah commented 2 months ago

The debugging here is showing that AHK itself thinks the keyboard is in a state it is not, there's nothing I can do in the script to fix this issue.