2020-12-04 20:34:40 -05:00
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
|
|
|
#include <SPI.h>
|
|
|
|
#include <nRF24L01.h>
|
|
|
|
#include <RF24.h>
|
|
|
|
|
|
|
|
#define GAMEPAD_REPORT_ARRAY_ADD 1
|
|
|
|
|
|
|
|
#include "gamepad/Gamepad.h"
|
|
|
|
|
2020-12-29 10:58:38 -05:00
|
|
|
#include "pins.h"
|
|
|
|
|
|
|
|
RF24 radio(OR_PIN_7, OR_PIN_8); // CE, CSN
|
2020-12-04 20:34:40 -05:00
|
|
|
|
|
|
|
const byte address[13] = "OpenRetroPad";
|
|
|
|
|
2020-12-05 02:06:48 -05:00
|
|
|
GAMEPAD_CLASS gamepad;
|
2020-12-04 20:34:40 -05:00
|
|
|
|
|
|
|
void setup() {
|
|
|
|
gamepad.begin();
|
|
|
|
radio.begin();
|
|
|
|
radio.openReadingPipe(0, address);
|
|
|
|
radio.setPALevel(RF24_PA_MIN);
|
|
|
|
radio.startListening();
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
if (radio.available() && gamepad.isConnected()) {
|
|
|
|
radio.read(&gamepad.gamepadReport, 16);
|
|
|
|
gamepad.sync(gamepad.gamepadReport[15]);
|
|
|
|
}
|
|
|
|
}
|