From d813bef54bdc716d861e828ed5116bd4e6a9fa90 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 19 Jan 2021 20:02:01 -0500 Subject: [PATCH] btdrv: Added/updated structs/enums for events, etc. --- nx/include/switch/services/btdrv.h | 113 +++++++++++++---------- nx/include/switch/services/btdrv_types.h | 13 ++- nx/source/services/btdrv.c | 4 +- 3 files changed, 76 insertions(+), 54 deletions(-) diff --git a/nx/include/switch/services/btdrv.h b/nx/include/switch/services/btdrv.h index 57cb275c..f6d431d3 100644 --- a/nx/include/switch/services/btdrv.h +++ b/nx/include/switch/services/btdrv.h @@ -66,7 +66,7 @@ typedef struct { }; } BtdrvEventInfo; -/// Data for \ref btdrvGetHidReportEventInfo / \ref btdrvGetHidEventInfo. The data stored here depends on the \ref BtdrvHidEventType. +/// Data for \ref btdrvGetHidEventInfo. The data stored here depends on the \ref BtdrvHidEventType. typedef struct { union { u8 data[0x480]; ///< Raw data. @@ -77,6 +77,58 @@ typedef struct { u32 status; ///< Status: 0 = hid connection opened, 2 = hid connection closed, 8 = failed to open hid connection. } connection; ///< ::BtdrvHidEventType_Connection + struct { + u32 type; ///< \ref BtdrvExtEventType, controls which data is stored below. + + union { + struct { + u32 status; ///< 0 for success, non-zero for error. + BtdrvAddress addr; ///< Device address. + } set_tsi; ///< ::BtdrvExtEventType_SetTsi + + struct { + u32 status; ///< 0 for success, non-zero for error. + BtdrvAddress addr; ///< Device address. + } exit_tsi; ///< ::BtdrvExtEventType_ExitTsi + + struct { + u32 status; ///< 0 for success, non-zero for error. + BtdrvAddress addr; ///< Device address. + } set_burst_mode; ///< ::BtdrvExtEventType_SetBurstMode + + struct { + u32 status; ///< 0 for success, non-zero for error. + BtdrvAddress addr; ///< Device address. + } exit_burst_mode; ///< ::BtdrvExtEventType_ExitBurstMode + + struct { + u32 status; ///< 0 for success, non-zero for error. + BtdrvAddress addr; ///< Device address. + u8 pad[2]; ///< Padding + u8 flag; ///< Flag + } set_zero_retransmission; ///< ::BtdrvExtEventType_SetZeroRetransmission + + struct { + u32 status; ///< 0 for success, non-zero for error. + BtdrvAddress addr; ///< Unused + u8 pad[2]; ///< Padding + u32 count; ///< Count value. + } pending_connections; ///< ::BtdrvExtEventType_PendingConnections + + struct { + u32 status; ///< 0 for success, non-zero for error. + BtdrvAddress addr; ///< Device address. + } move_to_secondary_piconet; ///< ::BtdrvExtEventType_MoveToSecondaryPiconet + }; + } ext; ///< ::BtdrvHidEventType_Ext + }; +} BtdrvHidEventInfo; + +/// Data for \ref btdrvGetHidReportEventInfo. The data stored here depends on the \ref BtdrvHidEventType. +typedef struct { + union { + u8 data[0x480]; ///< Raw data. + struct { u32 unk_x0; ///< Always 0. u8 unk_x4; ///< Always 0. @@ -86,51 +138,6 @@ typedef struct { u8 data[]; ///< Data. } data_report; ///< ::BtdrvHidEventType_Data - struct { - u32 type; - - union { - struct { - u32 status; ///< 0 for success, non-zero for error. - BtdrvAddress addr; ///< Device address. - } type0; - - struct { - u32 status; ///< 0 for success, non-zero for error. - BtdrvAddress addr; ///< Device address. - } type1; - - struct { - u32 status; ///< 0 for success, non-zero for error. - BtdrvAddress addr; ///< Device address. - } type2; - - struct { - u32 status; ///< 0 for success, non-zero for error. - BtdrvAddress addr; ///< Device address. - } type3; - - struct { - u32 status; ///< 0 for success, non-zero for error. - BtdrvAddress addr; ///< Device address. - u8 pad[2]; ///< Padding - u8 flag; ///< Flag - } type4; - - struct { - u32 status; ///< 0 for success, non-zero for error. - BtdrvAddress addr; ///< Unused - u8 pad[2]; ///< Padding - u32 count; ///< Count value. - } pending_connections; ///< type5 - - struct { - u32 status; ///< 0 for success, non-zero for error. - BtdrvAddress addr; ///< Device address. - } type6; - }; - } type7; ///< ::BtdrvHidEventType_Unknown7 - struct { union { u8 data[0xC]; ///< Raw data. @@ -434,30 +441,33 @@ Result btdrvFinalizeHid(void); /** * @brief GetHidEventInfo * @note This is used by btm-sysmodule. - * @param[out] buffer Output buffer, see \ref BtdrvHidReportEventInfo. + * @param[out] buffer Output buffer, see \ref BtdrvHidEventInfo. * @param[in] size Output buffer size. - * @param[out] type \ref BtdrvHidEventType, always ::BtdrvHidEventType_Connection or ::BtdrvHidEventType_Unknown7. + * @param[out] type \ref BtdrvHidEventType, always ::BtdrvHidEventType_Connection or ::BtdrvHidEventType_Ext. */ Result btdrvGetHidEventInfo(void* buffer, size_t size, BtdrvHidEventType *type); /** * @brief SetTsi + * @note The response will be available via \ref btdrvGetHidEventInfo. * @note This is used by btm-sysmodule. * @param[in] addr \ref BtdrvAddress - * @param[in] unk Unknown + * @param[in] tsi Tsi: non-value-0xFF to Set, value 0xFF to Exit. */ -Result btdrvSetTsi(BtdrvAddress addr, u8 unk); +Result btdrvSetTsi(BtdrvAddress addr, u8 tsi); /** * @brief EnableBurstMode + * @note The response will be available via \ref btdrvGetHidEventInfo. * @note This is used by btm-sysmodule. * @param[in] addr \ref BtdrvAddress - * @param[in] flag Flag + * @param[in] flag Flag: true = Set, false = Exit. */ Result btdrvEnableBurstMode(BtdrvAddress addr, bool flag); /** * @brief SetZeroRetransmission + * @note The response will be available via \ref btdrvGetHidEventInfo. * @note This is used by btm-sysmodule. * @param[in] addr \ref BtdrvAddress * @param[in] report_ids Input buffer containing an array of u8s. @@ -1065,6 +1075,7 @@ Result btdrvSetBleScanParameter(u16 unk0, u16 unk1); /** * @brief MoveToSecondaryPiconet + * @note The response will be available via \ref btdrvGetHidEventInfo. * @note Only available on [10.0.0+]. * @param[in] addr \ref BtdrvAddress */ diff --git a/nx/include/switch/services/btdrv_types.h b/nx/include/switch/services/btdrv_types.h index 08fff5ad..4f10c54e 100644 --- a/nx/include/switch/services/btdrv_types.h +++ b/nx/include/switch/services/btdrv_types.h @@ -34,6 +34,17 @@ typedef enum { BtdrvConnectionEventType_Suspended = 2, ///< ACL Link is now Suspended. } BtdrvConnectionEventType; +/// ExtEventType +typedef enum { + BtdrvExtEventType_SetTsi = 0, ///< SetTsi (\ref btdrvSetTsi) + BtdrvExtEventType_ExitTsi = 1, ///< ExitTsi (\ref btdrvSetTsi) + BtdrvExtEventType_SetBurstMode = 2, ///< SetBurstMode (\ref btdrvEnableBurstMode) + BtdrvExtEventType_ExitBurstMode = 3, ///< ExitBurstMode (\ref btdrvEnableBurstMode) + BtdrvExtEventType_SetZeroRetransmission = 4, ///< \ref btdrvSetZeroRetransmission + BtdrvExtEventType_PendingConnections = 5, ///< \ref btdrvGetPendingConnections + BtdrvExtEventType_MoveToSecondaryPiconet = 6, ///< \ref btdrvMoveToSecondaryPiconet +} BtdrvExtEventType; + /// BluetoothHhReportType /// Bit0-1 directly control the HID bluetooth transaction report-type value. /// Bit2-3: these directly control the Parameter Reserved field for SetReport, for GetReport these control the Parameter Reserved and Size bits. @@ -48,7 +59,7 @@ typedef enum { typedef enum { BtdrvHidEventType_Connection = 0, ///< Connection. Only used with \ref btdrvGetHidEventInfo. BtdrvHidEventType_Data = 4, ///< DATA report on the Interrupt channel. - BtdrvHidEventType_Unknown7 = 7, ///< Unknown. Only used with \ref btdrvGetHidEventInfo. + BtdrvHidEventType_Ext = 7, ///< Response for extensions. Only used with \ref btdrvGetHidEventInfo. BtdrvHidEventType_SetReport = 8, ///< Response to SET_REPORT. BtdrvHidEventType_GetReport = 9, ///< Response to GET_REPORT. } BtdrvHidEventType; diff --git a/nx/source/services/btdrv.c b/nx/source/services/btdrv.c index 7e0f30b3..4f7639be 100644 --- a/nx/source/services/btdrv.c +++ b/nx/source/services/btdrv.c @@ -336,8 +336,8 @@ Result btdrvGetHidEventInfo(void* buffer, size_t size, BtdrvHidEventType *type) return rc; } -Result btdrvSetTsi(BtdrvAddress addr, u8 unk) { - return _btmCmdInAddrU8NoOut(addr, unk, 28); +Result btdrvSetTsi(BtdrvAddress addr, u8 tsi) { + return _btmCmdInAddrU8NoOut(addr, tsi, 28); } Result btdrvEnableBurstMode(BtdrvAddress addr, bool flag) {