SukkoPera/PsxNewLib

Dual Controller Support?

dgorbunov opened this issue · 2 comments

Hey SukkoPera, thanks for making this great library! I was wondering if or how it is possible to implement two controllers through PsxNewLib... Does the library currently support this function? I suppose it would only be possible to BitBang the second controller due to the lack of more SPI ports on most Arduinos - but never the less it would be very useful, as most converters out there have 2 controller ports.

Ah.. just figured it out. Need to initialize second controller with new sets of pins like this: PsxControllerBitBang<PIN_PS2_ATT_2, PIN_PS2_CMD_2, PIN_PS2_DAT_2, PIN_PS2_CLK_2> psx2; and use psx2.method() for everything.

That should work, but please note that the SPI bus is a... well, bus: the MISO/MOSI/SCK lines can be shared among many peripherals, provided that each one has a separate SS pin. So you can just do:

PsxControllerHwSpi<10> controller1;
PsxControllerHwSpi<11> controller2;

Where 10 and 11 are the SS pins you are using for each device. On an Uno/ATmega328, I strongly recommend to use pin 10 for one of devices, the other ones you can choose freely.

This has never been tested but it should work.