mirror of
https://github.com/ndeadly/MissionControl
synced 2024-12-11 21:32:36 +00:00
70 lines
2 KiB
C++
70 lines
2 KiB
C++
#pragma once
|
|
#include <stratosphere.hpp>
|
|
#include <switch.h>
|
|
|
|
#define BLUETOOTH_CIRCBUFFER_SIZE 10000
|
|
|
|
namespace ams::bluetooth {
|
|
|
|
enum CircularBufferType {
|
|
CircularBufferType_HidReport = 0x1,
|
|
CircularBufferType_Bluetooth,
|
|
CircularBufferType_Ble,
|
|
CircularBufferType_BleCore,
|
|
CircularBufferType_BleHid,
|
|
};
|
|
|
|
struct CircularBufferPacketHeader{
|
|
u8 type; //+0x00
|
|
os::Tick timestamp; //+0x08
|
|
u64 size; //+0x10
|
|
};
|
|
|
|
struct CircularBufferPacket{
|
|
CircularBufferPacketHeader header;
|
|
HidReportData data;
|
|
};
|
|
|
|
//class CircularBuffer {
|
|
struct CircularBuffer {
|
|
//public:
|
|
CircularBuffer(void);
|
|
|
|
void Initialize(const char *name); // 10.0.0+
|
|
void Finalize(void);
|
|
bool IsInitialized(void);
|
|
u64 GetWriteableSize(void);
|
|
void AttachEvent(os::EventType *event); // Introduced in 10.0.0. Made-up name
|
|
u64 Write(u8 type, void *data, size_t size);
|
|
void DiscardOldPackets(u8 a1, u32 a2);
|
|
void *Read(void);
|
|
u64 Free(void);
|
|
|
|
//private:
|
|
void _setReadOffset(u32 offset);
|
|
void _setWriteOffset(u32 offset);
|
|
u32 _getWriteOffset(void);
|
|
u32 _getReadOffset(void);
|
|
u64 _write(u8 type, void *data, size_t size);
|
|
void _updateUtilization(void);
|
|
void *_read(void);
|
|
|
|
//private:
|
|
//os::SdkMutexType mutex;
|
|
os::SdkMutex mutex;
|
|
os::EventType *event;
|
|
|
|
u8 data[BLUETOOTH_CIRCBUFFER_SIZE];
|
|
u32 writeOffset;
|
|
u32 readOffset;
|
|
s64 size;
|
|
char name[16];
|
|
u8 _unk1;
|
|
bool isInitialized;
|
|
u8 _unk2[6];
|
|
u32 id;
|
|
bool _unk3;
|
|
//u8 _unk3[4];
|
|
};
|
|
|
|
}
|