Using Blender with a second USB Numpad

How possible do you think it would be to code a .py addon to recognize multiple typing keyboards or numpads attached to PC for Blender?

I’m back on PC now. I see that Py can pick up HIDs…
https://python.hotexamples.com/examples/hid/-/device/python-device-function-examples.html

1 Like

I think that it is actually a good idea to have an add-on that interfaces with such devices. My guess is that it is possible, but it will depend on how well Python integrates with the Windows hardware drivers.

1 Like

Yeah, for now it will only be aimed to PC. If Blender is capable of this (and also detect CORES and GPUS by name), identifying an extra usb pad should be not much trouble?

For everyone else reading the thread, I’ve posted the summary of the final intention in the following link.
Specially regarding a new way to control the VSE with typing keyboards or custom USB human interface devices (HID).
Imagine you have a dedicated USB numpad to call out your sculpting tools by hardware keypress?
Why not let Blender handle the HID devices recognition, just like it does with the GPU and CPU?

1 Like

I should study this better before I can make it work. I don’t know much about input drivers, but in case the echo cannot be eliminated, how about this dumb workaround:

  • remap the keyboard numpad to a unique macro, same as you did with the USB numpad
  • use those macros in lue of the orignal NumPad in blender
  • add your additional keybinds from unique to the USB NumPad

Would that work?

2 Likes

I use a Microsoft Ergo keyboard and it has a separate numpad, convenient.

Hi pKrime, I’m highly interested if you’re going to consider creating an addon for identifying HID (usb numpads and usb typing keyboards) as additional control devices in Blender. That would be a huge leap for production on the entire planet.
I posted the details about python and other things regarding Blender in the Blender Developer Talk thread. Maybe you had a chance to check it out? I wrote a lot of other details there about my finds.

About your suggested workflow:
Yes, I’ve considered liberating the typing keyboard numpad from all the (default) blender shortcuts, but that will beat the purpose of having an external (additional) usb numpad. I don’t want it to work as a numpad, but as a macro keyboard (push this button, do this complex shortcut or function in blender).
I would customize Blender with the typing keyboard numpad to my necessities, but I record Blender tutorials all the time, and the shortcuts on the screen will confuse users.
Instead, it’s easier to configure an external device (I’m ordering two programable macro keyboards next month), so the users will not wonder why they see on their screens ALT+SHIFT+F16 as a shortcut to trigger “Apply Action (pose mode) - Jump” in their screens.

So I can’t really liberate the typing keyboard Numpad. The typing keyboard numpad should behave as normally, and the additional USB numpad should trigger the macros which kind of works now, but it also echoes “numpad 1” at the moment of push if the command is assigned to the Numpad 1 on the additional USB numpad. HID identification and letting Blender tell them appart, could be a possible way to add a custom console (macro keys) from different USB HID like regular typing keyboards and additional usb numpads. Since numpads have NumLoc (toggle to create an additional layer of commands), this has also been addressed by LUA scripts posted in this thread.

I did not want to involve LUA or AHK in the Blender developer post thread since it’s going to be purely Python that can get this to work in Blender.
Please let me know what you think about this idea in Blender.

Thanks!

Your setup looks cool.
That typing keyboard: does it have a regular numpad?

Hi, I haven’t had any luck in catching raw events so far, but I am new to input remapping. My first concern is, by the time a keyboard event reaches python, blender might have already executed the original keybind: I don’t know if an addon can absorb a key stroke event. Also, it would basically be a keyloader, the OS security might not like it.

I will make more tests.

1 Like

In the previously posted videos, the way they (the macro key guys on the videos) do bypass the problem of the keylogging, is by writing a CaptureKeystroke.txt file. And this method works when passing “variables” through a text file to identify the keypress so the other application (AHK - AutoHotKeys) can pick it up and match the written keystroke to the declared command.

As I mentioned before, this works for EVERY OTHER SOFTWARE out there. I tested the mentioned method for OBS, Firefox, Word, Premiere, Photoshop, After Effects, Davinci Resolve, etc and IT WORKS… except for Blender. In Blender, this method does not work. Why?

When the LUA script is sent (as matching keypress command + F12 to write the file), the “CaptureKeystroke.txt” file is written, AHK picks up the variable, matches it to the command it’s got assigned, EXECUTES it from the (i.e. Usb Numpad key 1), the command gets triggered in Blender, BUT IT ALSO EXECUTES NUMPAD 1 (front ortographic view).

This happens because Blender is listening to any keyboard connection with the “97” code (windows code) which is Numpad1 (with Numlock On). For Blender, nor LUA or AHK can override the fact “a key” (97) was pushed and released.

////
@LazyDodo on the Blender dev chat says:
the event stack (currently) does not keep track of the origin of a key event, if you wanted to extend that functionality intern\ghost\intern\GHOST_EventKey.h be a good starting point to start looking.

Windows, in turn, also has it’s own “virtual key codes”. Maybe catching (or generating those) from an identified HID (additional usb numpad or typing keyboard) connected to PC will help.

Here’s a close-up photo

In Windows, to reassign the Numpad keys on any other keys of the keyboard (and even mouse) I used the utility Key Manager.

Yes, I’ve seen there is dedicated (programmable) hardware to reconfigure the keystrokes.
Awesome setup you got!