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

Stuck input after typing a sequence into a debug console #110

Open
Aadam-Marshall opened this issue May 27, 2024 · 2 comments
Open

Stuck input after typing a sequence into a debug console #110

Aadam-Marshall opened this issue May 27, 2024 · 2 comments

Comments

@Aadam-Marshall
Copy link

Aadam-Marshall commented May 27, 2024

I guess this issue is related to the fact that I also use PowerToys' Keyboard Manager in combination with capsicain.

Take this config as an example:

[CONFIG_1]

OPTION Debug
GLOBAL DebugOnStartup
#GLOBAL StartMinimized
#GLOBAL StartInTraybar
OPTION DelayForKEYSequenceMS 0 

REWIRE CAPS MOD15
COMBO X [.&.. .... .... ....] > sequence(HOME_HOME_&LSHF_END_RIGHT_^LSHF_&LALT_2_^LALT) # cut whole line

ALT+2 is mapped to CTRL+X in the PowerToys' Keyboard Manager.

Note that capsicain takes precedence over KM and sits lower than it. At first, capsicain's input (rewires, combos, etc) is processed, then it gets sent to KM and gets processed there.

Now, when I open capsicain with its debug console and press CapsLock + X (COMBO X) there, the output isn't finished and gets stuck:
1

Now, the Alt key is permanently pressed, it is stuck: whatever I press, it gets processed with Alt (pressing C will result in Alt+C)

Even if I close capsicain, it doesn't fix anything - the Alt is still stuck. Nothing will help except two things:

  1. If I close capsicain, I can open it again and press Alt into the debug console, the input will get unstuck.
  2. If I don't close capsicain and stay with the stuck unfinished command, I can press right mouse button and the command will finish itself, the input will get unstuck, and I can type normally again:
    2

The sequence in the debug gets stuck exactly when LALT is pressed (when the sequence gets to pressing LALT, that is).

In my COMBO X, I tried replacing &LALT_2_^LALT with &LCTRL_P_^LCTRL as an experiment (CTRL+P just because it doesn't have a shortcut, an empty combo), and it's the same story - input gets stuck.

Though I don't know on whose side the problem is - on capsicain's or PowerToys'.

@cajhin
Copy link
Owner

cajhin commented May 28, 2024

it's a little difficult to play that back in my head.

Possible gotchas:

  1. Powertoys is very fast and fires ctrl-x before capsicain releases alt (I don't know exactly if/how they would interfere).
  2. you have the debug console in the foreground and key events are directed to it. Note that every Windows console app will freeze when you select text in it. I disallow simple selection with the mouse for this reason, but maybe you found a way around it.

If Windows falsely thinks LALT is down, pressing and releasing LALT should fix it (unless capsicain is frozen and blocks key input).
In the debug output, when LALT is stuck, do you see a value for [M: ] ? If not, then capsicain has released the key.

Now I don't get why you make it so complicated. Why don't you simply do sequence(HOME_HOME_&LSHF_END_RIGHT_^LSHF_&LCTRL_X_^LCTRL) ?
and leave Powertoys out of the game?

Note: double Home does not always put the cursor into col1 - that is controlled by the editor.
Another way to delete a line is UP END RIGHT Shift+DOWN (but this fails when you're in line 1).
If you're sure that 2xHOME works for you, another fast option is HOME HOME Shift+DOWN Ctrl+X

Please let me know if you could fix it.

edit: (correction: in the log, #0 #1 #2 etc. is not the key event but the number of keys that are down. You live and learn, you live longer and forget...)

edit 2: ok this might be your error case.
When you are in the capsicain console window and press shift LEFT LEFT LEFT, you get a selection, which freezes capsicain, which blocks the shift up. which doesn't let you cancel the selection.
Result: Shift is permanently down
One way out is to keep shift pressed while you right-click into the console windows.
Or close capsicain, then press+release shift.
I guess something like that happens with your ALT and SHIFT

@Aadam-Marshall
Copy link
Author

every Windows console app will freeze when you select text in it

I have just now researched a bit about it. Sorry for wasting time if you already know it.
It doesn't really freeze but goes into selection mode, is that what you meant? (see here: https://stackoverflow.com/a/33883532). To unselect, you have to press Esc, Space, Tab, or right mouse button. When input is stuck in capsicain, it goes into selection mode too, the title bar is now "Select Capsicain v97" instead of "Capsicain v97". But unlike in other consoles, unstucking in capsicain only works with right mouse button, I guess this is because the keyboard is stuck with pressed Alt, and the console won't accept Alt+Esc, Alt+Space, Alt+Tab.

when LALT is stuck, do you see a value for [M: ] ?

It's in my screenshots, the value is 4000. By the way, what do M:, T:, and D: mean?

Why don't you simply do sequence(HOME_HOME_&LSHF_END_RIGHT_^LSHF_&LCTRL_X_^LCTRL) ?

I have LCTRL+X mapped to another combo in PowerToys. But you are right, I can map RCTRL+X instead. I was just testing some other peculiar stuff, and I checked my combos in the debug console of capsicain, and that's how I found this problem.

If you're sure that 2xHOME works for you

I've started using capsicain only this week, so I'm just figuring it all out at this point, with the help of the wiki, your own config, and capsicain.example.ini. Thank you for suggestions! I didn't know for what purpose there are two HOMEs and why only one HOME isn't sufficient.

Please let me know if you could fix it.

No, and the thing is: I tested a little more, and the issue persists even when PowerToys is not running at all. I guess it isn't related to PT? In this case, you can reproduce it yourself, the config is the same as in my issue, but with RCTRL+X:

[CONFIG_1]

OPTION Debug
GLOBAL DebugOnStartup
#GLOBAL StartMinimized
#GLOBAL StartInTraybar
OPTION DelayForKEYSequenceMS 0 

REWIRE CAPS MOD15
COMBO X [.&.. .... .... ....] > sequence(HOME_HOME_&LSHF_END_RIGHT_^LSHF_&RCTRL_X_^RCTRL)  # cut whole line

Anyway, after learning about the selection mode of the Windows console, I now see that this a natural behavior. But the issue with capsicain is still there, though it's not a big thing. But people may freakout after testing their combos and getting stuck, discovering that their keyboard input doesn't work at all. If this isn't fixable maybe you could put a line in the debug console saying that "if the input gets stuck - press RMB".

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