pdio
Published © GPL3+

Keyboard and Mouse Controller

Hack an old controller and use it as a combination of a keyboard and a mouse.

IntermediateShowcase (no instructions)3,387
Keyboard and Mouse Controller

Things used in this project

Hardware components

Arduino Micro & Genuino Micro
Arduino Micro & Genuino Micro
×1
Ewent controller
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Keyboard controller

C/C++
This is the code for the keyboard and mouse controller.
/*
 * 
 * Keyboard and Mouse controller
 * some comments might be in hungarian, sorry
 * Peter Dio 2017
 * 
 */
#define BA 5  // Button A
#define BB 6  // Button B
#define BX 8  // Button X
#define BY 7  // Button Y

#define BU 23 // Button Up
#define BD 0  // Button Down
#define BL 2  // Button Left
#define BR 15 // Button Right

#define BL1 11  // Button Left 1
#define BR1 3   // Button Right 1
#define BL2 12  // Button Left 2
#define BR2 4   // Button Right 2
#define BLS 13  // Button Left Stick
#define BRS 22  // Button Right Stick

#define BMODE 1     // Button Mode
#define BSTART 10   // Button Start
#define BSELECT 16  // Button Select
#define BAUTO 9     // Button Auto
#define BTURBO 14   // Button Turbo
#define BCLEAR 17   // Button Clear

#define SLX 21  // Stick Left X
#define SLY 20  // Stick Left Y
#define SRX 19  // Stick Right X
#define SRY 18  // Stick Right Y

#include "Keyboard.h"
#include "Mouse.h"

int mode = 0,     // Segédváltozó
    nr_modes = 3, // Number of modes
    aSLX,         // Analog beolvasás
    aSLY,         // Analog beolvasás
    aSRX,         // Analog beolvasás
    aSRY,         // Analog beolvasás
    sense = 3;    // Mouse sensitivity 1-5
//============================================================================================================================================================================================================
void setup() {
  pinMode(BA, INPUT_PULLUP);
  pinMode(BB, INPUT_PULLUP);
  pinMode(BX, INPUT_PULLUP);
  pinMode(BY, INPUT_PULLUP);
  pinMode(BU, INPUT_PULLUP);
  pinMode(BD, INPUT_PULLUP);
  pinMode(BL, INPUT_PULLUP);
  pinMode(BR, INPUT_PULLUP);
  pinMode(BL1, INPUT_PULLUP);
  pinMode(BR1, INPUT_PULLUP);
  pinMode(BL2, INPUT_PULLUP);
  pinMode(BR2, INPUT_PULLUP);
  pinMode(BLS, INPUT_PULLUP);
  pinMode(BRS, INPUT_PULLUP);
  pinMode(BMODE, INPUT_PULLUP);
  pinMode(BSTART, INPUT_PULLUP);
  pinMode(BSELECT, INPUT_PULLUP);
  pinMode(BAUTO, INPUT_PULLUP);
  pinMode(BTURBO, INPUT_PULLUP);
  pinMode(BCLEAR, INPUT_PULLUP);
  pinMode(SLX, INPUT);
  pinMode(SLY, INPUT);
  pinMode(SRX, INPUT);
  pinMode(SRY, INPUT);
  pinMode(30, INPUT);
  Keyboard.begin();
  Mouse.begin();
}
//============================================================================================================================================================================================================
void loop() {
  if(mode >= (nr_modes)){
    mode = 0;
  }
//============================================================================================================================================================================================================
  ///////////////////////////////////////////////////////////// MODE 2
  if(mode == 2){
    digitalWrite(30, 1);
    
    if(digitalRead(BA) == LOW){//////////////////////////////// ABXY
      Keyboard.press('a');
    }
    if(digitalRead(BA) == HIGH){
      Keyboard.release('a');
    }
    if(digitalRead(BB) == LOW){
      Keyboard.press('b');
    }
    if(digitalRead(BB) == HIGH){
      Keyboard.release('b');
    }
    if(digitalRead(BX) == LOW){
      Keyboard.press('x');
    }
    if(digitalRead(BX) == HIGH){
      Keyboard.release('x');
    }
    if(digitalRead(BY) == LOW){
      Keyboard.press('y');
    }
    if(digitalRead(BY) == HIGH){
      Keyboard.release('y');
    }
    
    if(digitalRead(BU) == LOW){//////////////////////////////// UDLR
      Keyboard.press('u');
    }
    if(digitalRead(BU) == HIGH){
      Keyboard.release('u');
    }
    if(digitalRead(BD) == LOW){
      Keyboard.press('d');
    }
    if(digitalRead(BD) == HIGH){
      Keyboard.release('d');
    }
    if(digitalRead(BL) == LOW){
      Keyboard.press('l');
    }
    if(digitalRead(BL) == HIGH){
      Keyboard.release('l');
    }
    if(digitalRead(BR) == LOW){
      Keyboard.press('r');
    }
    if(digitalRead(BR) == HIGH){
      Keyboard.release('r');
    }

    if(digitalRead(BL1) == LOW){/////////////////////////////// 123456
      Keyboard.press('1');
    }
    if(digitalRead(BL1) == HIGH){
      Keyboard.release('1');
    }
    if(digitalRead(BR1) == LOW){
      Keyboard.press('2');
    }
    if(digitalRead(BR1) == HIGH){
      Keyboard.release('2');
    }
    if(digitalRead(BL2) == LOW){
      Keyboard.press('3');
    }
    if(digitalRead(BL2) == HIGH){
      Keyboard.release('3');
    }
    if(digitalRead(BR2) == LOW){
      Keyboard.press('4');
    }
    if(digitalRead(BR2) == HIGH){
      Keyboard.release('4');
    }
    if(digitalRead(BLS) == LOW){
      Keyboard.press('5');
    }
    if(digitalRead(BLS) == HIGH){
      Keyboard.release('5');
    }
    if(digitalRead(BRS) == LOW){
      Keyboard.press('6');
    }
    if(digitalRead(BRS) == HIGH){
      Keyboard.release('6');
    }

    if(digitalRead(BSTART) == LOW){//////////////////////////// FUNCTION KEYS
      Keyboard.press('s');
    }
    if(digitalRead(BSTART) == HIGH){
      Keyboard.release('s');
    }
    if(digitalRead(BSELECT) == LOW){
      Keyboard.press('e');
    }
    if(digitalRead(BSELECT) == HIGH){
      Keyboard.release('e');
    }
    if(digitalRead(BAUTO) == LOW){
      Keyboard.press('o');
    }
    if(digitalRead(BAUTO) == HIGH){
      Keyboard.release('o');
    }
    if(digitalRead(BTURBO) == LOW){
      Keyboard.press('t');
    }
    if(digitalRead(BTURBO) == HIGH){
      Keyboard.release('t');
    }
    pinMode(BCLEAR, INPUT_PULLUP);
    if(digitalRead(BCLEAR) == LOW){
      Keyboard.press('c');
    }
    pinMode(BCLEAR, INPUT_PULLUP);
    if(digitalRead(BCLEAR) == HIGH){
      Keyboard.release('c');
    }
    if(digitalRead(BMODE) == LOW){//////////////////////////// MODE SELECTION
      mode++;
      digitalWrite(30, 0);
      delay(100);
      digitalWrite(30, 1);
      delay(200);
    }
  }
  ///////////////////////////////////////////////////////////// MODE 2
//============================================================================================================================================================================================================
  ///////////////////////////////////////////////////////////// MODE 0
  if(mode==0){
    if(sense >= 6){
      sense = 1;
    }
    digitalWrite(30, 1);
    
    if(digitalRead(BA) == LOW){//////////////////////////////// ABXY
      Mouse.press();
    }
    if(digitalRead(BA) == HIGH){
      Mouse.release();
    }
    if(digitalRead(BB) == LOW){
      Mouse.press(2);
    }
    if(digitalRead(BB) == HIGH){
      Mouse.release(2);
    }
    if(digitalRead(BX) == LOW){
      Keyboard.press(KEY_RETURN);
    }
    if(digitalRead(BX) == HIGH){
      Keyboard.release(KEY_RETURN);
    }
    if(digitalRead(BY) == LOW){
      Keyboard.press(KEY_BACKSPACE);
    }
    if(digitalRead(BY) == HIGH){
      Keyboard.release(KEY_BACKSPACE);
    }
    
    if(digitalRead(BU) == LOW){//////////////////////////////// UDLR
      Keyboard.press(KEY_UP_ARROW);
    }
    if(digitalRead(BU) == HIGH){
      Keyboard.release(KEY_UP_ARROW);
    }
    if(digitalRead(BD) == LOW){
      Keyboard.press(KEY_DOWN_ARROW);
    }
    if(digitalRead(BD) == HIGH){
      Keyboard.release(KEY_DOWN_ARROW);
    }
    if(digitalRead(BL) == LOW){
      Keyboard.press(KEY_LEFT_ARROW);
    }
    if(digitalRead(BL) == HIGH){
      Keyboard.release(KEY_LEFT_ARROW);
    }
    if(digitalRead(BR) == LOW){
      Keyboard.press(KEY_RIGHT_ARROW);
    }
    if(digitalRead(BR) == HIGH){
      Keyboard.release(KEY_RIGHT_ARROW);
    }
    
    if(digitalRead(BL1) == LOW){/////////////////////////////// 123456
      Keyboard.press(KEY_LEFT_SHIFT);
    }
    if(digitalRead(BL1) == HIGH){
      Keyboard.release(KEY_LEFT_SHIFT);
    }
    if(digitalRead(BR1) == LOW){
      Keyboard.press(KEY_RIGHT_ALT);
    }
    if(digitalRead(BR1) == HIGH){
      Keyboard.release(KEY_RIGHT_ALT);
    }
    if(digitalRead(BL2) == LOW){
      Keyboard.press(KEY_LEFT_CTRL);
    }
    if(digitalRead(BL2) == HIGH){
      Keyboard.release(KEY_LEFT_CTRL);
    }
    if(digitalRead(BR2) == LOW){
      Keyboard.press(' ');
    }
    if(digitalRead(BR2) == HIGH){
      Keyboard.release(' ');
    }
    if(digitalRead(BLS) == LOW){
      sense++;
      delay(200);
    }
    if(digitalRead(BRS) == LOW){
      Mouse.press(4);
    }
    if(digitalRead(BRS) == HIGH){
      Mouse.release(4);
    }

    if(digitalRead(BSTART) == LOW){//////////////////////////// FUNCTION KEYS
      Keyboard.press(KEY_ESC);
    }
    if(digitalRead(BSTART) == HIGH){
      Keyboard.release(KEY_ESC);
    }
    if(digitalRead(BSELECT) == LOW){
      Keyboard.press(KEY_LEFT_GUI);
    }
    if(digitalRead(BSELECT) == HIGH){
      Keyboard.release(KEY_LEFT_GUI);
    }
    pinMode(BCLEAR, INPUT_PULLUP);
    if(digitalRead(BCLEAR) == LOW){
      Keyboard.press(KEY_LEFT_ALT);
      delay(100);
      Keyboard.press(KEY_F4);
      delay(100);
      Keyboard.release(KEY_F4);
      Keyboard.release(KEY_LEFT_ALT);
      delay(100);
    }
    
    if(digitalRead(BMODE) == LOW){//////////////////////////// MODE SELECTION
      mode++;
      digitalWrite(30, 0);
      delay(100);
      digitalWrite(30, 1);
      delay(100);
      digitalWrite(30, 0);
      delay(100);
    }
    
    aSLX = analogRead(SLX);/////////////////////////////////////// CURSOR AND WHEEL
    aSLY = analogRead(SLY);
    //aSRX = analogRead(SRX);
    aSRY = analogRead(SRY);
    
    if(aSLX >= 509){/////////////////////////////////////// CURSOR X
      if(aSLX >= 600){
        if(aSLX >= 900){
          Mouse.move(-2*sense, 0, 0);
        }
        else{
          Mouse.move(-1*sense, 0, 0);
        }
      }
      else{
        Mouse.move(-1, 0, 0);
      }
    }
    if(aSLX <= 501){
      if(aSLX <= 400){
        if(aSLX <= 100){
          Mouse.move(2*sense, 0, 0);
        }
        else{
          Mouse.move(sense, 0, 0);
        }
      }
      else{
        Mouse.move(1, 0, 0);
      }
    }
    
    if(aSLY >= 526){ ////////////////////////////////////// CURSOR Y
      if(aSLY >= 600){
        if(aSLY >= 900){
          Mouse.move(0, -2*sense, 0);
        }
        else{
          Mouse.move(0, -1*sense, 0);
        }
      }
      else{
        Mouse.move(0, -1, 0);
      }
    }
    if(aSLY <= 518){
      if(aSLY <= 400){
        if(aSLY <= 100){
          Mouse.move(0, 2*sense, 0);
        }
        else{
          Mouse.move(0, 1*sense, 0);
        }
      }
      else{
        Mouse.move(0, 1, 0);
      }
    }
    
    if(aSRY >= 519){/////////////////////////////////// WHEEL
      if(aSRY >= 600){
        if(aSRY >= 900){
          Mouse.move(0, 0, 1);
          delay(50);
        }
        else{
          Mouse.move(0, 0, 1);
          delay(100);
        }
      }
      else{
        Mouse.move(0, 0, 1);
        delay(200);
      }
    }
    if(aSRY <= 511){
      if(aSRY <= 400){
        if(aSRY <= 100){
          Mouse.move(0, 0, -1);
          delay(50);
        }
        else{
          Mouse.move(0, 0, -1);
          delay(100);
        }
      }
      else{
        Mouse.move(0, 0, -1);
        delay(200);
      }
    }
  }
  ///////////////////////////////////////////////////////////// MODE 0
//============================================================================================================================================================================================================
  ///////////////////////////////////////////////////////////// MODE 1
  if(mode == 1){
    unsigned long pmillis,
                  cmillis;

    digitalWrite(30, 1);
    
    if(digitalRead(BMODE) == LOW){//////////////////////////// MODE SELECTION
      mode++;
      digitalWrite(30, 0);
      delay(100);
      digitalWrite(30, 1);
      delay(100);
      digitalWrite(30, 0);
      delay(100);
      digitalWrite(30, 1);
      delay(100);
      digitalWrite(30, 0);
      delay(100);
    }

    if(digitalRead(BU) == LOW){//////////////////////////////// UDLR
      Keyboard.press(KEY_BACKSPACE);
    }
    if(digitalRead(BU) == HIGH){
      Keyboard.release(KEY_BACKSPACE);
    }
    if(digitalRead(BR) == LOW){
      Keyboard.press(KEY_RETURN);
    }
    if(digitalRead(BR) == HIGH){
      Keyboard.release(KEY_RETURN);
    }

    if(digitalRead(BL1) == LOW){/////////////////////////////// 123456
      Keyboard.press(KEY_LEFT_SHIFT);
    }
    if(digitalRead(BL1) == HIGH){
      Keyboard.release(KEY_LEFT_SHIFT);
    }
    if(digitalRead(BR2) == LOW){
      Keyboard.press(' ');
    }
    if(digitalRead(BR2) == HIGH){
      Keyboard.release(' ');
    }

    if(digitalRead(BSTART) == LOW){//////////////////////////// FUNCTION KEYS
      Keyboard.press(KEY_ESC);
    }
    if(digitalRead(BSTART) == HIGH){
      Keyboard.release(KEY_ESC);
    }
    if(digitalRead(BSELECT) == LOW){
      Keyboard.press(KEY_LEFT_GUI);
    }
    if(digitalRead(BSELECT) == HIGH){
      Keyboard.release(KEY_LEFT_GUI);
    }
    pinMode(BCLEAR, INPUT_PULLUP);
    if(digitalRead(BCLEAR) == LOW){
      Keyboard.press(KEY_LEFT_ALT);
      delay(100);
      Keyboard.press(KEY_F4);
      delay(100);
      Keyboard.release(KEY_F4);
      Keyboard.release(KEY_LEFT_ALT);
      delay(100);
    }
    
    comehere:
    
    if(digitalRead(BA) == LOW){/////////////////////////////// ABCD
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BA) == LOW){
        delay(1);
      }
      while(digitalRead(BA) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('a');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BA) == LOW){
        delay(1);
      }
      while(digitalRead(BA) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('b');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BA) == LOW){
        delay(1);
      }
      while(digitalRead(BA) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('c');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BA) == LOW){
        delay(1);
      }
      while(digitalRead(BA) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('d');
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BB) == LOW){/////////////////////////////// EFGH
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BB) == LOW){
        delay(1);
      }
      while(digitalRead(BB) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('e');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BB) == LOW){
        delay(1);
      }
      while(digitalRead(BB) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('f');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BB) == LOW){
        delay(1);
      }
      while(digitalRead(BB) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('g');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BB) == LOW){
        delay(1);
      }
      while(digitalRead(BB) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('h');
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BX) == LOW){/////////////////////////////// IJKL
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BX) == LOW){
        delay(1);
      }
      while(digitalRead(BX) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('i');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BX) == LOW){
        delay(1);
      }
      while(digitalRead(BX) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('j');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BX) == LOW){
        delay(1);
      }
      while(digitalRead(BX) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('k');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BX) == LOW){
        delay(1);
      }
      while(digitalRead(BX) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('l');
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BY) == LOW){/////////////////////////////// MNOP
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BY) == LOW){
        delay(1);
      }
      while(digitalRead(BY) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('m');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BY) == LOW){
        delay(1);
      }
      while(digitalRead(BY) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('n');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BY) == LOW){
        delay(1);
      }
      while(digitalRead(BY) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('o');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BY) == LOW){
        delay(1);
      }
      while(digitalRead(BY) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('p');
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BD) == LOW){/////////////////////////////// QRST
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BD) == LOW){
        delay(1);
      }
      while(digitalRead(BD) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('q');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BD) == LOW){
        delay(1);
      }
      while(digitalRead(BD) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('r');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BD) == LOW){
        delay(1);
      }
      while(digitalRead(BD) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('s');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BD) == LOW){
        delay(1);
      }
      while(digitalRead(BD) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('t');
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BL) == LOW){/////////////////////////////// UVWXYZ
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BL) == LOW){
        delay(1);
      }
      while(digitalRead(BL) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('u');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BL) == LOW){
        delay(1);
      }
      while(digitalRead(BL) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('v');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BL) == LOW){
        delay(1);
      }
      while(digitalRead(BL) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('w');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BL) == LOW){
        delay(1);
      }
      while(digitalRead(BL) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('x');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BL) == LOW){
        delay(1);
      }
      while(digitalRead(BL) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('z');                    // ez lesz az y
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BL) == LOW){
        delay(1);
      }
      while(digitalRead(BL) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('y');                    // ez lesz a z
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BR1) == LOW){/////////////////////////////// ,.?!
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BR1) == LOW){
        delay(1);
      }
      while(digitalRead(BR1) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write(',');             // ,
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BR1) == LOW){
        delay(1);
      }
      while(digitalRead(BR1) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('.');             // .
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BR1) == LOW){
        delay(1);
      }
      while(digitalRead(BR1) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write(60);            // ?
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BR1) == LOW){
        delay(1);
      }
      while(digitalRead(BR1) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write(36);            // !
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BTURBO) == LOW){/////////////////////////////// 12345
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BTURBO) == LOW){
        delay(1);
      }
      while(digitalRead(BTURBO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('1');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BTURBO) == LOW){
        delay(1);
      }
      while(digitalRead(BTURBO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('2');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BTURBO) == LOW){
        delay(1);
      }
      while(digitalRead(BTURBO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('3');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BTURBO) == LOW){
        delay(1);
      }
      while(digitalRead(BTURBO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('4');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BTURBO) == LOW){
        delay(1);
      }
      while(digitalRead(BTURBO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('5');
          goto comehere;
        }
      }
      goto comehere;
    }

    if(digitalRead(BAUTO) == LOW){/////////////////////////////// 67890
      pmillis = millis();
      cmillis = pmillis;
      while(digitalRead(BAUTO) == LOW){
        delay(1);
      }
      while(digitalRead(BAUTO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('6');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BAUTO) == LOW){
        delay(1);
      }
      while(digitalRead(BAUTO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('7');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BAUTO) == LOW){
        delay(1);
      }
      while(digitalRead(BAUTO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('8');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BAUTO) == LOW){
        delay(1);
      }
      while(digitalRead(BAUTO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write('9');
          goto comehere;
        }
      }
      pmillis = cmillis;
      while(digitalRead(BAUTO) == LOW){
        delay(1);
      }
      while(digitalRead(BAUTO) == HIGH){
        cmillis = millis();
        if(cmillis - pmillis >= 500){
          Keyboard.write(96);
          goto comehere;
        }
      }
      goto comehere;
    }
    
    if(digitalRead(BLS) == LOW){//////////////////////////////// MOUSE CLICKS
      Mouse.press();
    }
    if(digitalRead(BLS) == HIGH){
      Mouse.release();
    }
    if(digitalRead(BRS) == LOW){
      Mouse.press(2);
    }
...

This file has been truncated, please download it to see its full contents.

Credits

pdio

pdio

0 projects • 1 follower

Comments