AnaviTechnology / anavi-macro-pad-2

Open source, programmable, two-key keypad with backlighting
7 stars 2 forks source link

Has anyone used a Macro Pad 2 to trigger a PC/Mac to go into BIOS/UEFI or boot disk selection? #3

Open UNIVAC-Colonel-Panic opened 2 years ago

UNIVAC-Colonel-Panic commented 2 years ago

I have a sort of KVM setup where I share a single wireless mouse, wireless keyboard and monitor . The mouse and keyboard are controlled by a single USB dongle.

This set up works great... until I need to boot a PC or Mac into BIOS/UEFI setup mode. What happens then is that the wireless USB dongle doesn't get initialized quick enough. By the time it has initialized, it's way past the point where the computer will detect any of the keystrokes that would cause it to enter setup. The solution is to use a wired keyboard during those critical boot up seconds. It's only a couple of keys that are needed -- DEL or F11 or whatever. A perfect application for Macro Pad 2.

I have no doubt that programming the Macro Pad 2 for DEL and F11 will be easy. But I want the Macro Pad 2 to be smarter, and that's why I've created this issue.

Imagine being able to press the left Macro Pad 2 and have it do the following macro:

  1. Hold down the DEL key for say three seconds, then release the key.
  2. Try other typical keys that go into setup on other computers -- ESC, F2, etc. Hold each down for three seconds, release, repeat.
  3. Go back to 1.

I'd like to be able to power on the PC (manually, like I already do), hit the left Macro Pad 2 once, and walk away, letting it take as long as needed to get into setup mode.

HERE'S MY QUESTION: Is there some mechanism in Macro Pad 2 that will tell me the computer has consumed the transmitted key (like DEL), because I'd like to use that signal to break out of the loop. Or, is there something else that might get emitted by the computer over the USB bus that the Macro Pad 2 could detect and use that to break out of the loop?

Edited to add: I'm envisioning using QMK as a starting point, then changing the generated QMK source code to add the macro for the "loop" described above.

leon-anavi commented 2 years ago

Hi @UNIVAC-Colonel-Panic,

This is a very interesting use case. Unfortunately, ANAVI Macro Pad 2 is not suitable for as this cannot be implemented straight-forward or at least it will be quite difficult. But it is suitable or ANAVI Macro Pad 8. Let me explain the technical details:

ANAVI Macro Pad 2 is powered by Microchip ATtiny85 which doesn't have a native hardware USB support. Instead software implementation of USB is used through the open source project V-USB and the Micronucleous bootloader. V-USB is a software-only implementation of a low-speed USB device for Atmel’s AVR® microcontrollers, including ATtiny85. Micronucleous on ANAVI Macro Pad 2 automatically enters a mode waiting to be flashed for 5-6 seconds after being plugged in. If flash procedure is not detected the bootloader loads the firmware, in this case QMK firmware. As a result there is a short delay after powering on ANAVI Macro Pad 2 and between it is working as a keyboard. To eventually reduce this delay Micronucleous you will probably need to modify bootloaderconfig.h, built a custom version of Micronucleous and after that write firmware which performs the desired algorithm.

HERE'S MY QUESTION: Is there some mechanism in Macro Pad 2 that will tell me the computer has consumed the transmitted key (like DEL), because I'd like to use that signal to break out of the loop. Or, is there something else that might get emitted by the computer over the USB bus that the Macro Pad 2 could detect and use that to break out of the loop?

I am not familiar with a straight-forward way to achieve this. Eventually, if the particular computer has a serial port for UART this can be detected by the serial output.

Edited to add: I'm envisioning using QMK as a starting point, then changing the generated QMK source code to add the macro for the "loop" described above.

QMK offers a feature called Leader Key. But for this very specific use case it might be easier to implement an Arduino sketch that performs the exact sequence with the desired timings. Mechanical keyboards with Microchip ATmega32U4 (such as ANAVI Macro Pad 8) are very similar in terms of hardware to Arduino Leonardo.

Best regards, Leon