mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-31 22:02:15 +02:00
Added hidGetControllerColors and HidControllerColors. Changed rightColorbuttons to rightColorButtons in HidControllerHeader. Updated CONTROLLER_P1_AUTO comment.
This commit is contained in:
parent
052fb34397
commit
6a9d194fe3
@ -310,7 +310,7 @@ typedef enum
|
|||||||
CONTROLLER_PLAYER_8 = 7,
|
CONTROLLER_PLAYER_8 = 7,
|
||||||
CONTROLLER_HANDHELD = 8,
|
CONTROLLER_HANDHELD = 8,
|
||||||
CONTROLLER_UNKNOWN = 9,
|
CONTROLLER_UNKNOWN = 9,
|
||||||
CONTROLLER_P1_AUTO = 10, /// Not an actual HID-sysmodule ID. Only for hidKeys*()/hidJoystickRead(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD.
|
CONTROLLER_P1_AUTO = 10, /// Not an actual HID-sysmodule ID. Only for hidKeys*()/hidJoystickRead()/hidSixAxisSensorValuesRead()/hidGetControllerType()/hidGetControllerColors(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD.
|
||||||
} HidControllerID;
|
} HidControllerID;
|
||||||
|
|
||||||
typedef struct touchPosition
|
typedef struct touchPosition
|
||||||
@ -491,10 +491,25 @@ typedef struct HidControllerHeader
|
|||||||
u32 leftColorBody;
|
u32 leftColorBody;
|
||||||
u32 leftColorButtons;
|
u32 leftColorButtons;
|
||||||
u32 rightColorBody;
|
u32 rightColorBody;
|
||||||
u32 rightColorbuttons;
|
u32 rightColorButtons;
|
||||||
} HidControllerHeader;
|
} HidControllerHeader;
|
||||||
static_assert(sizeof(HidControllerHeader) == 0x28, "Hid controller header structure has incorrect size");
|
static_assert(sizeof(HidControllerHeader) == 0x28, "Hid controller header structure has incorrect size");
|
||||||
|
|
||||||
|
/// Info struct extracted from HidControllerHeader.
|
||||||
|
/// Color fields are zero when not set. This can happen even when the *Set fields are set to true.
|
||||||
|
typedef struct HidControllerColors
|
||||||
|
{
|
||||||
|
bool singleSet; ///< Set to true when the below fields are valid.
|
||||||
|
u32 singleColorBody; ///< RGBA Single Body Color
|
||||||
|
u32 singleColorButtons; ///< RGBA Single Buttons Color
|
||||||
|
|
||||||
|
bool splitSet; ///< Set to true when the below fields are valid.
|
||||||
|
u32 leftColorBody; ///< RGBA Left Body Color
|
||||||
|
u32 leftColorButtons; ///< RGBA Left Buttons Color
|
||||||
|
u32 rightColorBody; ///< RGBA Right Body Color
|
||||||
|
u32 rightColorButtons; ///< RGBA Right Buttons Color
|
||||||
|
} HidControllerColors;
|
||||||
|
|
||||||
typedef struct HidControllerLayoutHeader
|
typedef struct HidControllerLayoutHeader
|
||||||
{
|
{
|
||||||
u64 timestampTicks;
|
u64 timestampTicks;
|
||||||
@ -607,6 +622,7 @@ void* hidGetSharedmemAddr(void);
|
|||||||
void hidSetControllerLayout(HidControllerID id, HidControllerLayoutType layoutType);
|
void hidSetControllerLayout(HidControllerID id, HidControllerLayoutType layoutType);
|
||||||
HidControllerLayoutType hidGetControllerLayout(HidControllerID id);
|
HidControllerLayoutType hidGetControllerLayout(HidControllerID id);
|
||||||
HidControllerType hidGetControllerType(HidControllerID id);
|
HidControllerType hidGetControllerType(HidControllerID id);
|
||||||
|
void hidGetControllerColors(HidControllerID id, HidControllerColors *colors);
|
||||||
|
|
||||||
void hidScanInput(void);
|
void hidScanInput(void);
|
||||||
|
|
||||||
|
@ -302,6 +302,38 @@ HidControllerType hidGetControllerType(HidControllerID id) {
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hidGetControllerColors(HidControllerID id, HidControllerColors *colors) {
|
||||||
|
if (id==CONTROLLER_P1_AUTO) {
|
||||||
|
hidGetControllerColors(g_controllerP1AutoID, colors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (id < 0 || id > 9) return;
|
||||||
|
if (colors == NULL) return;
|
||||||
|
|
||||||
|
HidControllerHeader *hdr = &g_controllerHeaders[id];
|
||||||
|
|
||||||
|
memset(colors, 0, sizeof(HidControllerColors));
|
||||||
|
|
||||||
|
rwlockReadLock(&g_hidLock);
|
||||||
|
|
||||||
|
colors->singleSet = (hdr->singleColorsDescriptor & BIT(1)) == 0;
|
||||||
|
colors->splitSet = (hdr->splitColorsDescriptor & BIT(1)) == 0;
|
||||||
|
|
||||||
|
if (colors->singleSet) {
|
||||||
|
colors->singleColorBody = hdr->singleColorBody;
|
||||||
|
colors->singleColorButtons = hdr->singleColorButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colors->splitSet) {
|
||||||
|
colors->leftColorBody = hdr->leftColorBody;
|
||||||
|
colors->leftColorButtons = hdr->leftColorButtons;
|
||||||
|
colors->rightColorBody = hdr->rightColorBody;
|
||||||
|
colors->rightColorButtons = hdr->rightColorButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
rwlockReadUnlock(&g_hidLock);
|
||||||
|
}
|
||||||
|
|
||||||
u64 hidKeysHeld(HidControllerID id) {
|
u64 hidKeysHeld(HidControllerID id) {
|
||||||
if (id==CONTROLLER_P1_AUTO) return hidKeysHeld(g_controllerP1AutoID);
|
if (id==CONTROLLER_P1_AUTO) return hidKeysHeld(g_controllerP1AutoID);
|
||||||
if (id < 0 || id > 9) return 0;
|
if (id < 0 || id > 9) return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user