mirror of
https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter
synced 2024-12-22 23:48:51 -05:00
Some of the code rewritten and reorganized
This commit is contained in:
parent
40ac0f5a28
commit
498382ad7b
@ -1,7 +1,11 @@
|
|||||||
//DB9 (8=GND): 1 2 3 4 5 6 7 8 9
|
//DB9-connector:
|
||||||
const uint8_t inputPinsPort1[] = { 5, 6, 7, 8, 0, 4, 0, 0, A2};
|
//Sega Mastersystem: 1 = up, 2 = down, 3 = left, 4 = right, 6 = btn1, 9 = btn2, 8 = gnd
|
||||||
const uint8_t inputPinsPort2[] = {10, 16, 14, 15, 0, 3, 0, 0, A1};
|
//MSX: 1 = up, 2 = down, 3 = left, 4 = right, 6 = btn1, 7 = btn2, 8 = gnd
|
||||||
//(1 = up, 2 = down, 3 = left, 4 = right, 6 = btn1, 9 = btn2)
|
|
||||||
|
// UP, DOWN, LEFT, RIGHT, BTN1, BTN2
|
||||||
|
const uint8_t inputPinsPort1[] = { 5, 6, 7, 8, 4, A2};
|
||||||
|
const uint8_t inputPinsPort2[] = { 10, 16, 14, 15, 3, A1};
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
@ -146,11 +150,9 @@ Joystick_ Joystick[2] =
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//set all DB9-connector input signal pins as inputs with pullups
|
//set all DB9-connector input signal pins as inputs with pullups
|
||||||
for (uint8_t i = 0; i < 9; i++) {
|
for (uint8_t i = 0; i < 6; i++) {
|
||||||
if (inputPinsPort1[i] != 0)
|
pinMode(inputPinsPort1[i], INPUT_PULLUP);
|
||||||
pinMode(inputPinsPort1[i], INPUT_PULLUP);
|
pinMode(inputPinsPort2[i], INPUT_PULLUP);
|
||||||
if (inputPinsPort2[i] != 0)
|
|
||||||
pinMode(inputPinsPort2[i], INPUT_PULLUP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -171,10 +173,10 @@ void loop() {
|
|||||||
bitWrite(Joystick[1].data, i, digitalRead(inputPinsPort2[i])); //AXES2
|
bitWrite(Joystick[1].data, i, digitalRead(inputPinsPort2[i])); //AXES2
|
||||||
}
|
}
|
||||||
|
|
||||||
bitWrite(Joystick[0].data, 4, digitalRead(inputPinsPort1[5])); //JOY1:FIRE1
|
bitWrite(Joystick[0].data, 4, digitalRead(inputPinsPort1[4])); //JOY1:FIRE1
|
||||||
bitWrite(Joystick[0].data, 5, digitalRead(inputPinsPort1[8])); //JOY1:FIRE2
|
bitWrite(Joystick[0].data, 5, digitalRead(inputPinsPort1[5])); //JOY1:FIRE2
|
||||||
bitWrite(Joystick[1].data, 4, digitalRead(inputPinsPort2[5])); //JOY2:FIRE1
|
bitWrite(Joystick[1].data, 4, digitalRead(inputPinsPort2[4])); //JOY2:FIRE1
|
||||||
bitWrite(Joystick[1].data, 5, digitalRead(inputPinsPort2[8])); //JOY2:FIRE2
|
bitWrite(Joystick[1].data, 5, digitalRead(inputPinsPort2[5])); //JOY2:FIRE2
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user