Emulate a 3 button Foot pedal using keyboard or mouse button

I have a three button footpedal (VEC-USB-3-Infinity-Digital-Control) that is used for dictation software. I don’t like having to use the footpedal and would like to use button presses on a mouse or keypresses on a generic keyboard to act like each of the three buttons on the footpedal.

So far, I have used wireshark to obtain the report descriptor from the footpedal and I have been able to fully emulate the 3 buttons of the footpedal using a macropad (keybow 2040) that is running circuitpython on a rp2040 with the below collection of snippets.

It seems like hid-remapper will let me use a generic keyboard to emulate the footpedal, but may not be set up to identify this type of device (consumer page, programmable button). Can it capture this device, perhaps using the “custom usages” option in the configuration webpage, or will it need some modification to the source code? I would welcome some pointers on how to proceed (Monitor tab didn’t find anything when I pushed the buttons on the footpedal when it was connected to the 2040 feather board and the configuration page able to find and connect to the board).

Thank you.

FOOTPAD_REPORT_DESCRIPTOR = bytes((  
    0x05, 0x0C,  #   Usage Page (Consumer)    
    0x09, 0x03,  #   Usage (Programmable Buttons)
    0xA1, 0x01,  #   Collection (Application)    
    0x05, 0x09,  #   Usage Page (Button)
    0x19, 0x01,  #   Usage Minimum (0x01)
    0x29, 0x03,  #   Usage Maximum (0x03)
    0x15, 0x00,  #   Logical Minimum (0)
    0x25, 0x01,  #   Logical Maximum (1)
    0x95, 0x03,  #   Report Count (3)  Button? (1 bit per each of 3 buttons)
    0x75, 0x01,  #   Report Size (1)
    0x81, 0x02,  #   Input
    0x95, 0x01,  #   Report Count (1)
    0x75, 0x05,  #   Report Size (5)  5 bits of padding?
    0x81, 0x01,  #   Input
    0x95, 0x01,  #   Report Count (1)
    0x75, 0x08,  #   Report Size (8)  8 bits of padding?
    0x81, 0x01,  #   Input
    0xC0,        #   End Collection
)) # 67 bytes

footpad = usb_hid.Device(
    report_descriptor=FOOTPAD_REPORT_DESCRIPTOR,
    usage_page=0x0C,           #
    usage=0x03,                #
    report_ids=(0,),           #
    in_report_lengths=(2,),    # This footpad sends 3 bits of data + 5 bits of padding + 8 bits of padding in its report.
    out_report_lengths=(0,),   # It does not receive any reports.
)
supervisor.set_usb_identification(
                                  manufacturer='VEC',
                                  product='VEC USB Footpedal',
                                  vid=0x05F3, 
                                  pid=0x00FF 
)

You’d have to compile a custom build of the firmware to change the VID/PID and report descriptor.

You could probably do it entirely on GitHub without having to set up a local dev environment. We have a video:

1 Like

this is exactly what I’m looking to do. it would definitely be nice to be able to not even have to move hands from a keyboard to a macropad encoded with flimsy autohotkey functions. I could not get the hid remapper to detect my dragon power mic as well. Here’s hoping to be completely unshackled by organizational IT permission provisioning

If I were to say, somehow adapt this to a commercial trackball like a Kensington slimblade, would it still be able to function as a mouse?

I have this working with 2 different macropads (not using remapper though) that use a rp2040 as the microcontroller (NOT USING AUTOHOTKEY AT ALL… no F4… no TAB… The firmware on the macropads completely emulates the deadman switch for dictation as well as the prev/next field buttons) using that code from my original post.

Also, it appears that keyboards that use the QMK firmware already have this functionality built-in, just not enabled. Once I’m finished with the code for the macropads, my next step will be to figure out how to recompile QMK for my keyboard (it appears that “programable buttons”[I think it’s the same one] is already apart of QMK so I’m hopeful that it will work and that all I have to do is change the VID and PID, and enable the programmable button…..).

Once I have the macropads code at the point I’m happy with, get QMK to work, then I’ll work on adapting remapper. It should work with the trackball once remapper has been adapted (and yes, from what I can tell, the trackball should function like a trackball should, just with buttons remapped to act like powermike buttons).

From the link...

#ifdef PROGRAMMABLE_BUTTON_ENABLE
    HID_RI_USAGE_PAGE(8, 0x0C),            // Consumer
    HID_RI_USAGE(8, 0x01),                 // Consumer Control
    HID_RI_COLLECTION(8, 0x01),            // Application
        HID_RI_REPORT_ID(8, REPORT_ID_PROGRAMMABLE_BUTTON),
        HID_RI_USAGE(8, 0x03),             // Programmable Buttons
        HID_RI_COLLECTION(8, 0x04),        // Named Array
            HID_RI_USAGE_PAGE(8, 0x09),    // Button
            HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1
            HID_RI_USAGE_MAXIMUM(8, 0x20), // Button 32
            HID_RI_LOGICAL_MINIMUM(8, 0x00),
            HID_RI_LOGICAL_MAXIMUM(8, 0x01),
            HID_RI_REPORT_COUNT(8, 32),
            HID_RI_REPORT_SIZE(8, 1),
            HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
        HID_RI_END_COLLECTION(0),
    HID_RI_END_COLLECTION(0),
#endif