Push layered Qt host source files
This commit is contained in:
248
LOGIC/Lgc_Core.h
248
LOGIC/Lgc_Core.h
@@ -1,85 +1,219 @@
|
||||
#pragma once
|
||||
|
||||
#include "DRI/Dri_Consumer.h"
|
||||
#include "DRI/Dri_NkroRaw.h"
|
||||
#include "DRI/Dri_Vendor.h"
|
||||
#include "LOGIC/Lgc_Consumer.h"
|
||||
#include "COM/Com_Def.h"
|
||||
#include "DRI/Dri_Cdc.h"
|
||||
#include "DRI/Dri_Nus.h"
|
||||
#include "LOGIC/Lgc_Func_Button.h"
|
||||
#include "LOGIC/Lgc_Nkro.h"
|
||||
#include "LOGIC/Lgc_Vendor.h"
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVector>
|
||||
|
||||
/*
|
||||
* Lgc_Core:贯穿 UI / LOGIC / DRI 的单一状态容器。
|
||||
* 高密注释使得学生在不翻源码的情况下即可看懂所有成员职责。
|
||||
*/
|
||||
struct Lgc_Core_Struct_State
|
||||
{
|
||||
/* DRI 端口:分别承接 RAW NKRO / Consumer / Vendor 通道 */
|
||||
Dri_NkroRaw_Struct_Port DriNkroPort;
|
||||
Dri_Consumer_Struct_Port DriConsumerPort;
|
||||
Dri_Vendor_Struct_Port DriVendorPort;
|
||||
Dri_Nus_Struct_Port DriNusPort;
|
||||
Dri_Cdc_Struct_Port DriCdcPort;
|
||||
|
||||
/* 设备与 UI 文本状态 */
|
||||
Mid_Struct_DeviceConfig DeviceConfig;
|
||||
QString TextConnection;
|
||||
QString TextLog;
|
||||
Com_Struct_DeviceConfig DeviceConfig;
|
||||
QString TextFunctionStatus;
|
||||
|
||||
/* 可视化按键:UI 模型(来自解析 NKRO/Consumer 结果) */
|
||||
bool IsVisibleKeyStateValid = false;
|
||||
quint8 VisibleModifier = 0;
|
||||
QVector<quint16> VisibleUsageList;
|
||||
|
||||
/* 物理按键:直接来自硬件,供 Swap/功能逻辑判断 */
|
||||
bool IsPhysicalKeyStateValid = false;
|
||||
quint8 PhysicalModifier = 0;
|
||||
QVector<quint16> PhysicalUsageList;
|
||||
QVector<quint16> LastPhysicalUsageList;
|
||||
|
||||
/* 键盘模式控制:NumLock、功能掩码、Swap 掩码等 */
|
||||
bool IsSystemNumLockOn = false;
|
||||
QByteArray FunctionMaskBitmap;
|
||||
QByteArray SwapMaskBitmap;
|
||||
QByteArray KeyboardMaskBitmap;
|
||||
|
||||
/* 功能键配置及 Swap 对应的运行期状态 */
|
||||
Lgc_Func_Button_Struct_Config FunctionButtonConfig;
|
||||
bool IsSwapModeOn = false;
|
||||
quint16 SwapUsageLeft = 0;
|
||||
quint16 SwapUsageRight = 0;
|
||||
bool IsSwapLeftPhysicalPressed = false;
|
||||
bool IsSwapRightPhysicalPressed = false;
|
||||
bool IsUsbProtocolReady = false;
|
||||
bool IsNusProtocolReady = false;
|
||||
bool IsUsbHelloSent = false;
|
||||
bool IsNusHelloSent = false;
|
||||
qint64 LastUsbHelloAttemptMs = 0;
|
||||
qint64 LastNusHelloAttemptMs = 0;
|
||||
qint64 NusReadySinceMs = 0;
|
||||
int NusHelloRetryCount = 0;
|
||||
bool WasNusConnectedLastPoll = false;
|
||||
bool HasLoggedNusWriteAck = false;
|
||||
bool HasLoggedNusHelloTimeout = false;
|
||||
qint64 LastCdcRefreshAttemptMs = 0;
|
||||
qint64 LastNusRefreshAttemptMs = 0;
|
||||
Com_Struct_ProtocolHelloRsp HelloResponse;
|
||||
quint32 DeviceLedMask = 0;
|
||||
quint32 LastAckedType = 0;
|
||||
quint32 LastErrorType = 0;
|
||||
quint32 LastErrorCode = 0;
|
||||
quint64 PendingUsbCommandBits = 0;
|
||||
qint64 PendingUsbCommandSinceMs = 0;
|
||||
quint64 PendingNusCommandBits = 0;
|
||||
qint64 PendingNusCommandSinceMs = 0;
|
||||
bool DeviceReady = false;
|
||||
bool BitmapSent = false;
|
||||
bool BitmapDirty = false;
|
||||
int BitmapRetryCount = 0;
|
||||
qint64 BitmapNextSendMs = 0;
|
||||
|
||||
Lgc_FunctionButton_Config FunctionButtonConfig;
|
||||
bool IsAltThemeEnabled = false;
|
||||
|
||||
/* 互操作:窗口句柄与核心运行状态 */
|
||||
void* WindowHandle = nullptr;
|
||||
bool IsConnected = false;
|
||||
bool IsStarted = false;
|
||||
bool IsFunctionSequenceRecording = false;
|
||||
QSet<quint16> UiPressedUsageSet;
|
||||
|
||||
int TestTxHelloReqCount = 0;
|
||||
int TestTxBitmapCount = 0;
|
||||
int TestTxTimeSyncCount = 0;
|
||||
int TestTxThemeRgbCount = 0;
|
||||
int TestRxHelloRspCount = 0;
|
||||
int TestRxFunctionKeyEventCount = 0;
|
||||
int TestRxLedStateCount = 0;
|
||||
int TestRxAckCount = 0;
|
||||
int TestRxErrorCount = 0;
|
||||
QString TestLastTxSummary;
|
||||
QString TestLastRxSummary;
|
||||
QByteArray TestLastTxBytes;
|
||||
QByteArray TestLastRxBytes;
|
||||
QByteArray TestLastFunctionEventBitmap;
|
||||
QStringList TestLogLines;
|
||||
QString LastLoggedNusEndpointSummary;
|
||||
};
|
||||
|
||||
/* 初始化核心:清空状态并准备 DRI 端口。 */
|
||||
void Lgc_Core_Func_Init(Lgc_Core_Struct_State* p_State);
|
||||
/* 告诉 LGC 使用哪个 HWND 接收 RAWINPUT。 */
|
||||
void Lgc_Core_Func_SetWindowHandle(Lgc_Core_Struct_State* p_State, void* WindowHandle);
|
||||
/* 每个 Windows 消息都交给核心处理。 */
|
||||
void Lgc_Core_Func_HandleNativeMessage(Lgc_Core_Struct_State* p_State, void* p_Message);
|
||||
/* 启动:打开设备、刷新按键状态并进入轮询。 */
|
||||
void Lgc_Core_Func_Start(Lgc_Core_Struct_State* p_State);
|
||||
/* 关闭:释放 DRI 端口与所有资源。 */
|
||||
void Lgc_Core_Func_Close(Lgc_Core_Struct_State* p_State);
|
||||
/* 当 VID/PID 变化或用户点击刷新时调用。 */
|
||||
void Lgc_Core_Func_RefreshDevice(Lgc_Core_Struct_State* p_State);
|
||||
/* 清空 LOG 文本,UI 立即同步。 */
|
||||
void Lgc_Core_Func_ClearLog(Lgc_Core_Struct_State* p_State);
|
||||
/* 轮询 DRI 队列,返回“是否发生变化”以供 UI 决定是否刷新。 */
|
||||
bool Lgc_Core_Func_Poll(Lgc_Core_Struct_State* p_State);
|
||||
/* 设置单个 Usage 是否是“功能模式” */
|
||||
bool Lgc_Core_Func_SetUsageFunctionMode(Lgc_Core_Struct_State* p_State, quint16 Usage, bool IsEnabled);
|
||||
/* 打开/关闭 Swap 模式,并指定左右 Usage */
|
||||
bool Lgc_Core_Func_SetSwapMode(
|
||||
struct Lgc_Core_Struct_View
|
||||
{
|
||||
QString TextFunctionStatus;
|
||||
bool IsConnected = false;
|
||||
bool HasOpenTransport = false;
|
||||
bool IsSystemNumLockOn = false;
|
||||
bool IsVisibleKeyStateValid = false;
|
||||
QVector<quint16> VisibleUsageList;
|
||||
bool IsPhysicalKeyStateValid = false;
|
||||
QVector<quint16> PhysicalUsageList;
|
||||
bool IsFunctionSequenceRecording = false;
|
||||
};
|
||||
|
||||
struct Lgc_Core_Struct_TestView
|
||||
{
|
||||
QString StatusText;
|
||||
QString UsbPortName;
|
||||
QString NusEndpointSummary;
|
||||
bool IsUsbOpened = false;
|
||||
bool IsNusOpened = false;
|
||||
bool IsNusConnected = false;
|
||||
bool IsUsbProtocolReady = false;
|
||||
bool IsNusProtocolReady = false;
|
||||
bool DeviceReady = false;
|
||||
quint32 HelloProtocolVersion = 0;
|
||||
quint32 HelloVendorId = 0;
|
||||
quint32 HelloProductId = 0;
|
||||
quint32 HelloFirmwareMajor = 0;
|
||||
quint32 HelloFirmwareMinor = 0;
|
||||
quint32 HelloCapabilityFlags = 0;
|
||||
quint32 DeviceLedMask = 0;
|
||||
quint32 LastAckedType = 0;
|
||||
quint32 LastErrorType = 0;
|
||||
quint32 LastErrorCode = 0;
|
||||
quint64 PendingUsbCommandBits = 0;
|
||||
quint64 PendingNusCommandBits = 0;
|
||||
QString LastTxSummary;
|
||||
QString LastRxSummary;
|
||||
QString LastTxHex;
|
||||
QString LastRxHex;
|
||||
QString FunctionMaskHex;
|
||||
QString LastFunctionEventHex;
|
||||
int TxHelloReqCount = 0;
|
||||
int TxBitmapCount = 0;
|
||||
int TxTimeSyncCount = 0;
|
||||
int TxThemeRgbCount = 0;
|
||||
int RxHelloRspCount = 0;
|
||||
int RxFunctionKeyEventCount = 0;
|
||||
int RxLedStateCount = 0;
|
||||
int RxAckCount = 0;
|
||||
int RxErrorCount = 0;
|
||||
QString LogText;
|
||||
};
|
||||
|
||||
void Lgc_Core_Init(Lgc_Core_Struct_State* p_State);
|
||||
void Lgc_Core_SetWindowHandle(Lgc_Core_Struct_State* p_State, void* WindowHandle);
|
||||
void Lgc_Core_HandleNativeMessage(Lgc_Core_Struct_State* p_State, void* p_Message);
|
||||
void Lgc_Core_Start(Lgc_Core_Struct_State* p_State);
|
||||
void Lgc_Core_Close(Lgc_Core_Struct_State* p_State);
|
||||
void Lgc_Core_RefreshDevice(Lgc_Core_Struct_State* p_State);
|
||||
bool Lgc_Core_Poll(Lgc_Core_Struct_State* p_State);
|
||||
|
||||
Lgc_Core_Struct_View Lgc_Core_GetView(const Lgc_Core_Struct_State* p_State);
|
||||
void Lgc_Core_SetStatusText(Lgc_Core_Struct_State* p_State, const QString& TextStatus);
|
||||
|
||||
QVector<int> Lgc_Core_GetFeatureIdList(const Lgc_Core_Struct_State* p_State);
|
||||
Lgc_FunctionFeature_Definition Lgc_Core_GetFeature(
|
||||
const Lgc_Core_Struct_State* p_State,
|
||||
int FeatureId);
|
||||
bool Lgc_Core_HasFeature(const Lgc_Core_Struct_State* p_State, int FeatureId);
|
||||
QString Lgc_Core_GetUsageShortText(quint16 Usage);
|
||||
QString Lgc_Core_GetFeatureTypeText(Lgc_FunctionFeature_Type Type);
|
||||
QString Lgc_Core_GetFeatureNameById(const Lgc_Core_Struct_State* p_State, int FeatureId);
|
||||
QString Lgc_Core_GetFeatureDescriptionById(
|
||||
const Lgc_Core_Struct_State* p_State,
|
||||
int FeatureId);
|
||||
QString Lgc_Core_GetFeatureBindingSummary(
|
||||
const Lgc_Core_Struct_State* p_State,
|
||||
int FeatureId);
|
||||
int Lgc_Core_GetUsageFeatureId(const Lgc_Core_Struct_State* p_State, quint16 Usage);
|
||||
bool Lgc_Core_HasUsageFeature(const Lgc_Core_Struct_State* p_State, quint16 Usage);
|
||||
|
||||
bool Lgc_Core_LoadFunctionConfig(Lgc_Core_Struct_State* p_State);
|
||||
bool Lgc_Core_SaveFunctionConfig(Lgc_Core_Struct_State* p_State);
|
||||
int Lgc_Core_AddFeature(Lgc_Core_Struct_State* p_State);
|
||||
bool Lgc_Core_UpdateFeature(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
quint16 UsageLeft,
|
||||
quint16 UsageRight,
|
||||
bool IsEnabled);
|
||||
/* 查询给定 Usage 当前是否处于功能模式 */
|
||||
bool Lgc_Core_Func_IsUsageFunctionMode(const Lgc_Core_Struct_State* p_State, quint16 Usage);
|
||||
const Lgc_FunctionFeature_Definition& Feature);
|
||||
bool Lgc_Core_DeleteFeature(Lgc_Core_Struct_State* p_State, int FeatureId);
|
||||
bool Lgc_Core_BindUsageToFeature(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
quint16 Usage,
|
||||
int FeatureId);
|
||||
|
||||
bool Lgc_Core_BeginSequenceRecording(Lgc_Core_Struct_State* p_State, int FeatureId);
|
||||
void Lgc_Core_EndSequenceRecording(Lgc_Core_Struct_State* p_State);
|
||||
void Lgc_Core_UpdateSequenceRecordingStatus(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
const QString& SequenceText);
|
||||
void Lgc_Core_HandleUiKeyPress(Lgc_Core_Struct_State* p_State, quint16 Usage);
|
||||
void Lgc_Core_HandleUiKeyRelease(Lgc_Core_Struct_State* p_State, quint16 Usage);
|
||||
|
||||
bool Lgc_Core_ApplyFunctionConfig(Lgc_Core_Struct_State* p_State);
|
||||
bool Lgc_Core_TestSendHello(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
Com_Enum_RawPacketSource TargetSource = Com_Enum_RawPacketSource_None);
|
||||
bool Lgc_Core_TestSendBitmapCurrentConfig(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
Com_Enum_RawPacketSource TargetSource = Com_Enum_RawPacketSource_None);
|
||||
bool Lgc_Core_TestSendBitmapAllEnabled(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
Com_Enum_RawPacketSource TargetSource = Com_Enum_RawPacketSource_None);
|
||||
bool Lgc_Core_TestSendBitmapAllDisabled(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
Com_Enum_RawPacketSource TargetSource = Com_Enum_RawPacketSource_None);
|
||||
bool Lgc_Core_TestSendTimeSync(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
Com_Enum_RawPacketSource TargetSource = Com_Enum_RawPacketSource_None);
|
||||
bool Lgc_Core_SendTimeSync(Lgc_Core_Struct_State* p_State);
|
||||
bool Lgc_Core_SendThemeRgb(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
quint8 Red,
|
||||
quint8 Green,
|
||||
quint8 Blue);
|
||||
bool Lgc_Core_TestSendThemeRgb(
|
||||
Lgc_Core_Struct_State* p_State,
|
||||
quint8 Red,
|
||||
quint8 Green,
|
||||
quint8 Blue,
|
||||
Com_Enum_RawPacketSource TargetSource = Com_Enum_RawPacketSource_None);
|
||||
bool Lgc_Core_SendThemeSwitch(Lgc_Core_Struct_State* p_State);
|
||||
void Lgc_Core_ClearTestLog(Lgc_Core_Struct_State* p_State);
|
||||
Lgc_Core_Struct_TestView Lgc_Core_GetTestView(const Lgc_Core_Struct_State* p_State);
|
||||
|
||||
Reference in New Issue
Block a user