Push layered Qt host source files
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "DRI/Dri_NkroRaw.h"
|
||||
#include "DRI/Dri_NkroRaw.h"
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <Windows.h>
|
||||
@@ -6,9 +6,9 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
/* ---------- 设备过滤与 Usage 映射 ---------- */
|
||||
// Device filter and scancode-to-usage mapping.
|
||||
|
||||
QString Dri_NkroRaw_Func_GetDevicePath(HANDLE DeviceHandle)
|
||||
QString Dri_NkroRaw_GetDevicePath(HANDLE DeviceHandle)
|
||||
{
|
||||
if (DeviceHandle == nullptr)
|
||||
{
|
||||
@@ -31,7 +31,7 @@ QString Dri_NkroRaw_Func_GetDevicePath(HANDLE DeviceHandle)
|
||||
return QString::fromWCharArray(Buffer.constData()).trimmed();
|
||||
}
|
||||
|
||||
bool Dri_NkroRaw_Func_IsTargetDevice(const QString& DevicePath, const Mid_Struct_DeviceConfig& DeviceConfig)
|
||||
bool Dri_NkroRaw_IsTargetDevice(const QString& DevicePath, const Mid_Struct_DeviceConfig& DeviceConfig)
|
||||
{
|
||||
if (DevicePath.isEmpty())
|
||||
{
|
||||
@@ -43,7 +43,7 @@ bool Dri_NkroRaw_Func_IsTargetDevice(const QString& DevicePath, const Mid_Struct
|
||||
UpperPath.contains(QStringLiteral("PID_%1").arg(DeviceConfig.ProductId, 4, 16, QLatin1Char('0')).toUpper());
|
||||
}
|
||||
|
||||
quint16 Dri_NkroRaw_Func_GetUsage(const RAWKEYBOARD& Keyboard)
|
||||
quint16 Dri_NkroRaw_GetUsage(const RAWKEYBOARD& Keyboard)
|
||||
{
|
||||
const bool IsE0 = (Keyboard.Flags & RI_KEY_E0) != 0;
|
||||
const bool IsE1 = (Keyboard.Flags & RI_KEY_E1) != 0;
|
||||
@@ -97,20 +97,18 @@ quint16 Dri_NkroRaw_Func_GetUsage(const RAWKEYBOARD& Keyboard)
|
||||
|
||||
} // namespace
|
||||
|
||||
/* ---------- 生命周期 ---------- */
|
||||
|
||||
void Dri_NkroRaw_Func_Close(Dri_NkroRaw_Struct_Port* p_Port)
|
||||
void Dri_NkroRaw_Close(Dri_NkroRaw_Struct_Port* p_Port)
|
||||
{
|
||||
*p_Port = Dri_NkroRaw_Struct_Port();
|
||||
}
|
||||
|
||||
bool Dri_NkroRaw_Func_Open(
|
||||
bool Dri_NkroRaw_Init(
|
||||
Dri_NkroRaw_Struct_Port* p_Port,
|
||||
const Mid_Struct_DeviceConfig& DeviceConfig,
|
||||
void* WindowHandle,
|
||||
QString* p_TextStatus)
|
||||
{
|
||||
Dri_NkroRaw_Func_Close(p_Port);
|
||||
Dri_NkroRaw_Close(p_Port);
|
||||
|
||||
if (WindowHandle == nullptr)
|
||||
{
|
||||
@@ -147,9 +145,7 @@ bool Dri_NkroRaw_Func_Open(
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ---------- RawInput 主流程 ---------- */
|
||||
|
||||
bool Dri_NkroRaw_Func_HandleNativeMessage(
|
||||
bool Dri_NkroRaw_HandleMessage(
|
||||
Dri_NkroRaw_Struct_Port* p_Port,
|
||||
void* p_Message,
|
||||
QString* p_TextStatus)
|
||||
@@ -189,13 +185,13 @@ bool Dri_NkroRaw_Func_HandleNativeMessage(
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString DevicePath = Dri_NkroRaw_Func_GetDevicePath(p_Input->header.hDevice);
|
||||
if (!Dri_NkroRaw_Func_IsTargetDevice(DevicePath, p_Port->DeviceConfig))
|
||||
const QString DevicePath = Dri_NkroRaw_GetDevicePath(p_Input->header.hDevice);
|
||||
if (!Dri_NkroRaw_IsTargetDevice(DevicePath, p_Port->DeviceConfig))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const quint16 Usage = Dri_NkroRaw_Func_GetUsage(p_Input->data.keyboard);
|
||||
const quint16 Usage = Dri_NkroRaw_GetUsage(p_Input->data.keyboard);
|
||||
if (Usage == 0)
|
||||
{
|
||||
return false;
|
||||
@@ -249,6 +245,7 @@ bool Dri_NkroRaw_Func_HandleNativeMessage(
|
||||
|
||||
Mid_Struct_RawPacket Packet;
|
||||
Packet.IsValid = true;
|
||||
Packet.Source = Mid_Enum_RawPacketSource_UsbNkroRaw;
|
||||
Packet.PortName = QStringLiteral("NKRO(原生输入)");
|
||||
Packet.ByteArray = QByteArray(MID_CONST_PACKET_SIZE_NKRO, 0);
|
||||
Packet.ByteArray[0] = static_cast<char>(Mid_Enum_ReportId_Nkro);
|
||||
@@ -263,12 +260,13 @@ bool Dri_NkroRaw_Func_HandleNativeMessage(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Dri_NkroRaw_Func_Read(
|
||||
bool Dri_NkroRaw_Read(
|
||||
Dri_NkroRaw_Struct_Port* p_Port,
|
||||
Mid_Struct_RawPacket* p_Packet,
|
||||
QString*)
|
||||
{
|
||||
p_Packet->IsValid = false;
|
||||
p_Packet->Source = Mid_Enum_RawPacketSource_UsbNkroRaw;
|
||||
p_Packet->ByteArray.clear();
|
||||
p_Packet->PortName = QStringLiteral("NKRO(原生输入)");
|
||||
|
||||
@@ -280,3 +278,4 @@ bool Dri_NkroRaw_Func_Read(
|
||||
*p_Packet = p_Port->PacketQueue.takeFirst();
|
||||
return p_Packet->IsValid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user