Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <Keyboard.h>
  2.  
  3. #define LAYOUT 3
  4. const int l_Pin = 10;
  5. const int r_Pin = A1;
  6. const int led_Pin = 13;
  7.  
  8. #if LAYOUT == 1 /* Gaming */
  9. const int l_Key[] = { 's' };
  10. const int r_Key[] = { 'w' };
  11. #elif LAYOUT == 2 /* Vim */
  12. const int l_Key[] = { KEY_LEFT_CTRL };
  13. const int r_Key[] = { KEY_ESC };
  14. #else /* Windows Virtual Desktop */
  15. const int l_Key[] = { KEY_LEFT_GUI, KEY_LEFT_CTRL, KEY_LEFT_ARROW };
  16. const int r_Key[] = { KEY_LEFT_GUI, KEY_LEFT_CTRL, KEY_RIGHT_ARROW };
  17. #endif
  18.  
  19. void setup()
  20. {
  21. pinMode(l_Pin, INPUT_PULLUP);
  22. pinMode(r_Pin, INPUT_PULLUP);
  23. pinMode(led_Pin, OUTPUT);
  24.  
  25. Keyboard.begin();
  26. digitalWrite(led_Pin, HIGH);
  27. }
  28.  
  29. void loop()
  30. {
  31. if (!digitalRead(l_Pin))
  32. for (auto k : l_Key)
  33. Keyboard.press(k);
  34. else
  35. for (auto k : l_Key)
  36. Keyboard.release(k);
  37. if (!digitalRead(r_Pin))
  38. for (auto k : r_Key)
  39. Keyboard.press(k);
  40. else
  41. for (auto k : r_Key)
  42. Keyboard.release(k);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement