Small change to Sega two controller adapter wiring.
Small change to Sega two controller adapter wiring. Wiring diagrams added for Sega two controller adapter and NES/SNES adapters.
This commit is contained in:
parent
32e910d3a6
commit
1015f20cd3
|
@ -0,0 +1,3 @@
|
||||||
|
# Ignore VS Code folders
|
||||||
|
.vscode
|
||||||
|
.build
|
|
@ -47,8 +47,8 @@
|
||||||
// (Second controller port for future reference)
|
// (Second controller port for future reference)
|
||||||
// 1 15 PB1
|
// 1 15 PB1
|
||||||
// 2 14 PB3
|
// 2 14 PB3
|
||||||
// 3 16 PB2
|
// 3 2 PD1
|
||||||
// 4 10 PB6
|
// 4 5 PC6
|
||||||
// 5 A2 PF5
|
// 5 A2 PF5
|
||||||
// 6 7 PE6 (Important: Connect this pin via a 220Ω resistor!)
|
// 6 7 PE6 (Important: Connect this pin via a 220Ω resistor!)
|
||||||
// 7 VCC
|
// 7 VCC
|
||||||
|
|
|
@ -9,7 +9,7 @@ With this simple to build adapter you can connect NES gamepads to a PC, Raspber
|
||||||
- Micro USB cable
|
- Micro USB cable
|
||||||
|
|
||||||
## Wiring
|
## Wiring
|
||||||
![Assemble1](images/nes-usb-adapter-wiring.png)
|
![Assemble1](images/snes-usb-adapter-wiring.png)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This project is licensed under the GNU General Public License v3.0.
|
This project is licensed under the GNU General Public License v3.0.
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 267 KiB |
|
@ -0,0 +1,25 @@
|
||||||
|
# DaemonBite Sega Controllers To USB Adapter
|
||||||
|
## Introduction
|
||||||
|
This is a simple to build adapter for connecting two Mega Drive (Genesis), Master System (+ Atari and C= controllers) to USB. It supports 3 and 6-button Mega Drive controllers and 1 and 2-button SMS/Atari/C= controllers.
|
||||||
|
|
||||||
|
The input lag for this adapter is minimal. Here is the result from a test with a 1ms polling rate on a MiSTer (one port version):
|
||||||
|
|
||||||
|
| Controller | Samples | Average | Max | Min | Std Dev |
|
||||||
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
||||||
|
| Original 3-Button Mega Drive Controller | 2342 | 0.75ms | 1.28ms | 0.24ms | 0.29ms |
|
||||||
|
| 8bitdo M30 Wireless 2.4G | 2348 | 4.54ms | 8.05ms | 2.22ms | 1.31ms |
|
||||||
|
|
||||||
|
## Parts you need
|
||||||
|
- Arduino Pro Micro (ATMega32U4)
|
||||||
|
- 2x Male end of Mega Drive controller extension (or DSUB 9Pin Male connectors and some wires)
|
||||||
|
- Heat shrink tube (Ø ~20mm)
|
||||||
|
- Micro USB cable
|
||||||
|
|
||||||
|
## Wiring
|
||||||
|
![Assemble1](images/sega-usb-2x-adapter-wiring.png)
|
||||||
|
|
||||||
|
## License
|
||||||
|
This project is licensed under the GNU General Public License v3.0.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
The Mega Drive gamepad interface is based on this repository : https://github.com/jonthysell/SegaController but almost entirely rewritten and a lot of optimisations have been made.
|
|
@ -33,25 +33,28 @@
|
||||||
|
|
||||||
SegaControllers32U4::SegaControllers32U4(void)
|
SegaControllers32U4::SegaControllers32U4(void)
|
||||||
{
|
{
|
||||||
// Setup select pin as output high (16, PB2)
|
// Setup select pin as output high (6, PD7)
|
||||||
DDRB |= B00000100; // output
|
DDRD |= B10000000; // output
|
||||||
PORTB |= B00000100; // high
|
PORTD |= B10000000; // high
|
||||||
// Setup select pin as output high (5, PC6)
|
// Setup select pin as output high (5, PC6)
|
||||||
DDRC |= B01000000; // output
|
DDRC |= B01000000; // output
|
||||||
PORTC |= B01000000; // high
|
PORTC |= B01000000; // high
|
||||||
|
|
||||||
// Setup input pins (A0,A1,A2,A3,14,15,16 or PF7,PF6,PF5,PF4,PB3,PB1,PB2)
|
// Setup input pins (A0,A1,A2,A3,14,15 or PF7,PF6,PF5,PF4,PB3,PB1)
|
||||||
DDRF &= ~B11110000; // input
|
DDRF &= ~B11110000; // input
|
||||||
PORTF |= B11110000; // high to enable internal pull-up
|
PORTF |= B11110000; // high to enable internal pull-up
|
||||||
DDRB &= ~B00001010; // input
|
DDRB &= ~B00001010; // input
|
||||||
PORTB |= B00001010; // high to enable internal pull-up
|
PORTB |= B00001010; // high to enable internal pull-up
|
||||||
// Setup input pins (TXO,RXI,2,3,4,6 or PD3,PD2,PD1,PD0,PD4,PD7)
|
// Setup input pins (TXO,RXI,2,3,4,6 or PD3,PD2,PD1,PD0,PD4,PE6)
|
||||||
DDRD &= ~B10011111; // input
|
DDRD &= ~B00011111; // input
|
||||||
PORTD |= B10011111; // high to enable internal pull-up
|
PORTD |= B00011111; // high to enable internal pull-up
|
||||||
|
DDRE &= ~B01000000; // input
|
||||||
|
PORTE |= B01000000; // high to enable internal pull-up
|
||||||
|
|
||||||
_inputReg1 = 0;
|
_inputReg1 = 0;
|
||||||
_inputReg2 = 0;
|
_inputReg2 = 0;
|
||||||
_inputReg3 = 0;
|
_inputReg3 = 0;
|
||||||
|
_inputReg4 = 0;
|
||||||
for(byte i=0; i<=1; i++)
|
for(byte i=0; i<=1; i++)
|
||||||
{
|
{
|
||||||
_currentState[i] = 0;
|
_currentState[i] = 0;
|
||||||
|
@ -77,7 +80,7 @@ word SegaControllers32U4::getStateMD1()
|
||||||
|
|
||||||
// Set the select pin low/high
|
// Set the select pin low/high
|
||||||
_pinSelect[0] = !_pinSelect[0];
|
_pinSelect[0] = !_pinSelect[0];
|
||||||
(!_pinSelect[0]) ? PORTB &= ~B00000100 : PORTB |= B00000100; // Set LOW on even cycle, HIGH on uneven cycle
|
(!_pinSelect[0]) ? PORTD &= ~B10000000 : PORTD |= B10000000; // Set LOW on even cycle, HIGH on uneven cycle
|
||||||
|
|
||||||
// Short delay to stabilise outputs in controller
|
// Short delay to stabilise outputs in controller
|
||||||
delayMicroseconds(SC_CYCLE_DELAY);
|
delayMicroseconds(SC_CYCLE_DELAY);
|
||||||
|
@ -166,6 +169,7 @@ word SegaControllers32U4::getStateMD2()
|
||||||
|
|
||||||
// Read input register(s)
|
// Read input register(s)
|
||||||
_inputReg3 = PIND;
|
_inputReg3 = PIND;
|
||||||
|
_inputReg4 = PINE;
|
||||||
|
|
||||||
if(_ignoreCycles[1] <= 0)
|
if(_ignoreCycles[1] <= 0)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +196,7 @@ word SegaControllers32U4::getStateMD2()
|
||||||
(bitRead(_inputReg3, DB9_PIN3_BIT2) == LOW) ? _currentState[1] |= SC_BTN_LEFT : _currentState[1] &= ~SC_BTN_LEFT;
|
(bitRead(_inputReg3, DB9_PIN3_BIT2) == LOW) ? _currentState[1] |= SC_BTN_LEFT : _currentState[1] &= ~SC_BTN_LEFT;
|
||||||
(bitRead(_inputReg3, DB9_PIN4_BIT2) == LOW) ? _currentState[1] |= SC_BTN_RIGHT : _currentState[1] &= ~SC_BTN_RIGHT;
|
(bitRead(_inputReg3, DB9_PIN4_BIT2) == LOW) ? _currentState[1] |= SC_BTN_RIGHT : _currentState[1] &= ~SC_BTN_RIGHT;
|
||||||
(bitRead(_inputReg3, DB9_PIN6_BIT2) == LOW) ? _currentState[1] |= SC_BTN_B : _currentState[1] &= ~SC_BTN_B;
|
(bitRead(_inputReg3, DB9_PIN6_BIT2) == LOW) ? _currentState[1] |= SC_BTN_B : _currentState[1] &= ~SC_BTN_B;
|
||||||
(bitRead(_inputReg3, DB9_PIN9_BIT2) == LOW) ? _currentState[1] |= SC_BTN_C : _currentState[1] &= ~SC_BTN_C;
|
(bitRead(_inputReg4, DB9_PIN9_BIT2) == LOW) ? _currentState[1] |= SC_BTN_C : _currentState[1] &= ~SC_BTN_C;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // No Mega Drive controller is connected, use SMS/Atari mode
|
else // No Mega Drive controller is connected, use SMS/Atari mode
|
||||||
|
@ -206,7 +210,7 @@ word SegaControllers32U4::getStateMD2()
|
||||||
if (bitRead(_inputReg3, DB9_PIN3_BIT2) == LOW) { _currentState[1] |= SC_BTN_LEFT; }
|
if (bitRead(_inputReg3, DB9_PIN3_BIT2) == LOW) { _currentState[1] |= SC_BTN_LEFT; }
|
||||||
if (bitRead(_inputReg3, DB9_PIN4_BIT2) == LOW) { _currentState[1] |= SC_BTN_RIGHT; }
|
if (bitRead(_inputReg3, DB9_PIN4_BIT2) == LOW) { _currentState[1] |= SC_BTN_RIGHT; }
|
||||||
if (bitRead(_inputReg3, DB9_PIN6_BIT2) == LOW) { _currentState[1] |= SC_BTN_A; }
|
if (bitRead(_inputReg3, DB9_PIN6_BIT2) == LOW) { _currentState[1] |= SC_BTN_A; }
|
||||||
if (bitRead(_inputReg3, DB9_PIN9_BIT2) == LOW) { _currentState[1] |= SC_BTN_B; }
|
if (bitRead(_inputReg4, DB9_PIN9_BIT2) == LOW) { _currentState[1] |= SC_BTN_B; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Select pin is LOW
|
else // Select pin is LOW
|
||||||
|
@ -223,7 +227,7 @@ word SegaControllers32U4::getStateMD2()
|
||||||
if(!_sixButtonMode[1])
|
if(!_sixButtonMode[1])
|
||||||
{
|
{
|
||||||
(bitRead(_inputReg3, DB9_PIN6_BIT2) == LOW) ? _currentState[1] |= SC_BTN_A : _currentState[1] &= ~SC_BTN_A;
|
(bitRead(_inputReg3, DB9_PIN6_BIT2) == LOW) ? _currentState[1] |= SC_BTN_A : _currentState[1] &= ~SC_BTN_A;
|
||||||
(bitRead(_inputReg3, DB9_PIN9_BIT2) == LOW) ? _currentState[1] |= SC_BTN_START : _currentState[1] &= ~SC_BTN_START;
|
(bitRead(_inputReg4, DB9_PIN9_BIT2) == LOW) ? _currentState[1] |= SC_BTN_START : _currentState[1] &= ~SC_BTN_START;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ enum
|
||||||
DB9_PIN3_BIT2 = 1,
|
DB9_PIN3_BIT2 = 1,
|
||||||
DB9_PIN4_BIT2 = 0,
|
DB9_PIN4_BIT2 = 0,
|
||||||
DB9_PIN6_BIT2 = 4,
|
DB9_PIN6_BIT2 = 4,
|
||||||
DB9_PIN9_BIT2 = 7
|
DB9_PIN9_BIT2 = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
const byte SC_INPUT_PINS = 6;
|
const byte SC_INPUT_PINS = 6;
|
||||||
|
@ -83,6 +83,7 @@ class SegaControllers32U4 {
|
||||||
byte _inputReg1;
|
byte _inputReg1;
|
||||||
byte _inputReg2;
|
byte _inputReg2;
|
||||||
byte _inputReg3;
|
byte _inputReg3;
|
||||||
|
byte _inputReg4;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
// 3 A2 PF5
|
// 3 A2 PF5
|
||||||
// 4 A3 PF4
|
// 4 A3 PF4
|
||||||
// 6 14 PB3
|
// 6 14 PB3
|
||||||
// 7 16 PB2 (6 PD7)
|
// 7 6 PD7
|
||||||
// 9 15 PB1
|
// 9 15 PB1
|
||||||
|
|
||||||
// 1 TXO PD3
|
// 1 TXO PD3
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
// 4 3 PD0
|
// 4 3 PD0
|
||||||
// 6 4 PD4
|
// 6 4 PD4
|
||||||
// 7 5 PC6
|
// 7 5 PC6
|
||||||
// 9 6 PD7
|
// 9 7 PE6
|
||||||
|
|
||||||
SegaControllers32U4 controllers;
|
SegaControllers32U4 controllers;
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 317 KiB |
Loading…
Reference in New Issue