Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keyboard.h>
- #define LAYOUT 3
- const int l_Pin = 10;
- const int r_Pin = A1;
- const int led_Pin = 13;
- #if LAYOUT == 1 /* Gaming */
- const int l_Key[] = { 's' };
- const int r_Key[] = { 'w' };
- #elif LAYOUT == 2 /* Vim */
- const int l_Key[] = { KEY_LEFT_CTRL };
- const int r_Key[] = { KEY_ESC };
- #else /* Windows Virtual Desktop */
- const int l_Key[] = { KEY_LEFT_GUI, KEY_LEFT_CTRL, KEY_LEFT_ARROW };
- const int r_Key[] = { KEY_LEFT_GUI, KEY_LEFT_CTRL, KEY_RIGHT_ARROW };
- #endif
- void setup()
- {
- pinMode(l_Pin, INPUT_PULLUP);
- pinMode(r_Pin, INPUT_PULLUP);
- pinMode(led_Pin, OUTPUT);
- Keyboard.begin();
- digitalWrite(led_Pin, HIGH);
- }
- void loop()
- {
- if (!digitalRead(l_Pin))
- for (auto k : l_Key)
- Keyboard.press(k);
- else
- for (auto k : l_Key)
- Keyboard.release(k);
- if (!digitalRead(r_Pin))
- for (auto k : r_Key)
- Keyboard.press(k);
- else
- for (auto k : r_Key)
- Keyboard.release(k);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement