mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-23 21:32:39 +02:00
Added hidsysGetUniquePadsFromNpad and hidsysGetUniquePadIds.
This commit is contained in:
parent
d6ba6d9625
commit
d4789c37c9
@ -1,11 +1,12 @@
|
||||
/**
|
||||
* @file hidsys.h
|
||||
* @brief hid:sys service IPC wrapper.
|
||||
* @author exelix
|
||||
* @author exelix, yellows8
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../kernel/event.h"
|
||||
#include "../services/hid.h"
|
||||
#include "../services/sm.h"
|
||||
|
||||
Result hidsysInitialize(void);
|
||||
@ -21,3 +22,22 @@ Result hidsysAcquireHomeButtonEventHandle(Event* event_out);
|
||||
Result hidsysActivateHomeButton(void);
|
||||
Result hidsysActivateSleepButton(void);
|
||||
Result hidsysActivateCaptureButton(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the UniquePadIds for the specified controller.
|
||||
* @note Only available on [3.0.0+].
|
||||
* @param id Controller ID. Must not be CONTROLLER_P1_AUTO.
|
||||
* @param UniquePadIds Output array of UniquePadIds.
|
||||
* @param Max number of entries for the UniquePadIds array.
|
||||
* @param total_entries Total output array entries. Optional, can be NULL.
|
||||
*/
|
||||
Result hidsysGetUniquePadsFromNpad(HidControllerID id, u64 *UniquePadIds, size_t count, size_t *total_entries);
|
||||
|
||||
/**
|
||||
* @brief Gets a list of all UniquePadIds.
|
||||
* @param UniquePadIds Output array of UniquePadIds.
|
||||
* @param Max number of entries for the UniquePadIds array.
|
||||
* @param total_entries Total output array entries. Optional, can be NULL.
|
||||
*/
|
||||
Result hidsysGetUniquePadIds(u64 *UniquePadIds, size_t count, size_t *total_entries);
|
||||
|
||||
|
@ -6,7 +6,9 @@
|
||||
#include "kernel/event.h"
|
||||
#include "services/applet.h"
|
||||
#include "services/hidsys.h"
|
||||
#include "services/hid.h"
|
||||
#include "services/sm.h"
|
||||
#include "runtime/hosversion.h"
|
||||
|
||||
static Service g_hidsysSrv;
|
||||
static u64 g_hidsysRefCnt;
|
||||
@ -179,3 +181,83 @@ Result hidsysActivateSleepButton(void) {
|
||||
Result hidsysActivateCaptureButton(void) {
|
||||
return _hidsysCmdWithResIdAndPid(151);
|
||||
}
|
||||
|
||||
Result hidsysGetUniquePadsFromNpad(HidControllerID id, u64 *UniquePadIds, size_t count, size_t *total_entries) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
Result rc;
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 id;
|
||||
} PACKED *raw;
|
||||
|
||||
ipcAddRecvStatic(&c, UniquePadIds, sizeof(u64)*count, 0);
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_hidsysSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 321;
|
||||
raw->id = hidControllerIDToOfficial(id);
|
||||
|
||||
rc = serviceIpcDispatch(&g_hidsysSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 total_entries;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_hidsysSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
if (R_SUCCEEDED(rc) && total_entries) *total_entries = resp->total_entries;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result hidsysGetUniquePadIds(u64 *UniquePadIds, size_t count, size_t *total_entries) {
|
||||
Result rc;
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
ipcAddRecvStatic(&c, UniquePadIds, sizeof(u64)*count, 0);
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_hidsysSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 703;
|
||||
|
||||
rc = serviceIpcDispatch(&g_hidsysSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 total_entries;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_hidsysSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
if (R_SUCCEEDED(rc) && total_entries) *total_entries = resp->total_entries;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user