mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-23 05:12:39 +02:00
Added hidGetControllerConnected() and updated CONTROLLER_P1_AUTO comment.
This commit is contained in:
parent
a62e29d5cf
commit
0370140c12
@ -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()/hidSixAxisSensorValuesRead()/hidGetControllerType()/hidGetControllerColors(). 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()/hidGetControllerConnected(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD.
|
||||||
} HidControllerID;
|
} HidControllerID;
|
||||||
|
|
||||||
typedef struct touchPosition
|
typedef struct touchPosition
|
||||||
@ -623,6 +623,7 @@ void hidSetControllerLayout(HidControllerID id, HidControllerLayoutType layoutTy
|
|||||||
HidControllerLayoutType hidGetControllerLayout(HidControllerID id);
|
HidControllerLayoutType hidGetControllerLayout(HidControllerID id);
|
||||||
HidControllerType hidGetControllerType(HidControllerID id);
|
HidControllerType hidGetControllerType(HidControllerID id);
|
||||||
void hidGetControllerColors(HidControllerID id, HidControllerColors *colors);
|
void hidGetControllerColors(HidControllerID id, HidControllerColors *colors);
|
||||||
|
bool hidGetControllerConnected(HidControllerID id);
|
||||||
|
|
||||||
void hidScanInput(void);
|
void hidScanInput(void);
|
||||||
|
|
||||||
|
@ -334,6 +334,17 @@ void hidGetControllerColors(HidControllerID id, HidControllerColors *colors) {
|
|||||||
rwlockReadUnlock(&g_hidLock);
|
rwlockReadUnlock(&g_hidLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hidGetControllerConnected(HidControllerID id) {
|
||||||
|
if (id==CONTROLLER_P1_AUTO)
|
||||||
|
return hidGetControllerConnected(g_controllerP1AutoID);
|
||||||
|
if (id < 0 || id > 9) return 0;
|
||||||
|
|
||||||
|
rwlockReadLock(&g_hidLock);
|
||||||
|
bool flag = (g_controllerEntries[id].connectionState & CONTROLLER_STATE_CONNECTED) != 0;
|
||||||
|
rwlockReadUnlock(&g_hidLock);
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
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