Remove static_asserts from hid.h in order to avoid a hard dependency on C11

This commit is contained in:
fincs 2019-01-01 03:27:43 +01:00
parent e59036d4c8
commit 49efa74e70

View File

@ -6,7 +6,6 @@
* @copyright libnx Authors * @copyright libnx Authors
*/ */
#pragma once #pragma once
#include <assert.h>
#include "../types.h" #include "../types.h"
#include "../kernel/event.h" #include "../kernel/event.h"
#include "../services/sm.h" #include "../services/sm.h"
@ -379,14 +378,12 @@ typedef struct HidTouchScreenHeader
u64 maxEntryIndex; u64 maxEntryIndex;
u64 timestamp; u64 timestamp;
} HidTouchScreenHeader; } HidTouchScreenHeader;
static_assert(sizeof(HidTouchScreenHeader) == 0x28, "Hid touch screen header structure has incorrect size");
typedef struct HidTouchScreenEntryHeader typedef struct HidTouchScreenEntryHeader
{ {
u64 timestamp; u64 timestamp;
u64 numTouches; u64 numTouches;
} HidTouchScreenEntryHeader; } HidTouchScreenEntryHeader;
static_assert(sizeof(HidTouchScreenEntryHeader) == 0x10, "Hid touch screen entry header structure has incorrect size");
typedef struct HidTouchScreenEntryTouch typedef struct HidTouchScreenEntryTouch
{ {
@ -400,7 +397,6 @@ typedef struct HidTouchScreenEntryTouch
u32 angle; u32 angle;
u32 padding_2; u32 padding_2;
} HidTouchScreenEntryTouch; } HidTouchScreenEntryTouch;
static_assert(sizeof(HidTouchScreenEntryTouch) == 0x28, "Hid touch screen touch structure has incorrect size");
typedef struct HidTouchScreenEntry typedef struct HidTouchScreenEntry
{ {
@ -408,7 +404,6 @@ typedef struct HidTouchScreenEntry
HidTouchScreenEntryTouch touches[16]; HidTouchScreenEntryTouch touches[16];
u64 unk; u64 unk;
} HidTouchScreenEntry; } HidTouchScreenEntry;
static_assert(sizeof(HidTouchScreenEntry) == 0x298, "Hid touch screen entry structure has incorrect size");
typedef struct HidTouchScreen typedef struct HidTouchScreen
{ {
@ -416,7 +411,6 @@ typedef struct HidTouchScreen
HidTouchScreenEntry entries[17]; HidTouchScreenEntry entries[17];
u8 padding[0x3c0]; u8 padding[0x3c0];
} HidTouchScreen; } HidTouchScreen;
static_assert(sizeof(HidTouchScreen) == 0x3000, "Hid touch screen structure has incorrect size");
// End HidTouchScreen // End HidTouchScreen
@ -429,7 +423,6 @@ typedef struct HidMouseHeader
u64 latestEntry; u64 latestEntry;
u64 maxEntryIndex; u64 maxEntryIndex;
} HidMouseHeader; } HidMouseHeader;
static_assert(sizeof(HidMouseHeader) == 0x20, "Hid mouse header structure has incorrect size");
typedef struct HidMouseEntry typedef struct HidMouseEntry
{ {
@ -438,7 +431,6 @@ typedef struct HidMouseEntry
MousePosition position; MousePosition position;
u64 buttons; u64 buttons;
} HidMouseEntry; } HidMouseEntry;
static_assert(sizeof(HidMouseEntry) == 0x30, "Hid mouse entry structure has incorrect size");
typedef struct HidMouse typedef struct HidMouse
{ {
@ -446,7 +438,6 @@ typedef struct HidMouse
HidMouseEntry entries[17]; HidMouseEntry entries[17];
u8 padding[0xB0]; u8 padding[0xB0];
} HidMouse; } HidMouse;
static_assert(sizeof(HidMouse) == 0x400, "Hid mouse structure has incorrect size");
// End HidMouse // End HidMouse
@ -459,7 +450,6 @@ typedef struct HidKeyboardHeader
u64 latestEntry; u64 latestEntry;
u64 maxEntryIndex; u64 maxEntryIndex;
} HidKeyboardHeader; } HidKeyboardHeader;
static_assert(sizeof(HidKeyboardHeader) == 0x20, "Hid keyboard header structure has incorrect size");
typedef struct HidKeyboardEntry typedef struct HidKeyboardEntry
{ {
@ -468,7 +458,6 @@ typedef struct HidKeyboardEntry
u64 modifier; u64 modifier;
u32 keys[8]; u32 keys[8];
} HidKeyboardEntry; } HidKeyboardEntry;
static_assert(sizeof(HidKeyboardEntry) == 0x38, "Hid keyboard entry structure has incorrect size");
typedef struct HidKeyboard typedef struct HidKeyboard
{ {
@ -476,7 +465,6 @@ typedef struct HidKeyboard
HidKeyboardEntry entries[17]; HidKeyboardEntry entries[17];
u8 padding[0x28]; u8 padding[0x28];
} HidKeyboard; } HidKeyboard;
static_assert(sizeof(HidKeyboard) == 0x400, "Hid keyboard structure has incorrect size");
// End HidKeyboard // End HidKeyboard
@ -489,7 +477,6 @@ typedef struct HidControllerMAC
u64 unk; u64 unk;
u64 timestamp_2; u64 timestamp_2;
} HidControllerMAC; } HidControllerMAC;
static_assert(sizeof(HidControllerMAC) == 0x20, "Hid controller MAC structure has incorrect size");
typedef struct HidControllerHeader typedef struct HidControllerHeader
{ {
@ -504,7 +491,6 @@ typedef struct HidControllerHeader
u32 rightColorBody; u32 rightColorBody;
u32 rightColorButtons; u32 rightColorButtons;
} HidControllerHeader; } HidControllerHeader;
static_assert(sizeof(HidControllerHeader) == 0x28, "Hid controller header structure has incorrect size");
/// Info struct extracted from HidControllerHeader. /// Info struct extracted from HidControllerHeader.
/// Color fields are zero when not set. This can happen even when the *Set fields are set to true. /// Color fields are zero when not set. This can happen even when the *Set fields are set to true.
@ -528,7 +514,6 @@ typedef struct HidControllerLayoutHeader
u64 latestEntry; u64 latestEntry;
u64 maxEntryIndex; u64 maxEntryIndex;
} HidControllerLayoutHeader; } HidControllerLayoutHeader;
static_assert(sizeof(HidControllerLayoutHeader) == 0x20, "Hid controller layout header structure has incorrect size");
typedef struct HidControllerInputEntry typedef struct HidControllerInputEntry
{ {
@ -538,14 +523,12 @@ typedef struct HidControllerInputEntry
JoystickPosition joysticks[JOYSTICK_NUM_STICKS]; JoystickPosition joysticks[JOYSTICK_NUM_STICKS];
u64 connectionState; u64 connectionState;
} HidControllerInputEntry; } HidControllerInputEntry;
static_assert(sizeof(HidControllerInputEntry) == 0x30, "Hid controller input entry structure has incorrect size");
typedef struct HidControllerLayout typedef struct HidControllerLayout
{ {
HidControllerLayoutHeader header; HidControllerLayoutHeader header;
HidControllerInputEntry entries[17]; HidControllerInputEntry entries[17];
} HidControllerLayout; } HidControllerLayout;
static_assert(sizeof(HidControllerLayout) == 0x350, "Hid controller layout structure has incorrect size");
typedef struct HidControllerSixAxisHeader typedef struct HidControllerSixAxisHeader
{ {
@ -554,7 +537,6 @@ typedef struct HidControllerSixAxisHeader
u64 latestEntry; u64 latestEntry;
u64 maxEntryIndex; u64 maxEntryIndex;
} HidControllerSixAxisHeader; } HidControllerSixAxisHeader;
static_assert(sizeof(HidControllerSixAxisHeader) == 0x20, "Hid controller sixaxis header structure has incorrect size");
typedef struct HidControllerSixAxisEntry typedef struct HidControllerSixAxisEntry
{ {
@ -564,14 +546,12 @@ typedef struct HidControllerSixAxisEntry
SixAxisSensorValues values; SixAxisSensorValues values;
u64 unk_3; u64 unk_3;
} HidControllerSixAxisEntry; } HidControllerSixAxisEntry;
static_assert(sizeof(HidControllerSixAxisEntry) == 0x68, "Hid controller sixaxis entry structure has incorrect size");
typedef struct HidControllerSixAxisLayout typedef struct HidControllerSixAxisLayout
{ {
HidControllerSixAxisHeader header; HidControllerSixAxisHeader header;
HidControllerSixAxisEntry entries[17]; HidControllerSixAxisEntry entries[17];
} HidControllerSixAxisLayout; } HidControllerSixAxisLayout;
static_assert(sizeof(HidControllerSixAxisLayout) == 0x708, "Hid controller sixaxis layout structure has incorrect size");
typedef struct HidController typedef struct HidController
{ {
@ -583,7 +563,6 @@ typedef struct HidController
HidControllerMAC macRight; HidControllerMAC macRight;
u8 unk_2[0xDF8]; u8 unk_2[0xDF8];
} HidController; } HidController;
static_assert(sizeof(HidController) == 0x5000, "Hid controller structure has incorrect size");
// End HidController // End HidController
@ -605,14 +584,12 @@ typedef struct HidSharedMemory
HidController controllers[10]; HidController controllers[10];
u8 unkSection9[0x4600]; u8 unkSection9[0x4600];
} HidSharedMemory; } HidSharedMemory;
static_assert(sizeof(HidSharedMemory) == 0x40000, "Hid Shared Memory structure has incorrect size");
typedef struct HidVibrationDeviceInfo typedef struct HidVibrationDeviceInfo
{ {
u32 unk_x0; u32 unk_x0;
u32 unk_x4; ///< 0x1 for left-joycon, 0x2 for right-joycon. u32 unk_x4; ///< 0x1 for left-joycon, 0x2 for right-joycon.
} HidVibrationDeviceInfo; } HidVibrationDeviceInfo;
static_assert(sizeof(HidVibrationDeviceInfo) == 0x8, "Hid VibrationDeviceInfo structure has incorrect size");
typedef struct HidVibrationValue typedef struct HidVibrationValue
{ {
@ -621,7 +598,6 @@ typedef struct HidVibrationValue
float amp_high; ///< High Band amplitude. 1.0f: Max amplitude. float amp_high; ///< High Band amplitude. 1.0f: Max amplitude.
float freq_high; ///< High Band frequency in Hz. float freq_high; ///< High Band frequency in Hz.
} HidVibrationValue; } HidVibrationValue;
static_assert(sizeof(HidVibrationValue) == 0x10, "Hid VibrationValue structure has incorrect size");
Result hidInitialize(void); Result hidInitialize(void);
void hidExit(void); void hidExit(void);