Fix flexible array errors
This commit is contained in:
parent
12557b5489
commit
583718f453
8 changed files with 46 additions and 51 deletions
|
|
@ -39,9 +39,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
// Absolute mouse report: 8 buttons, 2 absolute axis, wheel
|
// Absolute mouse report: 8 buttons, 2 absolute axis, wheel
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
struct{
|
struct{
|
||||||
uint8_t buttons;
|
uint8_t buttons;
|
||||||
int16_t xAxis;
|
int16_t xAxis;
|
||||||
|
|
|
||||||
|
|
@ -450,9 +450,9 @@ enum ConsumerKeycode : uint16_t {
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
// Every usable Consumer key possible, up to 4 keys presses possible
|
// Every usable Consumer key possible, up to 4 keys presses possible
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
ConsumerKeycode keys[4];
|
ConsumerKeycode keys[4];
|
||||||
struct {
|
struct {
|
||||||
ConsumerKeycode key1;
|
ConsumerKeycode key1;
|
||||||
|
|
@ -472,7 +472,7 @@ public:
|
||||||
inline void press(ConsumerKeycode m);
|
inline void press(ConsumerKeycode m);
|
||||||
inline void release(ConsumerKeycode m);
|
inline void release(ConsumerKeycode m);
|
||||||
inline void releaseAll(void);
|
inline void releaseAll(void);
|
||||||
|
|
||||||
// Sending is public in the base class for advanced users.
|
// Sending is public in the base class for advanced users.
|
||||||
virtual void SendReport(void* data, int length) = 0;
|
virtual void SendReport(void* data, int length) = 0;
|
||||||
|
|
||||||
|
|
@ -482,4 +482,3 @@ protected:
|
||||||
|
|
||||||
// Implementation is inline
|
// Implementation is inline
|
||||||
#include "ConsumerAPI.hpp"
|
#include "ConsumerAPI.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
// Low level key report: up to 6 keys and shift, ctrl etc at once
|
// Low level key report: up to 6 keys and shift, ctrl etc at once
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
struct{
|
struct{
|
||||||
uint8_t modifiers;
|
uint8_t modifiers;
|
||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
|
|
@ -74,4 +74,3 @@ private:
|
||||||
|
|
||||||
// Implementation is inline
|
// Implementation is inline
|
||||||
#include "DefaultKeyboardAPI.hpp"
|
#include "DefaultKeyboardAPI.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
// 32 Buttons, 6 Axis, 2 D-Pads
|
// 32 Buttons, 6 Axis, 2 D-Pads
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
uint32_t buttons;
|
uint32_t buttons;
|
||||||
|
|
||||||
struct{
|
struct{
|
||||||
|
|
@ -117,7 +117,7 @@ public:
|
||||||
inline void rzAxis(int8_t a);
|
inline void rzAxis(int8_t a);
|
||||||
inline void dPad1(int8_t d);
|
inline void dPad1(int8_t d);
|
||||||
inline void dPad2(int8_t d);
|
inline void dPad2(int8_t d);
|
||||||
|
|
||||||
// Sending is public in the base class for advanced users.
|
// Sending is public in the base class for advanced users.
|
||||||
virtual void SendReport(void* data, int length) = 0;
|
virtual void SendReport(void* data, int length) = 0;
|
||||||
|
|
||||||
|
|
@ -127,4 +127,3 @@ protected:
|
||||||
|
|
||||||
// Implementation is inline
|
// Implementation is inline
|
||||||
#include "GamepadAPI.hpp"
|
#include "GamepadAPI.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
// Mouse report: 8 buttons, position, wheel
|
// Mouse report: 8 buttons, position, wheel
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
struct{
|
struct{
|
||||||
uint8_t buttons;
|
uint8_t buttons;
|
||||||
int8_t xAxis;
|
int8_t xAxis;
|
||||||
|
|
@ -53,9 +53,9 @@ typedef union{
|
||||||
typedef union{
|
typedef union{
|
||||||
// BootMouse report: 3 buttons, position
|
// BootMouse report: 3 buttons, position
|
||||||
// Wheel is not supported by boot protocol
|
// Wheel is not supported by boot protocol
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
struct{
|
struct{
|
||||||
uint8_t buttons;
|
uint8_t buttons;
|
||||||
int8_t xAxis;
|
int8_t xAxis;
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
// Modifier + keymap + 1 custom key
|
// Modifier + keymap + 1 custom key
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
struct{
|
struct{
|
||||||
uint8_t modifiers;
|
uint8_t modifiers;
|
||||||
uint8_t keys[NKRO_KEY_COUNT / 8];
|
uint8_t keys[NKRO_KEY_COUNT / 8];
|
||||||
|
|
@ -43,7 +43,7 @@ typedef union{
|
||||||
uint8_t allkeys[2 + NKRO_KEY_COUNT / 8];
|
uint8_t allkeys[2 + NKRO_KEY_COUNT / 8];
|
||||||
} HID_NKROKeyboardReport_Data_t;
|
} HID_NKROKeyboardReport_Data_t;
|
||||||
|
|
||||||
|
|
||||||
class NKROKeyboardAPI : public KeyboardAPI
|
class NKROKeyboardAPI : public KeyboardAPI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -62,4 +62,3 @@ private:
|
||||||
|
|
||||||
// Implementation is inline
|
// Implementation is inline
|
||||||
#include "NKROKeyboardAPI.hpp"
|
#include "NKROKeyboardAPI.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ enum SystemKeycode : uint8_t {
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
// Every usable system control key possible
|
// Every usable system control key possible
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint8_t key;
|
uint8_t key;
|
||||||
} HID_SystemControlReport_Data_t;
|
} HID_SystemControlReport_Data_t;
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ public:
|
||||||
inline void press(SystemKeycode s);
|
inline void press(SystemKeycode s);
|
||||||
inline void release(void);
|
inline void release(void);
|
||||||
inline void releaseAll(void);
|
inline void releaseAll(void);
|
||||||
|
|
||||||
// Sending is public in the base class for advanced users.
|
// Sending is public in the base class for advanced users.
|
||||||
virtual void SendReport(void* data, int length) = 0;
|
virtual void SendReport(void* data, int length) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -54,17 +54,17 @@ THE SOFTWARE.
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
// a RAWHID_TX_SIZE byte buffer for tx
|
// a RAWHID_TX_SIZE byte buffer for tx
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
uint8_t buff[RAWHID_TX_SIZE];
|
uint8_t buff[RAWHID_TX_SIZE];
|
||||||
} HID_RawKeyboardTXReport_Data_t;
|
} HID_RawKeyboardTXReport_Data_t;
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
// a RAWHID_TX_SIZE byte buffer for rx
|
// a RAWHID_TX_SIZE byte buffer for rx
|
||||||
uint8_t whole8[];
|
uint8_t whole8[0];
|
||||||
uint16_t whole16[];
|
uint16_t whole16[0];
|
||||||
uint32_t whole32[];
|
uint32_t whole32[0];
|
||||||
uint8_t buff[RAWHID_RX_SIZE];
|
uint8_t buff[RAWHID_RX_SIZE];
|
||||||
} HID_RawKeyboardRXReport_Data_t;
|
} HID_RawKeyboardRXReport_Data_t;
|
||||||
|
|
||||||
|
|
@ -77,23 +77,23 @@ public:
|
||||||
if(length > 0){
|
if(length > 0){
|
||||||
featureReport = (uint8_t*)report;
|
featureReport = (uint8_t*)report;
|
||||||
featureLength = length;
|
featureLength = length;
|
||||||
|
|
||||||
// Disable feature report by default
|
// Disable feature report by default
|
||||||
disableFeatureReport();
|
disableFeatureReport();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int availableFeatureReport(void){
|
int availableFeatureReport(void){
|
||||||
if(featureLength < 0){
|
if(featureLength < 0){
|
||||||
return featureLength & ~0x8000;
|
return featureLength & ~0x8000;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableFeatureReport(void){
|
void enableFeatureReport(void){
|
||||||
featureLength &= ~0x8000;
|
featureLength &= ~0x8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disableFeatureReport(void){
|
void disableFeatureReport(void){
|
||||||
featureLength |= 0x8000;
|
featureLength |= 0x8000;
|
||||||
}
|
}
|
||||||
|
|
@ -110,22 +110,22 @@ public:
|
||||||
disable();
|
disable();
|
||||||
dataLength = 0;
|
dataLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enable(void){
|
void enable(void){
|
||||||
dataAvailable = 0;
|
dataAvailable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disable(void){
|
void disable(void){
|
||||||
dataAvailable = -1;
|
dataAvailable = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int available(void){
|
virtual int available(void){
|
||||||
if(dataAvailable < 0){
|
if(dataAvailable < 0){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return dataAvailable;
|
return dataAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int read(){
|
virtual int read(){
|
||||||
// Check if we have data available
|
// Check if we have data available
|
||||||
if(dataAvailable > 0)
|
if(dataAvailable > 0)
|
||||||
|
|
@ -135,7 +135,7 @@ public:
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int peek(){
|
virtual int peek(){
|
||||||
// Check if we have data available
|
// Check if we have data available
|
||||||
if(dataAvailable > 0){
|
if(dataAvailable > 0){
|
||||||
|
|
@ -143,7 +143,7 @@ public:
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void flush(void){
|
virtual void flush(void){
|
||||||
// Writing will always flush by the USB driver
|
// Writing will always flush by the USB driver
|
||||||
}
|
}
|
||||||
|
|
@ -157,24 +157,23 @@ public:
|
||||||
virtual size_t write(uint8_t *buffer, size_t size){
|
virtual size_t write(uint8_t *buffer, size_t size){
|
||||||
return USB_Send(pluggedEndpoint | TRANSFER_RELEASE, buffer, size);
|
return USB_Send(pluggedEndpoint | TRANSFER_RELEASE, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Implementation of the PUSBListNode
|
// Implementation of the PUSBListNode
|
||||||
int getInterface(uint8_t* interfaceCount);
|
int getInterface(uint8_t* interfaceCount);
|
||||||
int getDescriptor(USBSetup& setup);
|
int getDescriptor(USBSetup& setup);
|
||||||
bool setup(USBSetup& setup);
|
bool setup(USBSetup& setup);
|
||||||
|
|
||||||
uint8_t epType[1];
|
uint8_t epType[1];
|
||||||
uint8_t protocol;
|
uint8_t protocol;
|
||||||
uint8_t idle;
|
uint8_t idle;
|
||||||
|
|
||||||
// Buffer pointers to hold the received data
|
// Buffer pointers to hold the received data
|
||||||
int dataLength;
|
int dataLength;
|
||||||
int dataAvailable;
|
int dataAvailable;
|
||||||
uint8_t* data;
|
uint8_t* data;
|
||||||
|
|
||||||
uint8_t* featureReport;
|
uint8_t* featureReport;
|
||||||
int featureLength;
|
int featureLength;
|
||||||
};
|
};
|
||||||
extern RawHID_ RawHID;
|
extern RawHID_ RawHID;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue