susam / uncap

Map Caps Lock to Escape or any key to any key
MIT License
1.07k stars 43 forks source link

Breaks in video games #4

Open azy2 opened 6 years ago

azy2 commented 6 years ago

I use this program to swap esc and caps lock and left control with left alt:

uncap.exe 0x14:0x1B 0x1B:0x14 0xA2:0xA4 0xA4:0xA2

But inside of video games neither key works. Pressing neither caps lock nor esc brings up the menu.

At least in my case it would be okay if the program didn't work in video games, that is the keys performed their original function. But it seems to break the keys all together.

Any ideas about why that is or how to work around it? If you have any ideas I'll look into fixing it and make a pull request.

pfeiferbit commented 6 years ago

Perhaps it would be possible for a new feature to allow us to define another keybinding with which we can toggle the other keybinds/swaps on and off.

People might forget pressing that key before starting a game but then ALT-TAB or CTRL-ALT-DELETE may allow you to go to the desktop where the uncap keybindings work normally.

Another very overcomplicated solution could be to define filters for process names/executable paths and when these processes are running (like csgo.exe) to temporarily disable the keybinds/swaps.

Other than that I don't really see a solution. Most games directly talk to the input device drivers themself and not use the abstraction provided by Windows. Of course this will conflict with uncap.

This issue is partly the reason for my uncap setup described here: https://github.com/susam/uncap/issues/1#issuecomment-362890524

susam commented 6 years ago

Thank you for reporting the issue in detail.

I understand that the command you have mentioned in this issue, i.e., uncap.exe 0x14:0x1B 0x1B:0x14 0xA2:0xA4 0xA4:0xA2 is supposed to perform the following key swaps:

Can you help me with the following information so that I can better understand how Uncap behaves in your environment and what could be causing the issue.

pkubik commented 4 years ago

The default behavior (change caps-lock to escape) seems to not work with SDL2 key events (and therefore likely indie games). The SDL2 does not detect any event upon pressing the Caps Lock key. Note - no event, not even a scancode is given. I've been using Rust bindings for SDL2 if that changes anything.

Other windowing libraries do not share this issue, e.g. winit-rs. Other solutions, such as AutoHotKey work both with SDL2 and other libraries. This is beyond my knowledge on the keyboard handling.

uncap.exe -d with Caps-Lock pressed 3 times:

KEYUP        0     0 128 -   -   -   -   UP   28  13 (RETURN)
KEYDOWN      0     0   0 -   -   -   -   -    58  20 (0x14)
KEYDOWN      0 35963  16 -   -   INJ -   -     0  27 (0x1B)
KEYUP        0     0 128 -   -   -   -   UP   58  20 (0x14)
KEYUP        0 35963 144 -   -   INJ -   UP    0  27 (0x1B)
KEYDOWN      0     0   0 -   -   -   -   -    58  20 (0x14)
KEYDOWN      0 35963  16 -   -   INJ -   -     0  27 (0x1B)
KEYUP        0     0 128 -   -   -   -   UP   58  20 (0x14)
KEYUP        0 35963 144 -   -   INJ -   UP    0  27 (0x1B)
KEYDOWN      0     0   0 -   -   -   -   -    58  20 (0x14)
KEYDOWN      0 35963  16 -   -   INJ -   -     0  27 (0x1B)
KEYUP        0     0 128 -   -   -   -   UP   58  20 (0x14)
KEYUP        0 35963 144 -   -   INJ -   UP    0  27 (0x1B)
KEYDOWN      0     0   0 -   -   -   -   -    29 162 (0xA2)
KEYDOWN      0     0   0 -   -   -   -   -    46  67 (C)