Something went wrong. Try again.
Opensource firmware for NRF52840 Pro Micro that copycats the Steam Controller 2 Puck and adds an Xbox and Switch mode
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#include "bonds.h"#include <Adafruit_LittleFS.h>#include <InternalFileSystem.h>using namespace Adafruit_LittleFS_Namespace;
Slot g_slot[NSLOT];int g_connSlot = -1;unsigned long g_connReplyMs = 0;volatile bool g_dirty = false;bool g_pairing = false;
#define BOND_FILE "/bonds.bin"
bool recEmpty(const uint8_t *r){ for (int i = 0; i < 24; i++) if (r[i]) return false; return true;}
void saveBonds(){ InternalFS.remove(BOND_FILE); File f(InternalFS); if (f.open(BOND_FILE, FILE_O_WRITE)) { for (int i = 0; i < NSLOT; i++) { uint8_t u = g_slot[i].used ? 1 : 0; f.write(&u, 1); f.write(g_slot[i].rec, 24); } f.close(); }}
void loadBonds(){ File f(InternalFS); if (f.open(BOND_FILE, FILE_O_READ)) for (int i = 0; i < NSLOT; i++) { uint8_t u = 0; if (f.read(&u, 1) == 1) { g_slot[i].used = u; f.read(g_slot[i].rec, 24); } } f.close();}