mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-03 10:02:14 +02:00
hid: add functions for getting the state of the home, sleep and capture buttons from shmem
This commit is contained in:
parent
0fcf131cb2
commit
69b94f06b6
@ -1539,6 +1539,48 @@ NX_CONSTEXPR bool hidKeyboardStateGetKey(const HidKeyboardState *state, HidKeybo
|
|||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
|
///@name HomeButton
|
||||||
|
///@{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets \ref HidHomeButtonState.
|
||||||
|
* @note Home button shmem must be activated with \ref hidsysActivateHomeButton
|
||||||
|
* @param[out] states Output array of \ref HidHomeButtonState.
|
||||||
|
* @param[in] count Size of the states array in entries.
|
||||||
|
* @return Total output entries.
|
||||||
|
*/
|
||||||
|
size_t hidGetHomeButtonStates(HidHomeButtonState *states, size_t count);
|
||||||
|
|
||||||
|
///@}
|
||||||
|
|
||||||
|
///@name SleepButton
|
||||||
|
///@{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets \ref HidSleepButtonState.
|
||||||
|
* @note Sleep button shmem must be activated with \ref hidsysActivateSleepButton
|
||||||
|
* @param[out] states Output array of \ref HidSleepButtonState.
|
||||||
|
* @param[in] count Size of the states array in entries.
|
||||||
|
* @return Total output entries.
|
||||||
|
*/
|
||||||
|
size_t hidGetSleepButtonStates(HidSleepButtonState *states, size_t count);
|
||||||
|
|
||||||
|
///@}
|
||||||
|
|
||||||
|
///@name CaptureButton
|
||||||
|
///@{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets \ref HidCaptureButtonState.
|
||||||
|
* @note Capture button shmem must be activated with \ref hidsysActivateCaptureButton
|
||||||
|
* @param[out] states Output array of \ref HidCaptureButtonState.
|
||||||
|
* @param[in] count Size of the states array in entries.
|
||||||
|
* @return Total output entries.
|
||||||
|
*/
|
||||||
|
size_t hidGetCaptureButtonStates(HidCaptureButtonState *states, size_t count);
|
||||||
|
|
||||||
|
///@}
|
||||||
|
|
||||||
///@name Npad
|
///@name Npad
|
||||||
///@{
|
///@{
|
||||||
|
|
||||||
|
@ -275,6 +275,33 @@ size_t hidGetKeyboardStates(HidKeyboardState *states, size_t count) {
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t hidGetHomeButtonStates(HidHomeButtonState *states, size_t count) {
|
||||||
|
HidSharedMemory *sharedmem = (HidSharedMemory*)hidGetSharedmemAddr();
|
||||||
|
if (sharedmem == NULL)
|
||||||
|
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_NotInitialized));
|
||||||
|
|
||||||
|
size_t total = _hidGetStates(&sharedmem->home_button.lifo.header, sharedmem->home_button.lifo.storage, 17, offsetof(HidHomeButtonStateAtomicStorage,state), offsetof(HidHomeButtonState,sampling_number), states, sizeof(HidHomeButtonState), count);
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t hidGetSleepButtonStates(HidSleepButtonState *states, size_t count) {
|
||||||
|
HidSharedMemory *sharedmem = (HidSharedMemory*)hidGetSharedmemAddr();
|
||||||
|
if (sharedmem == NULL)
|
||||||
|
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_NotInitialized));
|
||||||
|
|
||||||
|
size_t total = _hidGetStates(&sharedmem->sleep_button.lifo.header, sharedmem->sleep_button.lifo.storage, 17, offsetof(HidSleepButtonStateAtomicStorage,state), offsetof(HidSleepButtonState,sampling_number), states, sizeof(HidSleepButtonState), count);
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t hidGetCaptureButtonStates(HidCaptureButtonState *states, size_t count) {
|
||||||
|
HidSharedMemory *sharedmem = (HidSharedMemory*)hidGetSharedmemAddr();
|
||||||
|
if (sharedmem == NULL)
|
||||||
|
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_NotInitialized));
|
||||||
|
|
||||||
|
size_t total = _hidGetStates(&sharedmem->capture_button.lifo.header, sharedmem->capture_button.lifo.storage, 17, offsetof(HidCaptureButtonStateAtomicStorage,state), offsetof(HidCaptureButtonState,sampling_number), states, sizeof(HidCaptureButtonState), count);
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
void hidInitializeNpad(void) {
|
void hidInitializeNpad(void) {
|
||||||
Result rc = _hidActivateNpad();
|
Result rc = _hidActivateNpad();
|
||||||
if (R_FAILED(rc)) diagAbortWithResult(rc);
|
if (R_FAILED(rc)) diagAbortWithResult(rc);
|
||||||
|
Loading…
Reference in New Issue
Block a user