diff --git a/nx/include/switch/services/btm.h b/nx/include/switch/services/btm.h index 6f8b7c51..b3d35145 100644 --- a/nx/include/switch/services/btm.h +++ b/nx/include/switch/services/btm.h @@ -96,11 +96,11 @@ Result btmLegacyGetDeviceInfo(BtmDeviceInfoList *out); /** * @brief GetDeviceInfo [13.0.0+] * @param[in] id Id - * @param[out] out \ref BtmDeviceInfo + * @param[out] out \ref BtmDeviceInfoV13 * @param[in] count Size of the out array in entries. * @param[out] total_out Total output entries. */ -Result btmGetDeviceInfo(u32 id, BtmDeviceInfo *out, size_t count, s32 *total_out); +Result btmGetDeviceInfo(u32 id, BtmDeviceInfoV13 *out, size_t count, s32 *total_out); /** * @brief AddDeviceInfo diff --git a/nx/include/switch/services/btm_types.h b/nx/include/switch/services/btm_types.h index 7a249299..46209a6c 100644 --- a/nx/include/switch/services/btm_types.h +++ b/nx/include/switch/services/btm_types.h @@ -190,7 +190,7 @@ typedef struct { BtmDeviceSlotMode devices[8]; ///< Array of \ref BtmDeviceSlotMode with the above count. } BtmDeviceSlotModeList; -/// DeviceInfo +/// DeviceInfo [1.0.0-12.1.0] typedef struct { BtdrvAddress addr; ///< \ref BtdrvAddress BtmClassOfDevice class_of_device; ///< ClassOfDevice @@ -203,13 +203,34 @@ typedef struct { BtmHidDeviceInfo hid_device_info; ///< \ref BtmHidDeviceInfo (Profile = Hid) } profile_info; u8 reserved2[0x1C]; ///< Reserved +} BtmDeviceInfoV1; + +/// DeviceInfo [13.0.0+] +typedef struct { + BtdrvAddress addr; ///< \ref BtdrvAddress + BtmClassOfDevice class_of_device; ///< ClassOfDevice + BtmLinkKey link_key; ///< LinkKey + u8 reserved[3]; ///< Reserved + u32 profile; ///< \ref BtmProfile + union { + u8 data[0x4]; ///< Empty (Profile = None) + BtmHidDeviceInfo hid_device_info; ///< \ref BtmHidDeviceInfo (Profile = Hid) + } profile_info; + u8 reserved2[0x1C]; ///< Reserved + char name[0xFC]; ///< Name +} BtmDeviceInfoV13; + +/// DeviceInfo [1.0.0-13.0.0] +typedef union { + BtmDeviceInfoV1 v1; + BtmDeviceInfoV13 v13; } BtmDeviceInfo; /// DeviceInfoList typedef struct { u8 device_count; ///< DeviceCount u8 reserved[3]; ///< Reserved - BtmDeviceInfo devices[10]; ///< Array of \ref BtmDeviceInfo with the above count. + BtmDeviceInfoV1 devices[10]; ///< Array of \ref BtmDeviceInfoV1 with the above count. } BtmDeviceInfoList; /// DeviceProperty diff --git a/nx/source/services/btm.c b/nx/source/services/btm.c index a1bd76d1..7094fd43 100644 --- a/nx/source/services/btm.c +++ b/nx/source/services/btm.c @@ -215,11 +215,11 @@ Result btmLegacyGetDeviceInfo(BtmDeviceInfoList *out) { return _btmCmdOutBufPtrFixed(out, sizeof(*out), 9); } -Result btmGetDeviceInfo(u32 id, BtmDeviceInfo *out, size_t count, s32 *total_out) { +Result btmGetDeviceInfo(u32 id, BtmDeviceInfoV13 *out, size_t count, s32 *total_out) { if (hosversionBefore(13,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - return _btmCmdInIdOutBufPtr(id, out, sizeof(BtmDeviceInfo)*count, total_out, 9); + return _btmCmdInIdOutBufPtr(id, out, sizeof(BtmDeviceInfoV13)*count, total_out, 9); } Result btmAddDeviceInfo(const BtmDeviceInfo *info) {