Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keyboard.h>
- // MAMEish bindings.
- struct { int pin; int key; } pinsToKeys[] = {
- { 2, KEY_LEFT_ARROW },
- { 3, KEY_UP_ARROW },
- { 4, KEY_RIGHT_ARROW },
- { 5, KEY_DOWN_ARROW },
- { 6, KEY_LEFT_CTRL }, // Fire 1
- { 7, KEY_LEFT_ALT }, // Fire 2
- { 8, 32 }, // space Fire 3
- { 9, 65 }, // a Fire 4
- { 10, 83 }, // s Fire 5
- { 11, 81 }, // q Fire 6
- { A0, 1 }, // 1 start
- { A2, 27 } // esc pause
- };
- void setup() {
- for (const auto& pinToKey : pinsToKeys) {
- pinMode(pinToKey.pin, INPUT_PULLUP);
- }
- Keyboard.begin();
- }
- void loop() {
- for (const auto& pinToKey : pinsToKeys) {
- if (digitalRead(pinToKey.pin) == LOW) {
- Keyboard.press(pinToKey.key);
- } else {
- Keyboard.release(pinToKey.key);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement