mirror of
https://github.com/ndeadly/MissionControl
synced 2024-12-18 00:23:12 +00:00
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
|
#pragma once
|
||
|
#include <stratosphere.hpp>
|
||
|
#include <switch.h>
|
||
|
|
||
|
#define BLUETOOTH_CIRCBUFFER_SIZE 10000
|
||
|
|
||
|
namespace ams::bluetooth {
|
||
|
|
||
|
enum CircularBufferType {
|
||
|
CircularBufferType_Unknown,
|
||
|
CircularBufferType_HidReport,
|
||
|
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);
|
||
|
|
||
|
u64 WritePacket(const CircularBufferPacket *packet); // Not a real function, used to write translated packet into buffer
|
||
|
|
||
|
//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::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];
|
||
|
};
|
||
|
|
||
|
}
|