libnx  v4.7.0
Data Structures | Enumerations | Functions
hidbus.h File Reference

hidbus service IPC wrapper, for using external devices attached to HID controllers. More...

#include "../types.h"
#include "../kernel/event.h"
#include "../services/hid.h"
#include "../sf/service.h"

Go to the source code of this file.

Data Structures

struct  HidbusBusHandle
 BusHandle. More...
 
struct  HidbusJoyPollingReceivedData
 JoyPollingReceivedData. More...
 
struct  HidbusDataAccessorHeader
 HidbusDataAccessorHeader. More...
 
struct  HidbusJoyDisableSixAxisPollingDataAccessorEntryData
 HidbusJoyDisableSixAxisPollingDataAccessorEntryData. More...
 
struct  HidbusJoyDisableSixAxisPollingDataAccessorEntry
 HidbusJoyDisableSixAxisPollingDataAccessorEntry. More...
 
struct  HidbusJoyEnableSixAxisPollingDataAccessorEntryData
 HidbusJoyEnableSixAxisPollingDataAccessorEntryData. More...
 
struct  HidbusJoyEnableSixAxisPollingDataAccessorEntry
 HidbusJoyEnableSixAxisPollingDataAccessorEntry. More...
 
struct  HidbusJoyButtonOnlyPollingDataAccessorEntryData
 HidbusJoyButtonOnlyPollingDataAccessorEntryData. More...
 
struct  HidbusJoyButtonOnlyPollingDataAccessorEntry
 HidbusJoyButtonOnlyPollingDataAccessorEntry. More...
 
struct  HidbusJoyDisableSixAxisPollingDataAccessor
 HidbusJoyDisableSixAxisPollingDataAccessor. More...
 
struct  HidbusJoyEnableSixAxisPollingDataAccessor
 HidbusJoyEnableSixAxisPollingDataAccessor. More...
 
struct  HidbusJoyButtonOnlyPollingDataAccessor
 HidbusJoyButtonOnlyPollingDataAccessor. More...
 
struct  HidbusStatusManagerEntryCommon
 Common data for HidbusStatusManagerEntry*. More...
 
struct  HidbusStatusManagerEntryV5
 HidbusStatusManagerEntry on 5.x. More...
 
struct  HidbusStatusManagerEntry
 HidbusStatusManagerEntry. More...
 
struct  HidbusStatusManagerV5
 StatusManager on 5.x. More...
 
struct  HidbusStatusManager
 StatusManager. More...
 

Enumerations

enum  HidbusBusType {
  HidbusBusType_LeftJoyRail = 0 ,
  HidbusBusType_RightJoyRail = 1 ,
  HidbusBusType_RightLarkRail = 2
}
 BusType. More...
 
enum  HidbusJoyPollingMode {
  HidbusJoyPollingMode_SixAxisSensorDisable = 0 ,
  HidbusJoyPollingMode_SixAxisSensorEnable = 1 ,
  HidbusJoyPollingMode_ButtonOnly = 2
}
 JoyPollingMode. More...
 

Functions

Result hidbusGetServiceSession (Service *srv_out)
 Gets the Service object for the actual hidbus service session. This object must be closed by the user once finished using cmds with this.
 
void * hidbusGetSharedmemAddr (void)
 Gets the SharedMemory addr (HidbusStatusManagerV5 on 5.x, otherwise HidbusStatusManager). Only valid when at least one BusHandle is currently initialized (hidbusInitialize).
 
Result hidbusGetBusHandle (HidbusBusHandle *handle, bool *flag, HidNpadIdType id, HidbusBusType bus_type)
 GetBusHandle. More...
 
Result hidbusInitialize (HidbusBusHandle handle)
 Initialize. More...
 
Result hidbusFinalize (HidbusBusHandle handle)
 Finalize. More...
 
Result hidbusEnableExternalDevice (HidbusBusHandle handle, bool flag, u32 device_id)
 EnableExternalDevice. More...
 
Result hidbusSendAndReceive (HidbusBusHandle handle, const void *inbuf, size_t inbuf_size, void *outbuf, size_t outbuf_size, u64 *out_size)
 SendAndReceive. More...
 
Result hidbusEnableJoyPollingReceiveMode (HidbusBusHandle handle, const void *inbuf, size_t inbuf_size, void *workbuf, size_t workbuf_size, HidbusJoyPollingMode polling_mode)
 EnableJoyPollingReceiveMode. More...
 
Result hidbusDisableJoyPollingReceiveMode (HidbusBusHandle handle)
 DisableJoyPollingReceiveMode. More...
 
Result hidbusGetJoyPollingReceivedData (HidbusBusHandle handle, HidbusJoyPollingReceivedData *recv_data, s32 count)
 GetJoyPollingReceivedData. More...
 

Detailed Description

hidbus service IPC wrapper, for using external devices attached to HID controllers.

See also: https://switchbrew.org/wiki/HID_services#hidbus

Note
Only available on [5.0.0+].
Author
yellows8

Enumeration Type Documentation

◆ HidbusBusType

BusType.

Enumerator
HidbusBusType_LeftJoyRail 

LeftJoyRail.

HidbusBusType_RightJoyRail 

RightJoyRail.

HidbusBusType_RightLarkRail 

[6.0.0+] RightLarkRail (for microphone).

◆ HidbusJoyPollingMode

JoyPollingMode.

Enumerator
HidbusJoyPollingMode_SixAxisSensorDisable 

SixAxisSensorDisable.

HidbusJoyPollingMode_SixAxisSensorEnable 

JoyEnableSixAxisPollingData.

HidbusJoyPollingMode_ButtonOnly 

[6.0.0+] ButtonOnly

Function Documentation

◆ hidbusDisableJoyPollingReceiveMode()

Result hidbusDisableJoyPollingReceiveMode ( HidbusBusHandle  handle)

DisableJoyPollingReceiveMode.

Note
This can also be used via hidbusEnableExternalDevice with flag=false.
Parameters
[in]handleHidbusBusHandle

◆ hidbusEnableExternalDevice()

Result hidbusEnableExternalDevice ( HidbusBusHandle  handle,
bool  flag,
u32  device_id 
)

EnableExternalDevice.

Note
This uses hidLaShowControllerFirmwareUpdate if needed.
Parameters
[in]handleHidbusBusHandle
[in]flagWhether to enable the device (true = enable, false = disable). When false, this will internally use hidbusDisableJoyPollingReceiveMode if needed.
[in]device_idExternalDeviceId which must match the connected device. Only used when flag is set.

◆ hidbusEnableJoyPollingReceiveMode()

Result hidbusEnableJoyPollingReceiveMode ( HidbusBusHandle  handle,
const void *  inbuf,
size_t  inbuf_size,
void *  workbuf,
size_t  workbuf_size,
HidbusJoyPollingMode  polling_mode 
)

EnableJoyPollingReceiveMode.

Parameters
[in]handleHidbusBusHandle
[in]inbufInput buffer, containing the command data.
[in]inbuf_sizeInput buffer size, must be <0x26.
[out]workbufTransferMemory buffer, must be 0x1000-byte aligned. This buffer must not be written to until after hidbusDisableJoyPollingReceiveMode is used.
[in]workbuf_sizeTransferMemory buffer size, must be 0x1000-byte aligned.
[in]polling_modeHidbusJoyPollingMode

◆ hidbusFinalize()

Result hidbusFinalize ( HidbusBusHandle  handle)

Finalize.

Parameters
[in]handleHidbusBusHandle

◆ hidbusGetBusHandle()

Result hidbusGetBusHandle ( HidbusBusHandle handle,
bool *  flag,
HidNpadIdType  id,
HidbusBusType  bus_type 
)

GetBusHandle.

Parameters
[out]handleHidbusBusHandle
[out]flagOutput flag indicating whether the handle is valid.
[in]idHidNpadIdType
[in]bus_typeHidbusBusType

◆ hidbusGetJoyPollingReceivedData()

Result hidbusGetJoyPollingReceivedData ( HidbusBusHandle  handle,
HidbusJoyPollingReceivedData recv_data,
s32  count 
)

GetJoyPollingReceivedData.

Parameters
[in]handleHidbusBusHandle
[out]recv_dataOutput array of HidbusJoyPollingReceivedData.
[in]countTotal entries for the recv_data array. The maximum is 0xa. Official apps use range 0x1-0x9.

◆ hidbusInitialize()

Result hidbusInitialize ( HidbusBusHandle  handle)

Initialize.

Parameters
[in]handleHidbusBusHandle

◆ hidbusSendAndReceive()

Result hidbusSendAndReceive ( HidbusBusHandle  handle,
const void *  inbuf,
size_t  inbuf_size,
void *  outbuf,
size_t  outbuf_size,
u64 out_size 
)

SendAndReceive.

Parameters
[in]handleHidbusBusHandle
[in]inbufInput buffer, containing the command data.
[in]inbuf_sizeInput buffer size, must be <0x26.
[out]outbufOutput buffer, containing the command reply data.
[in]outbuf_sizeOutput buffer max size.
[out]out_sizeActual output size.