2026-03-26 10:45:29 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-04-17 16:25:19 +08:00
|
|
|
#include "COM/Com_Def.h"
|
|
|
|
|
#include "DRI/Dri_Cdc.h"
|
|
|
|
|
#include "DRI/Dri_Nus.h"
|
2026-03-26 10:45:29 +08:00
|
|
|
#include "LOGIC/Lgc_Func_Button.h"
|
|
|
|
|
#include <QtCore/QByteArray>
|
2026-04-17 16:25:19 +08:00
|
|
|
#include <QtCore/QSet>
|
|
|
|
|
#include <QtCore/QString>
|
|
|
|
|
#include <QtCore/QStringList>
|
|
|
|
|
#include <QtCore/QVector>
|
2026-03-26 10:45:29 +08:00
|
|
|
|
|
|
|
|
struct Lgc_Core_Struct_State
|
|
|
|
|
{
|
2026-04-17 16:25:19 +08:00
|
|
|
Dri_Nus_Struct_Port DriNusPort;
|
|
|
|
|
Dri_Cdc_Struct_Port DriCdcPort;
|
|
|
|
|
|
|
|
|
|
Com_Struct_DeviceConfig DeviceConfig;
|
2026-03-26 10:45:29 +08:00
|
|
|
QString TextFunctionStatus;
|
|
|
|
|
|
|
|
|
|
bool IsVisibleKeyStateValid = false;
|
|
|
|
|
QVector<quint16> VisibleUsageList;
|
|
|
|
|
|
|
|
|
|
bool IsPhysicalKeyStateValid = false;
|
|
|
|
|
QVector<quint16> PhysicalUsageList;
|
|
|
|
|
QVector<quint16> LastPhysicalUsageList;
|
|
|
|
|
|
|
|
|
|
bool IsSystemNumLockOn = false;
|
|
|
|
|
QByteArray FunctionMaskBitmap;
|
|
|
|
|
QByteArray KeyboardMaskBitmap;
|
|
|
|
|
|
2026-04-17 16:25:19 +08:00
|
|
|
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;
|
2026-03-26 10:45:29 +08:00
|
|
|
|
|
|
|
|
void* WindowHandle = nullptr;
|
|
|
|
|
bool IsConnected = false;
|
|
|
|
|
bool IsStarted = false;
|
2026-04-17 16:25:19 +08:00
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
2026-03-26 10:45:29 +08:00
|
|
|
};
|
|
|
|
|
|
2026-04-17 16:25:19 +08:00
|
|
|
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,
|
|
|
|
|
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(
|
2026-03-26 10:45:29 +08:00
|
|
|
Lgc_Core_Struct_State* p_State,
|
2026-04-17 16:25:19 +08:00
|
|
|
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);
|