mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
btdrv: Updated names for BtdrvHidReportEvent*.
This commit is contained in:
parent
2f6fcf7fb2
commit
348b21def2
@ -23,7 +23,7 @@ typedef struct {
|
|||||||
u8 pad; ///< Padding
|
u8 pad; ///< Padding
|
||||||
u16 size; ///< Size of the below data.
|
u16 size; ///< Size of the below data.
|
||||||
u8 data[]; ///< Data.
|
u8 data[]; ///< Data.
|
||||||
} type4; ///< ::BtdrvHidEventType_Unknown4
|
} data_report; ///< ::BtdrvHidEventType_Data
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
union {
|
union {
|
||||||
@ -35,7 +35,7 @@ typedef struct {
|
|||||||
u8 pad[2]; ///< Padding
|
u8 pad[2]; ///< Padding
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} type8; ///< ::BtdrvHidEventType_Unknown8
|
} set_report; ///< ::BtdrvHidEventType_SetReport
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
union {
|
union {
|
||||||
@ -45,7 +45,7 @@ typedef struct {
|
|||||||
struct {
|
struct {
|
||||||
BtdrvAddress addr; ///< \ref BtdrvAddress
|
BtdrvAddress addr; ///< \ref BtdrvAddress
|
||||||
u8 pad[2]; ///< Padding
|
u8 pad[2]; ///< Padding
|
||||||
u32 unk_x0; ///< Unknown. hid-sysmodule only uses the below data when this field is 0.
|
u32 res; ///< 0 = success, non-zero = error. hid-sysmodule only uses the below data when this field is 0.
|
||||||
BtdrvHidData data; ///< \ref BtdrvHidData
|
BtdrvHidData data; ///< \ref BtdrvHidData
|
||||||
u8 pad2[2]; ///< Padding
|
u8 pad2[2]; ///< Padding
|
||||||
};
|
};
|
||||||
@ -55,13 +55,13 @@ typedef struct {
|
|||||||
u8 rawdata[0x2C8]; ///< Raw data.
|
u8 rawdata[0x2C8]; ///< Raw data.
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u32 unk_x0; ///< Unknown. hid-sysmodule only uses the below report when this field is 0.
|
u32 res; ///< 0 = success, non-zero = error. hid-sysmodule only uses the below report when this field is 0.
|
||||||
BtdrvAddress addr; ///< \ref BtdrvAddress
|
BtdrvAddress addr; ///< \ref BtdrvAddress
|
||||||
BtdrvHidReport report; ///< \ref BtdrvHidReport
|
BtdrvHidReport report; ///< \ref BtdrvHidReport
|
||||||
};
|
};
|
||||||
} hid_report; ///< [9.0.0+]
|
} hid_report; ///< [9.0.0+]
|
||||||
};
|
};
|
||||||
} type9; ///< ::BtdrvHidEventType_Unknown9
|
} get_report; ///< ::BtdrvHidEventType_GetReport
|
||||||
};
|
};
|
||||||
} BtdrvHidReportEventInfo;
|
} BtdrvHidReportEventInfo;
|
||||||
|
|
||||||
@ -85,17 +85,18 @@ typedef struct {
|
|||||||
} v1; ///< Pre-9.0.0
|
} v1; ///< Pre-9.0.0
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u8 unused[0x5]; ///< Unused
|
u8 unused[0x4]; ///< Unused
|
||||||
|
u8 unused_x4; ///< Unused
|
||||||
BtdrvAddress addr; ///< \ref BtdrvAddress
|
BtdrvAddress addr; ///< \ref BtdrvAddress
|
||||||
u8 pad; ///< Padding
|
u8 pad; ///< Padding
|
||||||
u16 size; ///< Size of the below data.
|
u16 size; ///< Size of the below data.
|
||||||
u8 data[]; ///< Data.
|
u8 data[]; ///< Data.
|
||||||
} v9; ///< [9.0.0+]
|
} v9; ///< [9.0.0+]
|
||||||
} type4; ///< ::BtdrvHidEventType_Unknown4
|
} data_report; ///< ::BtdrvHidEventType_Data
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u8 data[0xC]; ///< Raw data.
|
u8 data[0xC]; ///< Raw data.
|
||||||
} type8; ///< ::BtdrvHidEventType_Unknown8
|
} set_report; ///< ::BtdrvHidEventType_SetReport
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
union {
|
union {
|
||||||
@ -107,7 +108,7 @@ typedef struct {
|
|||||||
u8 rawdata[0x2C8]; ///< Raw data.
|
u8 rawdata[0x2C8]; ///< Raw data.
|
||||||
} hid_report; ///< [9.0.0+]
|
} hid_report; ///< [9.0.0+]
|
||||||
};
|
};
|
||||||
} type9; ///< ::BtdrvHidEventType_Unknown9
|
} get_report; ///< ::BtdrvHidEventType_GetReport
|
||||||
} data;
|
} data;
|
||||||
} BtdrvHidReportEventInfoBufferData;
|
} BtdrvHidReportEventInfoBufferData;
|
||||||
|
|
||||||
@ -412,7 +413,7 @@ Result btdrvRegisterHidReportEvent(Event* out_event);
|
|||||||
* @brief GetHidReportEventInfo
|
* @brief GetHidReportEventInfo
|
||||||
* @note \ref btdrvRegisterHidReportEvent must be used before this, on [7.0.0+].
|
* @note \ref btdrvRegisterHidReportEvent must be used before this, on [7.0.0+].
|
||||||
* @note This is used by hid-sysmodule. When used by other processes, hid/user-process will conflict. No events will be received by that user-process, or it will be corrupted, etc.
|
* @note This is used by hid-sysmodule. When used by other processes, hid/user-process will conflict. No events will be received by that user-process, or it will be corrupted, etc.
|
||||||
* @note [7.0.0+] When data isn't available, the type is set to ::BtdrvHidEventType_Unknown4, with the buffer cleared to all-zero.
|
* @note [7.0.0+] When data isn't available, the type is set to ::BtdrvHidEventType_Data, with the buffer cleared to all-zero.
|
||||||
* @param[out] buffer Output buffer, see \ref BtdrvHidReportEventInfo.
|
* @param[out] buffer Output buffer, see \ref BtdrvHidReportEventInfo.
|
||||||
* @param[in] size Output buffer size.
|
* @param[in] size Output buffer size.
|
||||||
* @oaram[out] type \ref BtdrvHidEventType
|
* @oaram[out] type \ref BtdrvHidEventType
|
||||||
|
@ -29,10 +29,10 @@ typedef enum {
|
|||||||
/// HidEventType
|
/// HidEventType
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BtdrvHidEventType_Unknown0 = 0, ///< Unknown. Only used with \ref btdrvGetHidEventInfo.
|
BtdrvHidEventType_Unknown0 = 0, ///< Unknown. Only used with \ref btdrvGetHidEventInfo.
|
||||||
BtdrvHidEventType_Unknown4 = 4, ///< Unknown.
|
BtdrvHidEventType_Data = 4, ///< DATA report on the Interrupt channel.
|
||||||
BtdrvHidEventType_Unknown7 = 7, ///< Unknown. Only used with \ref btdrvGetHidEventInfo.
|
BtdrvHidEventType_Unknown7 = 7, ///< Unknown. Only used with \ref btdrvGetHidEventInfo.
|
||||||
BtdrvHidEventType_Unknown8 = 8, ///< Unknown.
|
BtdrvHidEventType_SetReport = 8, ///< Response to SET_REPORT.
|
||||||
BtdrvHidEventType_Unknown9 = 9, ///< Unknown.
|
BtdrvHidEventType_GetReport = 9, ///< Response to GET_REPORT.
|
||||||
} BtdrvHidEventType;
|
} BtdrvHidEventType;
|
||||||
|
|
||||||
/// This determines the u16 data to write into the CircularBuffer (name "BLE CORE").
|
/// This determines the u16 data to write into the CircularBuffer (name "BLE CORE").
|
||||||
|
@ -416,31 +416,31 @@ Result btdrvGetHidReportEventInfo(void* buffer, size_t size, BtdrvHidEventType *
|
|||||||
if (g_btdrvCircularBuffer==NULL) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
if (g_btdrvCircularBuffer==NULL) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
for (; (data_ptr = btdrvCircularBufferRead(g_btdrvCircularBuffer)); btdrvCircularBufferFree(g_btdrvCircularBuffer)) {
|
for (; (data_ptr = btdrvCircularBufferRead(g_btdrvCircularBuffer)); btdrvCircularBufferFree(g_btdrvCircularBuffer)) {
|
||||||
*type = data_ptr->hdr.type;
|
*type = data_ptr->hdr.type;
|
||||||
if (*type == BtdrvHidEventType_Unknown4) {
|
if (*type == BtdrvHidEventType_Data) {
|
||||||
if (armTicksToNs(armGetSystemTick() - data_ptr->hdr.tick) >= 100000001) continue;
|
if (armTicksToNs(armGetSystemTick() - data_ptr->hdr.tick) >= 100000001) continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (data_ptr == NULL) {
|
if (data_ptr == NULL) {
|
||||||
*type = BtdrvHidEventType_Unknown4;
|
*type = BtdrvHidEventType_Data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*type == BtdrvHidEventType_Unknown9) {
|
if (*type == BtdrvHidEventType_GetReport) {
|
||||||
if (hosversionBefore(9,0,0)) memcpy(info->type9.hid_data.rawdata, data_ptr->data.type9.hid_data.rawdata, sizeof(info->type9.hid_data.rawdata));
|
if (hosversionBefore(9,0,0)) memcpy(info->get_report.hid_data.rawdata, data_ptr->data.get_report.hid_data.rawdata, sizeof(info->get_report.hid_data.rawdata));
|
||||||
else memcpy(info->type9.hid_report.rawdata, data_ptr->data.type9.hid_report.rawdata, sizeof(info->type9.hid_report.rawdata));
|
else memcpy(info->get_report.hid_report.rawdata, data_ptr->data.get_report.hid_report.rawdata, sizeof(info->get_report.hid_report.rawdata));
|
||||||
}
|
}
|
||||||
else if (*type == BtdrvHidEventType_Unknown8) memcpy(info->type8.data, data_ptr->data.type8.data, sizeof(info->type8.data));
|
else if (*type == BtdrvHidEventType_SetReport) memcpy(info->set_report.data, data_ptr->data.set_report.data, sizeof(info->set_report.data));
|
||||||
else if (*type == BtdrvHidEventType_Unknown4) {
|
else if (*type == BtdrvHidEventType_Data) {
|
||||||
u16 tmpsize = hosversionBefore(9,0,0) ? data_ptr->data.type4.v1.size : data_ptr->data.type4.v9.size;
|
u16 tmpsize = hosversionBefore(9,0,0) ? data_ptr->data.data_report.v1.size : data_ptr->data.data_report.v9.size;
|
||||||
if (size < 0xE) return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
if (size < 0xE) return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
if (tmpsize > size-0xE) tmpsize = size-0xE;
|
if (tmpsize > size-0xE) tmpsize = size-0xE;
|
||||||
info->type4.unk_x0 = 0;
|
info->data_report.unk_x0 = 0;
|
||||||
info->type4.size = tmpsize;
|
info->data_report.size = tmpsize;
|
||||||
if (hosversionBefore(9,0,0)) memcpy(info->type4.data, data_ptr->data.type4.v1.data, tmpsize);
|
if (hosversionBefore(9,0,0)) memcpy(info->data_report.data, data_ptr->data.data_report.v1.data, tmpsize);
|
||||||
else memcpy(info->type4.data, data_ptr->data.type4.v9.data, tmpsize);
|
else memcpy(info->data_report.data, data_ptr->data.data_report.v9.data, tmpsize);
|
||||||
|
|
||||||
if (hosversionBefore(9,0,0)) memcpy(&info->type4.addr, &data_ptr->data.type4.v1.addr, sizeof(BtdrvAddress));
|
if (hosversionBefore(9,0,0)) memcpy(&info->data_report.addr, &data_ptr->data.data_report.v1.addr, sizeof(BtdrvAddress));
|
||||||
else memcpy(&info->type4.addr, &data_ptr->data.type4.v9.addr, sizeof(BtdrvAddress));
|
else memcpy(&info->data_report.addr, &data_ptr->data.data_report.v9.addr, sizeof(BtdrvAddress));
|
||||||
}
|
}
|
||||||
else return MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen); // sdknso would Abort here.
|
else return MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen); // sdknso would Abort here.
|
||||||
btdrvCircularBufferFree(g_btdrvCircularBuffer);
|
btdrvCircularBufferFree(g_btdrvCircularBuffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user