libnx  v4.6.0
Data Structures | Macros | Enumerations | Functions
ringcon.h File Reference

Wrapper for using the Ring-Con attached to a Joy-Con, with hidbus. More...

#include "../types.h"
#include "../services/hidbus.h"

Go to the source code of this file.

Data Structures

struct  RingConFwVersion
 Ring-Con firmware version. More...
 
struct  RingConManuCal
 Ring-Con manufacturer calibration. More...
 
struct  RingConUserCal
 Ring-Con user calibration. More...
 
struct  RingConPollingData
 Polling data extracted from HidbusJoyPollingReceivedData. More...
 
struct  RingCon
 Ring-Con state object. More...
 

Macros

#define RINGCON_CAL_MAGIC   -0x3502
 

Enumerations

enum  RingConDataValid {
  RingConDataValid_Ok = 0 ,
  RingConDataValid_CRC = 1 ,
  RingConDataValid_Cal = 2
}
 Whether the output data is valid. More...
 
enum  RingConErrorFlag {
  RingConErrorFlag_BadUserCalUpdate = 0 ,
  RingConErrorFlag_BadFlag = 4 ,
  RingConErrorFlag_BadUserCal = 5 ,
  RingConErrorFlag_BadManuCal = 6
}
 

Functions

Result ringconCreate (RingCon *c, HidNpadIdType id)
 Creates a RingCon object, and handles the various initialization for it. More...
 
void ringconClose (RingCon *c)
 Close a RingCon. More...
 
static u32 ringconGetErrorFlags (RingCon *c)
 Gets the error flags field. More...
 
static bool ringconGetErrorFlag (RingCon *c, RingConErrorFlag flag)
 Gets the value of an error flag, set by ringconSetErrorFlag. More...
 
static RingConFwVersion ringconGetFwVersion (RingCon *c)
 Gets the RingConFwVersion previously loaded by ringconCreate. More...
 
static void ringconGetId (RingCon *c, u64 *id_l, u64 *id_h)
 Gets the Id previously loaded by ringconCreate. More...
 
static s16 ringconGetUnkCal (RingCon *c)
 Gets the unk_cal previously loaded by ringconCreate with ringconReadUnkCal. More...
 
static s32 ringconGetTotalPushCount (RingCon *c)
 Gets the total-push-count previously loaded by ringconCreate. More...
 
static void ringconGetManuCal (RingCon *c, RingConManuCal *out)
 Gets the RingConManuCal previously loaded by ringconCreate. More...
 
static void ringconGetUserCal (RingCon *c, RingConUserCal *out)
 Gets the RingConUserCal previously loaded by ringconCreate. More...
 
Result ringconUpdateUserCal (RingCon *c, RingConUserCal cal)
 Updates the RingConUserCal. More...
 
Result ringconReadFwVersion (RingCon *c, RingConFwVersion *out)
 Reads the RingConFwVersion. More...
 
Result ringconReadId (RingCon *c, u64 *id_l, u64 *id_h)
 Reads the Id. More...
 
Result ringconGetPollingData (RingCon *c, RingConPollingData *out, s32 count, s32 *total_out)
 Gets the RingConPollingData. More...
 
Result ringconCmdx00020105 (RingCon *c, u32 *out)
 Uses cmd 0x00020105. More...
 
Result ringconReadManuCal (RingCon *c, RingConManuCal *out)
 Reads the RingConManuCal. More...
 
Result ringconReadUnkCal (RingCon *c, s16 *out)
 Gets the unknown value derived from the output of cmd 0x00020504 and ringconReadManuCal. More...
 
Result ringconReadUserCal (RingCon *c, RingConUserCal *out)
 Reads the RingConUserCal. More...
 
Result ringconReadRepCount (RingCon *c, s32 *out, RingConDataValid *data_valid)
 Reads the rep-count for Multitask Mode. More...
 
Result ringconReadTotalPushCount (RingCon *c, s32 *out, RingConDataValid *data_valid)
 Reads the total-push-count, for Multitask Mode. More...
 
Result ringconResetRepCount (RingCon *c)
 This resets the value returned by ringconReadRepCount to 0. More...
 
Result ringconWriteUserCal (RingCon *c, RingConUserCal cal)
 Writes the RingConUserCal. More...
 

Detailed Description

Wrapper for using the Ring-Con attached to a Joy-Con, with hidbus.

See also: https://switchbrew.org/wiki/Ring-Con

Author
yellows8

Enumeration Type Documentation

◆ RingConDataValid

Whether the output data is valid.

Enumerator
RingConDataValid_Ok 

Valid.

RingConDataValid_CRC 

Bad CRC.

RingConDataValid_Cal 

Only used with ringconReadUserCal. Calibration is needed via ringconUpdateUserCal.

◆ RingConErrorFlag

Enumerator
RingConErrorFlag_BadUserCalUpdate 

The output from ringconReadUserCal doesn't match the input used with ringconWriteUserCal, or the RingConDataValid is not RingConDataValid_Ok.

RingConErrorFlag_BadFlag 

The output flag from ringconCmdx00020105 when successful is invalid.

RingConErrorFlag_BadUserCal 

BadUserCal.

RingConErrorFlag_BadManuCal 

BadManuCal.

Function Documentation

◆ ringconClose()

void ringconClose ( RingCon c)

Close a RingCon.

Parameters
cRingCon

◆ ringconCmdx00020105()

Result ringconCmdx00020105 ( RingCon c,
u32 out 
)

Uses cmd 0x00020105.

Note
Used internally by ringconCreate.
Parameters
cRingCon
[out]outOutput value.

◆ ringconCreate()

Result ringconCreate ( RingCon c,
HidNpadIdType  id 
)

Creates a RingCon object, and handles the various initialization for it.

Parameters
cRingCon
[in]idHidNpadIdType. A Ring-Con must be attached to this controller.

◆ ringconGetErrorFlag()

static bool ringconGetErrorFlag ( RingCon c,
RingConErrorFlag  flag 
)
inlinestatic

Gets the value of an error flag, set by ringconSetErrorFlag.

Parameters
cRingCon
[in]flagRingConErrorFlag

◆ ringconGetErrorFlags()

static u32 ringconGetErrorFlags ( RingCon c)
inlinestatic

Gets the error flags field.

Parameters
cRingCon

◆ ringconGetFwVersion()

static RingConFwVersion ringconGetFwVersion ( RingCon c)
inlinestatic

Gets the RingConFwVersion previously loaded by ringconCreate.

Parameters
cRingCon
[out]outRingConFwVersion

◆ ringconGetId()

static void ringconGetId ( RingCon c,
u64 id_l,
u64 id_h 
)
inlinestatic

Gets the Id previously loaded by ringconCreate.

Parameters
cRingCon
[out]id_lId low.
[out]id_hId high.

◆ ringconGetManuCal()

static void ringconGetManuCal ( RingCon c,
RingConManuCal out 
)
inlinestatic

Gets the RingConManuCal previously loaded by ringconCreate.

Parameters
cRingCon
[out]outRingConManuCal

◆ ringconGetPollingData()

Result ringconGetPollingData ( RingCon c,
RingConPollingData out,
s32  count,
s32 total_out 
)

Gets the RingConPollingData.

Only returns entries which are new since the last time this was called (or if not previously called, all available entries up to count).

Parameters
cRingCon
[out]outOutput array of RingConPollingData. Entry order is newest -> oldest.
[in]countTotal size of the out array in entries, max value is 0x9.
[out]total_outTotal output entries.

◆ ringconGetTotalPushCount()

static s32 ringconGetTotalPushCount ( RingCon c)
inlinestatic

Gets the total-push-count previously loaded by ringconCreate.

Parameters
cRingCon
[out]outtotal_push_count

◆ ringconGetUnkCal()

static s16 ringconGetUnkCal ( RingCon c)
inlinestatic

Gets the unk_cal previously loaded by ringconCreate with ringconReadUnkCal.

Only valid when the output flag from ringconCmdx00020105 is valid.

Parameters
cRingCon

◆ ringconGetUserCal()

static void ringconGetUserCal ( RingCon c,
RingConUserCal out 
)
inlinestatic

Gets the RingConUserCal previously loaded by ringconCreate.

Note
The Ring-Con UserCal doesn't seem to be calibrated normally?
Parameters
cRingCon
[out]outRingConUserCal

◆ ringconReadFwVersion()

Result ringconReadFwVersion ( RingCon c,
RingConFwVersion out 
)

Reads the RingConFwVersion.

Note
This is used internally by ringconCreate. Normally you should use ringconGetFwVersion instead.
Parameters
cRingCon
[out]outRingConFwVersion

◆ ringconReadId()

Result ringconReadId ( RingCon c,
u64 id_l,
u64 id_h 
)

Reads the Id.

Note
This is used internally by ringconCreate. Normally you should use ringconGetId instead.
Parameters
cRingCon
[out]id_lId low.
[out]id_hId high.

◆ ringconReadManuCal()

Result ringconReadManuCal ( RingCon c,
RingConManuCal out 
)

Reads the RingConManuCal.

Note
Used internally by ringconCreate and ringconReadUnkCal.
Parameters
cRingCon
[out]outRingConManuCal

◆ ringconReadRepCount()

Result ringconReadRepCount ( RingCon c,
s32 out,
RingConDataValid data_valid 
)

Reads the rep-count for Multitask Mode.

Parameters
cRingCon
[out]outOutput value. Official sw using this clamps the output to range 0-500.
[out]data_validRingConDataValid

◆ ringconReadTotalPushCount()

Result ringconReadTotalPushCount ( RingCon c,
s32 out,
RingConDataValid data_valid 
)

Reads the total-push-count, for Multitask Mode.

Note
Used internally by ringconCreate. Normally ringconGetTotalPushCount should be used instead.
Parameters
cRingCon
[out]outOutput value.
[out]data_validRingConDataValid

◆ ringconReadUnkCal()

Result ringconReadUnkCal ( RingCon c,
s16 out 
)

Gets the unknown value derived from the output of cmd 0x00020504 and ringconReadManuCal.

Note
Used internally by ringconCreate.
Parameters
cRingCon
[out]outOutput value.

◆ ringconReadUserCal()

Result ringconReadUserCal ( RingCon c,
RingConUserCal out 
)

Reads the RingConUserCal.

Note
Used internally by ringconCreate and ringconUpdateUserCal.
Parameters
cRingCon
[out]outRingConUserCal

◆ ringconResetRepCount()

Result ringconResetRepCount ( RingCon c)

This resets the value returned by ringconReadRepCount to 0.

Parameters
cRingCon

◆ ringconUpdateUserCal()

Result ringconUpdateUserCal ( RingCon c,
RingConUserCal  cal 
)

Updates the RingConUserCal.

Note
The input RingConUserCal is used with ringconWriteUserCal, and the output from ringconReadUserCal is verified with the input RingConUserCal. This does not update the RingConUserCal returned by ringconGetUserCal.
The Ring-Con UserCal doesn't seem to be calibrated normally?
Parameters
cRingCon
[in]calRingConUserCal

◆ ringconWriteUserCal()

Result ringconWriteUserCal ( RingCon c,
RingConUserCal  cal 
)

Writes the RingConUserCal.

Note
Used internally by ringconUpdateUserCal.
Parameters
cRingCon
[in]calRingConUserCal