Page 1 of 1

Keys identified in Usb extra Numpad (Keyboard 2) but also from "keyboard 1". Help.

Posted: 05 Sep 2021, 04:50
by viktorrios
Hi, I just bought a Genius USB Numpad so I can use it as an extra set of trigger keys for different applications.
Keyboard 1 has id: 2B852B30
and Keyboard 2 has id: 2866AC2B

I assigned Keyboard 1 to be called "Streamdeck"

My issue is that when using "0" on the USB numpad extra keyboard (Streamdeck), I get the registered call and ALSO the Numpad Zero on Keyboard 2.
So I get this sequence:

Code: Select all

streamdeck  :  \\?\HID#VID_0C45&PID_7663&MI_00#8&2B852B30&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [388695651] :  keyboard
<unassigned>  :  \\?\HID#VID_04D9&PID_1503&MI_00#8&2866AC2B&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65609] :  keyboard
Total number of devices: 2
streamdeck  :  \\?\HID#VID_0C45&PID_7663&MI_00#8&2B852B30&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [388695651] :  keyboard
<unassigned>  :  \\?\HID#VID_04D9&PID_1503&MI_00#8&2866AC2B&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65609] :  keyboard
Total number of devices: 2
\\?\HID#VID_0C45&PID_7663&MI_00#8&2B852B30&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD}
Callback for device: button 96, direction 1, flags 18619437
Callback for device: button 96, direction 0, flags 18619593
Callback for device: button 96, direction 1, flags 18620515
Callback for device: button 96, direction 0, flags 18620656
My question is: How can I only make the extra USB Numpad (keyboard 1) register the keypress and not my original typing Keyboard(2)?

This is the code I am using:

Code: Select all

lmc_device_set_name('streamdeck','2B852B30')
lmc_print_devices()

print(lmc_device_set_name('streamdeck', '2B852B30'))

log_handler = function(button, direction, flags)
  print('Callback for device: button ' .. button .. ', direction '..direction..', flags '..flags)
end

lmc_set_handler('streamdeck', log_handler)

lmc_set_handler('streamdeck', function(button,direction)
  if (direction == 1) then return end
  if (button == 13) then
    lmc_send_keys('^{ENTER}', 50)

    elseif (button == 97) then
    lmc_send_keys('^{NUM1}', 50)

    elseif (button == 98) then
    lmc_send_keys('^{NUM2}', 50)

    elseif (button == 99) then
    lmc_send_keys('^{NUM3}', 50)

    elseif (button == 100) then
    lmc_send_keys('^{NUM4}', 50)

    elseif (button == 101) then
    lmc_send_keys('^{NUM5}', 50)

    elseif (button == 102) then
    lmc_send_keys('^{NUM6}', 50)

    elseif (button == 103) then
    lmc_send_keys('^{NUM7}', 50)

    elseif (button == 104) then
    lmc_send_keys('^{NUM8}', 50)

    elseif (button == 105) then
    lmc_send_keys('^{NUM9}', 50)

    elseif (button == 111) then
    lmc_send_keys('^{NUMDIVIDE}', 50)

    elseif (button == 106) then
    lmc_send_keys('^{NUMMULTIPLY}', 50)

    elseif (button == 109) then
    lmc_send_keys('^{NUMMINUS}', 50)

    elseif (button == 107) then
    lmc_send_keys('^{NUMPLUS}', 50)

    elseif (button == 8) then
    lmc_send_keys('^{BACKSPACE}', 50)

    elseif (button == 110) then
    lmc_send_keys('^{NUMDECIMAL}', 50)

    elseif (button == 96) then
    lmc_send_keys('{left}', 50)
  end
end
)
BTW My USB Numpad features the 000 button which types the three zeroes in a sequence. How can I make the above script so that only writes it one time?
I've also read you can program a second layer of functions when you "turn off" num lock. I was trying to create a script using HID Macros and also to identify they keypress code.

Please help me out.
Thanks. :)

Re: Keys identified in Usb extra Numpad (Keyboard 2) but also from "keyboard 1". Help.

Posted: 06 Sep 2021, 08:28
by admin
Don't call lmc_device_set_name twice in your script. Try to remove the first call and keep the one in print.
Regarding 000 - probably could be with some scripting (including time measurement and ignoring quickly followed presses) but not sure if you can recognize "regular 0" and first of 000

Re: Keys identified in Usb extra Numpad (Keyboard 2) but also from "keyboard 1". Help.

Posted: 06 Sep 2021, 21:32
by viktorrios
Thank you for your reply Admin.
I will remove the first call lmc_device_set_name as you mentioned.

I am figuring some people use "mirroring commands" from the first keyboard to new keystrokes on secondary NumPad keyboard,
while others create "totally new keystroke calls (F13-F24)" on the secondary.

Is there a way to assign F13 to F24 function keys to the Numpad?
Thanks!

Re: Keys identified in Usb extra Numpad (Keyboard 2) but also from "keyboard 1". Help.

Posted: 07 Sep 2021, 07:46
by admin
AFAIK you can send F13-F24 from the macro but you need some software which can receive it and do the action (like AutoHotKey or directly the program you want to control).

Re: Keys identified in Usb extra Numpad (Keyboard 2) but also from "keyboard 1". Help.

Posted: 02 Oct 2021, 07:41
by viktorrios
Cool.
Let's talk about "capturing the keystroke" before it's sent to Windows regular functions, because I feel this is where my problem currently is.
I use Blender which is a 3d software. I can configure the F13 keypress on windows for Blender to pick up the keystroke using PowerToys Keyboard
key assign (PowerToys is a native windows install application).

But here's the problem:
When I press Numpad 1 on my extra USB numpad keyboard (not my typing normal keyboard), the command gets picked up by Blender
and it also presses the regular "Numpad 1" command. So I get 2 actions with one keypress. This is not optimal.

For the past 4 weeks I've been reading about Key-press, Key-hold, Key-release. I feel I am having the case where I press the Numpad 1 (and correct
command shortcut fires off in Blender) but when I RELEASE the key, then regular Numpad 1 is sent.

How could I TRAP the keystroke so that it only sends F13 (and not Numpad 1 afterwards?)
Could you help me out with the additional code in the previous example?
Thanks! Any pointers will help!

Re: Keys identified in Usb extra Numpad (Keyboard 2) but also from "keyboard 1". Help.

Posted: 04 Oct 2021, 08:08
by admin
Blocking the original keypress is basically a hack, some applications still can recognize it. Maybe Blender is one of these apps.