Files
0417_QT_code/DRI/Dri_Consumer.cpp

53 lines
1.3 KiB
C++
Raw Permalink Normal View History

2026-04-17 16:25:19 +08:00
#include "DRI/Dri_Consumer.h"
2026-03-26 10:45:29 +08:00
2026-04-17 16:25:19 +08:00
void Dri_Consumer_Close(Dri_Consumer_Struct_Port* p_Port)
2026-03-26 10:45:29 +08:00
{
2026-04-17 16:25:19 +08:00
Dri_Hid_CloseReadPort(&p_Port->ReadPort);
2026-03-26 10:45:29 +08:00
}
2026-04-17 16:25:19 +08:00
bool Dri_Consumer_Init(
2026-03-26 10:45:29 +08:00
Dri_Consumer_Struct_Port* p_Port,
const Mid_Struct_DeviceConfig& DeviceConfig,
QString* p_TextStatus)
{
2026-04-17 16:25:19 +08:00
Dri_Consumer_Close(p_Port);
Mid_Struct_DeviceMatch Match;
Match.VendorId = DeviceConfig.VendorId;
Match.ProductId = DeviceConfig.ProductId;
Match.UsagePage = MID_CONST_USAGE_PAGE_CONSUMER;
Match.Usage = MID_CONST_USAGE_CONSUMER;
2026-03-26 10:45:29 +08:00
QString DevicePath;
quint16 InputLength = 0;
2026-04-17 16:25:19 +08:00
if (!Mid_FindHidInterface(
Match,
2026-03-26 10:45:29 +08:00
&DevicePath,
&InputLength,
nullptr))
{
if (p_TextStatus != nullptr)
{
2026-04-17 16:25:19 +08:00
*p_TextStatus = QStringLiteral("Consumer interface was not found: 000C / 0001.");
2026-03-26 10:45:29 +08:00
}
return false;
}
2026-04-17 16:25:19 +08:00
return Dri_Hid_InitReadPort(
&p_Port->ReadPort,
DevicePath,
InputLength,
Mid_Enum_RawPacketSource_UsbConsumerHid,
QStringLiteral("Consumer"),
p_TextStatus);
2026-03-26 10:45:29 +08:00
}
2026-04-17 16:25:19 +08:00
bool Dri_Consumer_Read(
2026-03-26 10:45:29 +08:00
Dri_Consumer_Struct_Port* p_Port,
Mid_Struct_RawPacket* p_Packet,
QString* p_TextStatus)
{
2026-04-17 16:25:19 +08:00
return Dri_Hid_Read(&p_Port->ReadPort, p_Packet, p_TextStatus);
2026-03-26 10:45:29 +08:00
}
2026-04-17 16:25:19 +08:00