cajhin / capsicain

Powerful low-level keyboard remapping tool for Windows
349 stars 18 forks source link

beginner question #5

Closed yoloswaggerboy69 closed 3 years ago

yoloswaggerboy69 commented 3 years ago

hey, first of all sorry for asking such a beginner level question but I'm having problems understanding the config file. I understand that this program is really involved and the main reason I'm trying to use it is that autohotkey doesn't work with the music software i use. all i really want to do is remap a couple of shortcuts so they match the keystrokes of mac os so i can build muscle memory.

so essentially just basic stuff like making alt+s send ctrl+s and so on.

i must admit even the simpler config file is quite overwhelming.

if you could give me a basic pointer on how to add my custom mappings i'll definitely be able to figure out the rest from there i just need a little bit of help to get started.

thank you very much

cajhin commented 3 years ago

Don't worry, the config system is quite technical and more suited to a coder brain. It's still easier than writing a GUI for it, though, so here we are... Just give me a list of mappings you want to have and I'll send you the ini for it.

yoloswaggerboy69 commented 3 years ago

thank you very much, i think i'll be able to figure it out the pattern from the ones below:

alt+c -> ctrl+c alt+v -> ctrl+v win+shift+n -> alt+shift+n

is there also a way to somehow make the actual hardware keyboard keys ctrl+c not do anything so that i can actually train myself to use the different mappings? i don't want to make the actual keys inactive just set the shortcut from the hardware keys ctrl+s to do nothing. sorry if the explanation is a little weird i could try to explain it again if it is too confusing.

cajhin commented 3 years ago

Here's your config. See if it works for you. Just copy and paste into capsicain.ini Ask if you can't figure it out (your approach is a bit tricky)

# config file to remap some Alt/Control combos
# This detailed modifier kung fu is a bit tricky by nature.

# Easier approaches, where possible, are
#   1. globally switch the ALT and WIN keys (there's extra support for that)
#   2. rewire a modifier to a virtual modifier (Windows does not see them, which makes it easier),
#      but then you must define ALL possible combos with that key.

# Press [ESC] + [R]  to reset/reload any changes you make to this file.

GLOBAL IniVersion yoloswaggerboy69-v1
                #any string, so you can check with [ESC]+[S]tatus if you're running the right config

GLOBAL ActiveLayerOnStartup 1
                #This layer is active on startup
                #Switch to "Normal Windows keys" with [ESC]+[0]
                #Switch to this config with [ESC]+[1]

[LAYER_1]
OPTION layerName = Reconfigure-Alt-Ctrl-combos

# ║  Modifier labels and "modstring order" are:        ║
# ║  RALT RWIN RCTRL RSHF    LALT LWIN LCTRL LSHF      ║
# ║   '&' stands for "and with this modifier"          ║

    #LeftAlt+C to (LCtrl+C and ^release the LeftAlt key first)
COMBO    C        [.... &...] > moddedKey (C + ^.&.)
    #hint:              ^ this position (4 from the right) stands for the LeftAlt modifier, '&' stands for 'and this is down'.
    #Windows already knows you pressed LeftAlt. Out of the box, this is unchanged, so you would effectively get "Lalt+LCtrl+C"
    #The ^ in [^.&.] means 'release the LAlt key if it is down. '&' means 'and press this modifier', in this case LCtrl. '.' means 'whatever'.

    #RightAlt+C to LCtrl+C. (out of the box, Left and Right modifiers are different keys and need different rules)
COMBO    C        [&... ....] > moddedKey (C + ^... ..&.)

    #Disable LCtrl+C (just map to RCtrl which does nothing on its own)
    #Note to self: key (NOP) does not work, a special case I just discovered. Scancode zero... fix this
COMBO    C        [.... ..&.] > key (RCTRL)

    #LeftAlt+V > LCtrl+V, release LAlt
COMBO    V        [.... &...] > moddedKey (V + ^.&.)

    #LWin+LShift+N > LAlt+LShift+N, release LWin
COMBO    N        [.... .... .&.&] > moddedKey (N + &^.&)
yoloswaggerboy69 commented 3 years ago

oh wo thank you so much, this is the first option that was compatible with pro tools, even the ctrl+c blocking method works perfectly.

So generally which method would you recommend? the one with the virtual modifier or the classic remap ? I think I'll have to remap the shortcuts manually since some of them switch hardware keys between windows and mac (meaning just switching win and alt doesn't really work in my case)

thank you again for your support I appreciate you taking the time and even adding comments to the code :)

cajhin commented 3 years ago

Depends on what you want to have in the end. If you just need to replicate a couple of Mac shortcuts on the Alt key, go ahead with the current strategy.

If you think you'll end up mapping every single CMD-x combo from the mac, I'd map LWin to LAlt, and map LAlt to virtual modifier MOD12, which will be your new CMD key (which also means you lose the Win key - do you use it?). Then define your two dozen combos with that mod12. The advantage of virtual modifiers is that Windows does not see them at all, so there are no subtle side effects that you may need to fix (Windows does some extra things with modifiers like Alt tapped focuses the app menu, shift+alt switches language, those things tend to cause annoying accidents when you're not typing precisely).

If you end up with a ton of custom key mappings and macros (which can be super powerful if you have common workflows), I myself use and prefer the "virtual modifier" approach. Starting with CapsLock, which is my virtual MOD9 (that's where the logo came from), with lots of controls for editing text.

yoloswaggerboy69 commented 3 years ago

hey, I've been thinking about the best way of tackling this and I had the thought that it would be immensely helpful to deactivate keyboard input entirely, except for the keys/ shortcuts that are manually specified because otherwise i would have to map all the mac shortcuts in addition to disabling all the windows ones. is there any way of pulling that off?

thank you so much for your continued support and patience.

cajhin commented 3 years ago

I'm not quite sure I understand your goal. Do you really want to completely disable your keyboard, except a bunch of shortcuts that you explicitly define? As in, "you press the A key, no combo is defined for that, the key is dropped"? That might be a simple hack with alphamaps, just map every non-modifier key to NOP (no operation. Didn't test if this works, NOP is a bit special since scancode 0 is also the code for "an error happened". Gotta clean that up).

If you just want to disable all the default shortcuts like Ctrl-A for "select all", then I'm afraid you have to write one rule for each shortcut.

yoloswaggerboy69 commented 3 years ago

hey, just wanted to check in and let you know that after some trial and error it finally clicked and now I'm making good progress on the remapping but i ran into an issue which I'm not quite sure to fix.

in pro tools certain functions are accessed by holding CMD (CTRL on Windows) and then clicking on an on-screen item. I'm aware that I can use rewire to switch the two keys but that breaks my other shortcuts. Is there a way to either integrate mouse keys or do a form of rewire that doesn't apply to the other combos ?

thank you!

cajhin commented 3 years ago

capsicain does not see the mouse, so you can't do anything with it. The Interception driver below can give access to mouse events, but I had no need for it; and also, the mouse is more time-sensitive than the keyboard (if you're a blazing fast typist, you could generate 20 key events per second max; your mouse can easily generate much more than that, so every millisecond counts).

I understand you want (LAlt + mouseclick) to always result in (LCtrl + mouseclick). Since you don't see the mouseclick, all you can do is rewire LAlt to LCtrl, fixed and globally. Also LCtrl to LAlt. Then you have to redefine all combos that involve LCtrl and LAlt. PITA but no alternative.

Changing an existing config isn't too bad, with a clever find+replace in your text editor, like

  1. find "&...]" replace "..x.]"
  2. find "..&.]" replace "&...]"
  3. find "..x.]" replace "..&.]" This will swap all combos with LAlt and LCtrl.

After rewiring, Windows combos that you did not define will of course change. Ctrl-S will then become Alt-S, for example, unless you define a rule for the "former Ctrl key that is now Alt key", like "Alt-S > Ctrl-S".

yoloswaggerboy69 commented 3 years ago

okay I've been (over)thinking about this and I can't seem to figure out how to do the mapping in a way that works with these two shortcuts and doesn't break my other mappings.

Maybe you have an idea about how to tackle this because i Just can't seem to figure it out.

This is directly from the Pro Tools Manual:

Record-safe track:

Mac:     Command-click on track Record Enable button              
Windows: Control-click on track Record Enable button

Cycle through record modes:

Mac:   Control-click on Transport Record Enable button                
Windows: Start-click on Transport Record Enable button

again I can't thank you enough for your help, you've brought me closer to my goal than any other piece of software ever has :)

yoloswaggerboy69 commented 3 years ago

OMG I'm the biggest idiot in the world, you literally told me the right way of doing it and i just completely misunderstood because i was overthinking it so much.

I can't believe I spent two days to get through about two pages of the shortcut manual, mapping every single shortcut, when the solution was literally this:

REWIRE LCTRL LWIN
REWIRE LWIN  LALT
REWIRE LALT  LCTRL
REWIRE RCTRL WIN
REWIRE RWIN  RALT
REWIRE RALT  RCTRL

I somehow thought they would cancel each other out or something dumb like that.

Just wanted to follow up and thank you for the millionth time can't believe i'm this stupid.

Thank you so much for your work!