cajhin / capsicain

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

Newbie, How to rewire keys on second BT keyboard (numpad)? (AHI related) #115

Open PeterP1975 opened 2 months ago

PeterP1975 commented 2 months ago

Hi, Sorry for asking on this forum, I know its AutoHotInterception related, but maybe its possible to make it in Capsicain only???

Setup: 2 BT devices: K380 logitech keyboard, 2nd is numpad from China that sends wrong keycodes (Keycodes 0-9 = the same in logitech keyboard number row). Lack of proper keycodes on numpad made me to remap numpad keys to proper ones: Numpad1, Numpad2 instead of 1, 2 etc. No changes to K380 logitech keyboard.

So far i have:

SingleInstance force

Persistent

include Lib\AutoHotInterception.ahk

AHI := AutoHotInterception()

keyboardId := AHI.GetKeyboardIdFromHandle("HID{00001124-0000-1000-8000-00805f9b34fb}_VID&000204e8_PID&7021&Col01") AHI.SubscribeKeyboard(keyboardId, true, KeyEvent)

return

WHAT NEXT? How to remap, i only have isolated keyboard (numpad) number.. OR How to rewire numpad keyboard using Capsicain?? Cheers Peter

cajhin commented 2 months ago

Hi

I'd approach it like this...

Switch the capsicain console to debug mode (ESC+D) Press 1 on keyboard, then press 1 on keypad. From your descripton, I assume both send the same keycode, labeled "1".

When you press a key on the keyboard, then a key on the keypad, you should see a message that the device has changed, and its ID, for example keyboard device id: hid{00001124-0000-1000-8000-00805f9b34fb}_vid&00020a5c_pid&8502&col01

Find a substring that is unique to the keypad (like "0001124")

For your capsicain.ini you need OPTION IncludeDeviceID 0001124 This limits all changes to the keypad. When a device whose ID does not contain "0001124" sends a key event, capsicain does not touch it. For a description see https://github.com/cajhin/capsicain/wiki/Keyword%3A-OPTION#option-includedeviceid-searchstring

Now you have to rewire regular number keys to "keypad number keys" REWIRE 1 NP1 REWIRE 2 NP2 ... REWIRE 0 NP0

That should work (I can't try it out right now)

Good luck, please let me know if you succeed Jörn

On 30. Aug 2024, at 18:37, PeterP1975 @.***> wrote:

Hi, Sorry for asking on this forum, I know its AutoHotInterception related, but maybe its possible to make it in Capsicain only???

Setup: 2 BT devices: K380 logitech keyboard, 2nd is numpad from China that sends wrong keycodes (Keycodes 0-9 = the same in logitech keyboard number row). Lack of proper keycodes on numpad made me to remap numpad keys to proper ones: Numpad1, Numpad2 instead of 1, 2 etc. No changes to K380 logitech keyboard.

So far i have:

SingleInstance force

Persistent

include Lib\AutoHotInterception.ahk

AHI := AutoHotInterception()

keyboardId := AHI.GetKeyboardIdFromHandle("HID{00001124-0000-1000-8000-00805f9b34fb}_VID&000204e8_PID&7021&Col01") AHI.SubscribeKeyboard(keyboardId, true, KeyEvent)

return

WHAT NEXT? How to remap, i only have isolated keyboard (numpad) number.. OR How to rewire numpad keyboard using Capsicain?? Cheers Peter

— Reply to this email directly, view it on GitHub https://github.com/cajhin/capsicain/issues/115, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBEBJVW6VCVHYRLAJBWW3DZUCNU5AVCNFSM6AAAAABNMZR6XSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ4TONZWGA2TCMI. You are receiving this because you are subscribed to this thread.

PeterP1975 commented 2 months ago

Hi, apologies for my delay

Unfortunately there are my device ids (connected via BT): dev id numpad hid{00001124-0000-1000-8000-00805f9b34fb}_vid&000204e8_pid&7021&col01 - this one must be rewired dev id K380 hid{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b342&col01 and they both have the same substring: 00001124, vid and pid are different

I'd like to add that i have LWin::F24 on K380 but in AutoHotkey.ahk config file (is run by capsicain).

Any thoughts on:

  1. How to rewire keys on numpad with the same substring as K380 (vid & pid different)
  2. Next question: Maybe all should be rewired by capsicain.ini (I mean Lwin to F24 - on K380, not only certain keys on numpad). Lwin remapped to F24 behaves strangely when rewired on upper level than driver level (I mean rewired via AutoHotkey.ahk). In Blender i cannot use rewired to F24 key (used similarly as Ctrl, Shift - as a modifier key) with certain letter keys. I ASSUME that Windows shortcuts interfering with Blender shortcuts.

So i think all should be rewired by capsicain.ini. Lwin to F24 on K380 keyboard AND certain keys on numpad.

How to do it?

CONFIG capsicain.ini GLOBAL StartInTraybar GLOBAL startAHK [CONFIG_1]

CONFIG AutoHotkey.ahk

Requires AutoHotkey v2.0

LWin::F24

Cheers Peter

cajhin commented 2 months ago
  1. you can use any unique substring from the device id, like "000204e8_pid" or "7021"
  2. sorry capsicain can't do what you want. You cannot put the definitions for both devices into one config, because keyboard and numpad send the same key events (plain numbers), so you can't define different results for these keys. When you use two configs, one per device, then you'd have to switch them manually. There is no "autoswitch config on device change". A feature I might implement one day... The OPTION includeDeviceID limits the config to one specific device, and will ignore the other one.

For your keyboard, you would want an ini like

GLOBAL StartInTraybar
GLOBAL startAHK

[CONFIG_1]
OPTION ConfigName myKeyboard
OPTION includeDeviceID b342
REWIRE LWIN F24

...but that of course ignores your numpad. Not sure what F24 is supposed to do for you. I guess that Blender gets its key events from a lower level, which might not work with AHK. That's one of the reasons I made capsicain. I've used Blender and it generally worked with capsicain. Might be that 3D navigation with keys is choppy, if you use anything other than REWIRE for the navigation keys (I don't know, I gifted myself a 3dConnextion Space Mouse, which is very cool :)

PeterP1975 commented 2 months ago

F24 in my case should work as another modifier key (like ctr, shift, alt). Blender compared to eg 3ds Max has a lot of keybindings (I mean A LOT - with new Blender 4.2 extension platform for example letter "t" has 26 bindings and this is not an exception "r"is about 27..) Another thing: 2 BT HID devices: I needed Numpad to be on the left side of the keyboard. Right side Numpad's location is totally useles as my right hand uses mouse, my left hand uses left located numpad and BT keyboard.

Anyway: cajhin = God Like Person

My config now: GLOBAL StartInTraybar GLOBAL startAHK

[CONFIG_1] OPTION ConfigName K35 OPTION includeDeviceID pid&7021& REWIRE 1 NP1 REWIRE 2 NP2 REWIRE 3 NP3 REWIRE 4 NP4 REWIRE 5 NP5 REWIRE 6 NP6 REWIRE 7 NP7 REWIRE 8 NP8 REWIRE 9 NP9 REWIRE 0 NP0 REWIRE , NP, REWIRE . NP. REWIRE = F13 REWIRE TAB NUMLOCK REWIRE RET NPRET

Numpad keys works flawleslly (Blender reads it properly). Issues:

  1. As You see I used key labels from Numpad rather than it's keycodes to rewire (trial & error). I assume that capsicain reads keycodes not quite right. (the same with Monitor.ahk, but different keycodes)
  2. There are some strange keys on this China piece of ... (Numpad I meant): for example HOW to rewire double 0 key ("00" - there is separate "00" key: pressing it once causes double "0" action) to for example ctrl (Yes: new Blender extension adds new custom orientation and its binded to Numpad 0-9 keys WITH a modifier key). I read manual and I understood nothing, too technical for me, especially combos and MOD keys.

??

cajhin commented 1 month ago
  1. using the key labels (as defined by capsicain) is correct. You don't put key codes into the ini file, capsicain translates that for you (I'd rather remember the label LCTRL than code 0x1D) No need to guess. Open debug console (ESC+D) tap Space, you see "SPACEv" then "SPACE^". So SPACE is the label for that key you pressed. Works the same with any other key.

  2. I've never seen "00" other than on toilet doors. Again, check what the key does in debug mode. If the numpad simply sends "zero down, up, down, up", then there is no way to distinguish it from pressing 0 two times, which means you can't use it as a modifier.

Is it a LogiLink with 35 keys?

I'm not quite sure how you want to use the numpad in Blender. I think I'd want to have the common modifiers (shift ctrl alt) on the numpad? Maybe rewire Enter->Shift, that allows you to type "Shift+Number" combos with your left hand, without breaking any fingers.

COMBOs are things with modifiers, like "press CTRL-0 to send Shift+Alt+Spacebar" or whatever you want.

Problem here: CTRL-X is already used for the Windows "Cut" command, you don't want to override that. If you would like to put an extra layer with Blender commands on your numpad, you can use your numpad's PGDOWN key as a special modifier key to shift to that layer. I recommend you rewire it not to control, but to the invisible "MOD9". Then you can define combos like MOD9+0 = Control+Alt+Spacebar, without interfering with any existing CTRL combos.

That would look like REWIRE PGDOWN MOD9 COMBO 0 [...& .... ....] > moddedKey( SPACE + &.&. )

Now press PgDn + 0 ... voila, blender toggles fullscreen

The hardest part is figuring out, what exactly you want the keys to do...

Figuring out that &.&. represents "with LCTRL and LALT down" is confusing at first but not really hard.

Good luck, and don't forget to create stuff in Blender :)

On 4. Sep 2024, at 18:13, PeterP1975 @.***> wrote:

F24 in my case should work as another modifier key (like ctr, shift, alt). Blender compared to eg 3ds Max has a lot of keybindings (I mean A LOT - with new Blender 4.2 extension platform for example letter "t" has 26 bindings and this is not an exception "r"is about 27..) Another thing: 2 BT HID devices: I needed Numpad to be on the left side of the keyboard. Right side Numpad's location is totally useles as my right hand uses mouse, my left hand uses left located numpad and BT keyboard.

Anyway: cajhin = God Like Person

My config now: GLOBAL StartInTraybar GLOBAL startAHK

[CONFIG_1] OPTION ConfigName K35 OPTION includeDeviceID pid&7021& REWIRE 1 NP1 REWIRE 2 NP2 REWIRE 3 NP3 REWIRE 4 NP4 REWIRE 5 NP5 REWIRE 6 NP6 REWIRE 7 NP7 REWIRE 8 NP8 REWIRE 9 NP9 REWIRE 0 NP0 REWIRE , NP, REWIRE . NP. REWIRE = F13 REWIRE TAB NUMLOCK REWIRE RET NPRET

Numpad keys works flawleslly (Blender reads it properly). Issues:

As You see I used key labels from Numpad rather than it's keycodes to rewire (trial & error). I assume that capsicain reads keycodes not quite right. (the same with Monitor.ahk, but different keycodes) There are some strange keys on this China piece of ... (Numpad I meant): for example HOW to rewire double 0 key ("00" - there is separate "00" key: pressing it once causes double "0" action) to for example ctrl (Yes: new Blender extension adds new custom orientation and its binded to Numpad 0-9 keys WITH a modifier key). I read manual and I understood nothing, too technical for me, especially combos and MOD keys. ??

— Reply to this email directly, view it on GitHub https://github.com/cajhin/capsicain/issues/115#issuecomment-2329478564, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBEBJQRT6BCGS5JD5PZJGTZU4WSVAVCNFSM6AAAAABNMZR6XSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRZGQ3TQNJWGQ. You are receiving this because you commented.

PeterP1975 commented 1 month ago

I'll rewire something elsethan "00" eg "," (as a modifier key: shift, alt, ctrl) which it's not present in normal numpad. This thing i mean numpad is called K35 from 198i brand. Has 2xBT + 2,4G connector, quite good scissor keys. But software part, o my... It's like that scene from M.A.S.H series. One of main characters ordered a pinstripe suit (suit with stripe pattern) from korean tailor. And suit is done, good material, nice fashion but stripes are not from top to bottom but horizontal:)

Anyway Now numpad is doing what is supposed to, mostly. Keystrokes are fast as hell. Next time I'll try autohotkey, but syntax, i do not understand it, i am not a programmer.

About layers concept. As far as I understand, I suppose to switch to another set of keys called a "layer" by pressing special key, then use for example "q" instead of "w". From an ergonomic point of view it's a complication. I'd rather want to have all my commands in one layer, that is why i needed "Win" key remapped to "F24" (now it is done by AHK) to use it as a modifier key (like eg another "ctrl") to fit all commands in one set of keys. Look at Blender s

Obsidian_wGQAz4flDT

hortcuts in Obsidian