104 lines
1.6 KiB
C++
104 lines
1.6 KiB
C++
/*
|
|
|
|
Convert DDR control panel to buttons.
|
|
DDR control panel uses a JST YLR-12V connector
|
|
Pins 1-6 are used for buttons, pin 7 and 8 are GRD
|
|
|
|
Button to keyboard mappings
|
|
Left 1 : A
|
|
Left 2 : D
|
|
Right 1 : J
|
|
Right 2 : L
|
|
Start 1 : S
|
|
Start 2 : K
|
|
|
|
*/
|
|
|
|
#define BT_L1 1
|
|
#define BT_L2 2
|
|
#define BT_R1 3
|
|
#define BT_R2 4
|
|
#define BT_S1 5
|
|
#define BT_S2 6
|
|
|
|
#include <Keyboard.h>
|
|
|
|
void setup()
|
|
{
|
|
// Setup pins
|
|
pinMode (BT_L1, INPUT);
|
|
pinMode (BT_L2, INPUT);
|
|
pinMode (BT_R1, INPUT);
|
|
pinMode (BT_R2, INPUT);
|
|
pinMode (BT_S1, INPUT);
|
|
pinMode (BT_S2, INPUT);
|
|
|
|
// Set pins to high
|
|
digitalWrite(BT_L1, HIGH);
|
|
digitalWrite(BT_L2, HIGH);
|
|
digitalWrite(BT_R1, HIGH);
|
|
digitalWrite(BT_R2, HIGH);
|
|
digitalWrite(BT_S1, HIGH);
|
|
digitalWrite(BT_S2, HIGH);
|
|
|
|
Keyboard.begin();
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
// Check button inputs
|
|
if(digitalRead(BT_L1) == LOW)
|
|
{
|
|
Keyboard.press('a');
|
|
}
|
|
else
|
|
{
|
|
Keyboard.release('a');
|
|
}
|
|
|
|
if(digitalRead(BT_L2) == LOW)
|
|
{
|
|
Keyboard.press('d');
|
|
}
|
|
else
|
|
{
|
|
Keyboard.release('d');
|
|
}
|
|
|
|
if(digitalRead(BT_R1) == LOW)
|
|
{
|
|
Keyboard.press('j');
|
|
}
|
|
else
|
|
{
|
|
Keyboard.release('j');
|
|
}
|
|
|
|
if(digitalRead(BT_R2) == LOW)
|
|
{
|
|
Keyboard.press('l');
|
|
}
|
|
else
|
|
{
|
|
Keyboard.release('l');
|
|
}
|
|
|
|
if(digitalRead(BT_S1) == LOW)
|
|
{
|
|
Keyboard.press('s');
|
|
}
|
|
else
|
|
{
|
|
Keyboard.release('s');
|
|
}
|
|
|
|
if(digitalRead(BT_S2) == LOW)
|
|
{
|
|
Keyboard.press('k');
|
|
}
|
|
else
|
|
{
|
|
Keyboard.release('k');
|
|
}
|
|
}
|