9 #include "../services/hidbus.h"
11 #define RINGCON_CAL_MAGIC -0x3502
61 u64 polling_last_sampling_number;
92 return c->error_flags;
101 return (c->error_flags &
BIT(flag)) != 0;
138 return c->total_push_count;
HidNpadIdType
HID controller IDs.
Definition: hid.h:214
Result ringconCreate(RingCon *c, HidNpadIdType id)
Creates a RingCon object, and handles the various initialization for it.
static RingConFwVersion ringconGetFwVersion(RingCon *c)
Gets the RingConFwVersion previously loaded by ringconCreate.
Definition: ringcon.h:109
Result ringconReadUserCal(RingCon *c, RingConUserCal *out)
Reads the RingConUserCal.
static void ringconGetId(RingCon *c, u64 *id_l, u64 *id_h)
Gets the Id previously loaded by ringconCreate.
Definition: ringcon.h:119
Result ringconReadId(RingCon *c, u64 *id_l, u64 *id_h)
Reads the Id.
Result ringconWriteUserCal(RingCon *c, RingConUserCal cal)
Writes the RingConUserCal.
static s16 ringconGetUnkCal(RingCon *c)
Gets the unk_cal previously loaded by ringconCreate with ringconReadUnkCal.
Definition: ringcon.h:128
Result ringconUpdateUserCal(RingCon *c, RingConUserCal cal)
Updates the RingConUserCal.
RingConErrorFlag
Definition: ringcon.h:20
@ RingConErrorFlag_BadUserCal
BadUserCal.
Definition: ringcon.h:23
@ RingConErrorFlag_BadFlag
The output flag from ringconCmdx00020105 when successful is invalid.
Definition: ringcon.h:22
@ RingConErrorFlag_BadManuCal
BadManuCal.
Definition: ringcon.h:24
@ RingConErrorFlag_BadUserCalUpdate
The output from ringconReadUserCal doesn't match the input used with ringconWriteUserCal,...
Definition: ringcon.h:21
static bool ringconGetErrorFlag(RingCon *c, RingConErrorFlag flag)
Gets the value of an error flag, set by ringconSetErrorFlag.
Definition: ringcon.h:100
Result ringconResetRepCount(RingCon *c)
This resets the value returned by ringconReadRepCount to 0.
void ringconClose(RingCon *c)
Close a RingCon.
Result ringconCmdx00020105(RingCon *c, u32 *out)
Uses cmd 0x00020105.
static s32 ringconGetTotalPushCount(RingCon *c)
Gets the total-push-count previously loaded by ringconCreate.
Definition: ringcon.h:137
static u32 ringconGetErrorFlags(RingCon *c)
Gets the error flags field.
Definition: ringcon.h:91
Result ringconReadRepCount(RingCon *c, s32 *out, RingConDataValid *data_valid)
Reads the rep-count for Multitask Mode.
RingConDataValid
Whether the output data is valid.
Definition: ringcon.h:14
@ RingConDataValid_Ok
Valid.
Definition: ringcon.h:15
@ RingConDataValid_Cal
Only used with ringconReadUserCal. Calibration is needed via ringconUpdateUserCal.
Definition: ringcon.h:17
@ RingConDataValid_CRC
Bad CRC.
Definition: ringcon.h:16
static void ringconGetManuCal(RingCon *c, RingConManuCal *out)
Gets the RingConManuCal previously loaded by ringconCreate.
Definition: ringcon.h:146
Result ringconReadUnkCal(RingCon *c, s16 *out)
Gets the unknown value derived from the output of cmd 0x00020504 and ringconReadManuCal.
Result ringconGetPollingData(RingCon *c, RingConPollingData *out, s32 count, s32 *total_out)
Gets the RingConPollingData.
Result ringconReadFwVersion(RingCon *c, RingConFwVersion *out)
Reads the RingConFwVersion.
Result ringconReadManuCal(RingCon *c, RingConManuCal *out)
Reads the RingConManuCal.
static void ringconGetUserCal(RingCon *c, RingConUserCal *out)
Gets the RingConUserCal previously loaded by ringconCreate.
Definition: ringcon.h:156
Result ringconReadTotalPushCount(RingCon *c, s32 *out, RingConDataValid *data_valid)
Reads the total-push-count, for Multitask Mode.
BusHandle.
Definition: hidbus.h:28
Ring-Con firmware version.
Definition: ringcon.h:28
u8 fw_main_ver
Main firmware version.
Definition: ringcon.h:29
u8 fw_sub_ver
Sub firmware version.
Definition: ringcon.h:30
Ring-Con manufacturer calibration.
Definition: ringcon.h:34
s16 zero_min
(manu_)zero_min
Definition: ringcon.h:37
s16 zero_max
(manu_)zero_max
Definition: ringcon.h:38
s16 os_max
(manu_)os_max
Definition: ringcon.h:35
s16 hk_max
(manu_)hk_max
Definition: ringcon.h:36
Polling data extracted from HidbusJoyPollingReceivedData.
Definition: ringcon.h:50
s16 data
Sensor state data.
Definition: ringcon.h:51
u64 sampling_number
SamplingNumber.
Definition: ringcon.h:52
Ring-Con user calibration.
Definition: ringcon.h:42
s16 hk_max
(user_)hk_max
Definition: ringcon.h:44
s16 os_max
(user_)os_max
Definition: ringcon.h:43
s16 zero
(user_)zero
Definition: ringcon.h:45
RingConDataValid data_valid
RingConDataValid
Definition: ringcon.h:46
Ring-Con state object.
Definition: ringcon.h:56
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
int16_t s16
16-bit signed integer.
Definition: types.h:26
u32 Result
Function error code result type.
Definition: types.h:44
#define NX_CONSTEXPR
Flags a function as constexpr in C++14 and above; or as (always) inline otherwise.
Definition: types.h:92
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21