Files
0417_QT_code/DRI/Dri_Vendor.h
2026-03-26 10:45:29 +08:00

43 lines
1.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "MID/Mid_Def.h"
#include <QtCore/QByteArray>
#include <QtCore/QString>
#include <Windows.h>
/*
* DRI Vendor 层:读写固件的 Vendor/NKRO HID 接口,支撑逻辑层功能诊断。
*
*/
struct Dri_Vendor_Struct_Port
{
/* 读写句柄Vendor 写、NKRO 写与通用读各占一个 */
HANDLE HandleRead = INVALID_HANDLE_VALUE;
HANDLE HandleWriteVendor = INVALID_HANDLE_VALUE;
HANDLE HandleWriteNkro = INVALID_HANDLE_VALUE;
HANDLE HandleEvent = nullptr;
OVERLAPPED OverlappedRead = {};
/* 运行状态 + 报文长度缓存,便于 UI/LOGIC 层快速判断 */
bool IsOpened = false;
bool IsReadPending = false;
quint16 InputLength = 0;
quint16 OutputLength = 0;
quint16 NkroWriteOutputLength = 0;
QByteArray ReadBuffer;
};
/* 关闭全部句柄,安全退出时务必调用以便复用设备。 */
void Dri_Vendor_Func_Close(Dri_Vendor_Struct_Port* p_Port);
/* 根据 VID/PID 打开对应 HID 接口,并创建必需句柄。 */
bool Dri_Vendor_Func_Open(Dri_Vendor_Struct_Port* p_Port,
const Mid_Struct_DeviceConfig& DeviceConfig,
QString* p_TextStatus);
/* 读取 Vendor 报文:一次返回一个 Mid_Struct_RawPacket。 */
bool Dri_Vendor_Func_Read(Dri_Vendor_Struct_Port* p_Port,
Mid_Struct_RawPacket* p_Packet,
QString* p_TextStatus);
/* 写入 Vendor/NKRO 报文ByteArray 按固件定义组包。 */
bool Dri_Vendor_Func_Write(Dri_Vendor_Struct_Port* p_Port,
const QByteArray& ByteArray,
QString* p_TextStatus);