arduino-pico/libraries/Keyboard/examples/KeyboardPassword/KeyboardPassword.ino
Earle F. Philhower, III 1dfd9ebac7
Add HID consumer (aka media) keys for USB, BT (#1309)
Allow sending thigns like KEY_MUTE or KEY_SCAN_NEXT from the USB and
Bluetooth Classic keyboard libraries.

BLE requires some add'l magic, not yet discovered.

Pull in latest upstream Keyboard library changes
2023-03-15 19:10:31 -07:00

44 lines
1.1 KiB
C++

/* Released into the public domain */
/* Earle F. Philhower, III <earlephilhower@yahoo.com> */
#include <Keyboard.h>
void ledCB(bool numlock, bool capslock, bool scrolllock, bool compose, bool kana, void *cbData) {
(void) numlock;
(void) scrolllock;
(void) compose;
(void) kana;
(void) cbData;
digitalWrite(LED_BUILTIN, capslock ? HIGH : LOW);
}
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Keyboard.onLED(ledCB);
Keyboard.begin();
delay(5000);
Serial.printf("Arduino USB Password Typer\n");
Serial.printf("Press BOOTSEL to enter your super-secure(not!) password\n\n");
}
void loop() {
if (BOOTSEL) {
Serial.println("Typing password for you...shhhh....");
Serial.println("First, mute the computer to be extra quiet");
Keyboard.consumerPress(KEY_MUTE);
delay(100);
Keyboard.consumerRelease();
Keyboard.print("ThisPasswordIsWeakLikeABaby");
Serial.println("OK, unmute the computer since our secret is done");
Keyboard.consumerPress(KEY_MUTE);
delay(100);
Keyboard.consumerRelease();
while (BOOTSEL);
}
}