MODULE UsbHidParserExt;
IMPORT SYSTEM, KernelLog, UsbHidUP;
CONST
ParseIDUsagePage* = 0;
ParseIDLogicalMinimum* = 1;
ParseIDLogicalMaximum * = 2;
ParseIDPhysicalMinimum* = 3;
ParseIDPhysicalMaximum* = 4;
ParseIDUnitExponent* = 5;
ParseIDUnit* = 6;
ParseIDReportSize* = 7;
ParseIDReportID* = 8;
ParseIDReportCount* = 9;
ParseIDPush* = 10;
ParseIDPop* = 11;
ParseIDUsage* = 0;
ParseIDUsageMinimum* = 1;
ParseIDUsageMaximum* = 2;
ParseIDDesignatorIndex* = 3;
ParseIDDesignatorMinimum* = 4;
ParseIDDesignatorMaximum* = 5;
ParseIDStringIndex* = 7;
ParseIDStringMinimum* = 8;
ParseIDStringMaximum* = 9;
ParseIDDelimiter* = 10;
ParseIDDataConstant* = 0;
ParseIDArrayVariable* = 1;
ParseIDAbsoluteRelative* = 2;
ParseIDNoWrapWrap* = 3;
ParseIDLinearNonLinear * = 4;
ParseIDPreferdStateNoPreferd* = 5;
ParseIDNoNullPositionNullState* = 6;
ParseIDNonVolatileVolatile* = 7;
ParseIDBitFieldBufferedByte* = 8;
PROCEDURE PrintLevel(level:LONGINT);
VAR i : LONGINT;
BEGIN
IF(level > 0) THEN
FOR i:=0 TO (level - 1) DO
KernelLog.String(" ");
END;
END;
END PrintLevel;
PROCEDURE ParseMainItem*(bTag, bSize, data, itemNr, depth: LONGINT);
VAR dataAsSet : SET;
BEGIN
IF (bTag=0CH) THEN
DEC(depth);
END;
PrintLevel(depth);
dataAsSet := SYSTEM.VAL(SET, data);
CASE bTag OF
8H: KernelLog.String("Input (");
IF (0 IN dataAsSet) THEN KernelLog.String("Constant, ") ELSE KernelLog.String("Data, ") END;
IF (1 IN dataAsSet) THEN KernelLog.String("Variable, ") ELSE KernelLog.String("Array, ") END;
IF (2 IN dataAsSet) THEN KernelLog.String("Relative, ") ELSE KernelLog.String("Absolute, ") END;
IF (3 IN dataAsSet) THEN KernelLog.String("Wrap, ") ELSE KernelLog.String("No Wrap, ") END;
IF (4 IN dataAsSet) THEN KernelLog.String("Non Linear, ") ELSE KernelLog.String("Linear, ") END;
IF (5 IN dataAsSet) THEN KernelLog.String("No Preferred, ") ELSE KernelLog.String("Preferred State, ") END;
IF (6 IN dataAsSet) THEN KernelLog.String("Null State") ELSE KernelLog.String("No Null Position ") END;
IF (7 IN dataAsSet) THEN ELSE END;
IF bSize > 1 THEN
IF (8 IN dataAsSet) THEN KernelLog.String(", Buffered Bytes"); ELSE KernelLog.String(", Bit Field"); END;
END;
|9H: KernelLog.String("Output(");
IF (0 IN dataAsSet) THEN KernelLog.String("Constant, ") ELSE KernelLog.String("Data, ") END;
IF (1 IN dataAsSet) THEN KernelLog.String("Variable, ") ELSE KernelLog.String("Array, ") END;
IF (2 IN dataAsSet) THEN KernelLog.String("Relative, ") ELSE KernelLog.String("Absolute, ") END;
IF (3 IN dataAsSet) THEN KernelLog.String("Wrap, ") ELSE KernelLog.String("No Wrap, "); END;
IF (4 IN dataAsSet) THEN KernelLog.String("Non Linear, ") ELSE KernelLog.String("Linear, ") END;
IF (5 IN dataAsSet) THEN KernelLog.String("No Preferred, ") ELSE KernelLog.String("Preferred State, ") END;
IF (6 IN dataAsSet) THEN KernelLog.String("Null State, ") ELSE KernelLog.String("No Null Position, ") END;
IF (7 IN dataAsSet) THEN KernelLog.String("Volatile") ELSE KernelLog.String("Non Volatile") END;
IF bSize > 1 THEN
IF (8 IN dataAsSet) THEN KernelLog.String(", Buffered Bytes") ELSE KernelLog.String(", Bit Field") END;
END;
|0BH: KernelLog.String("Feature(");
IF (0 IN dataAsSet) THEN KernelLog.String("Constant, ") ELSE KernelLog.String("Data, "); END;
IF (1 IN dataAsSet) THEN KernelLog.String("Variable, ") ELSE KernelLog.String("Array, ") END;
IF (2 IN dataAsSet) THEN KernelLog.String("Relative, ") ELSE KernelLog.String("Absolute, ") END;
IF (3 IN dataAsSet) THEN KernelLog.String("Wrap, ") ELSE KernelLog.String("No Wrap, ") END;
IF (4 IN dataAsSet) THEN KernelLog.String("Non Linear, ") ELSE KernelLog.String("Linear, ") END;
IF (5 IN dataAsSet) THEN KernelLog.String("No Preferred, ") ELSE KernelLog.String("Preferred State, ") END;
IF (6 IN dataAsSet) THEN KernelLog.String("Null State, ") ELSE KernelLog.String("No Null Position, ") END;
IF (7 IN dataAsSet) THEN KernelLog.String("Volatile") ELSE KernelLog.String("Non Volatile") END;
IF bSize > 1 THEN
IF (8 IN dataAsSet) THEN KernelLog.String(", Buffered Bytes"); ELSE KernelLog.String(", Bit Field") END;
END;
|0AH: KernelLog.String("Collection(");
CASE data OF
0H: KernelLog.String("Physical");
|1H: KernelLog.String("Application");
|2H: KernelLog.String("Logical");
|3H: KernelLog.String("Report");
|4H: KernelLog.String("Named Array");
|5H: KernelLog.String("Usage Switch");
|6H: KernelLog.String("Usage Modifier");
ELSE
IF data < 8FH THEN
KernelLog.String("RESERVED");
ELSE
KernelLog.String("Vendor-defined");
END;
END;
|0CH: KernelLog.String("End Collection(");
ELSE
KernelLog.String("RESERVED(");
END;
KernelLog.String(")");
KernelLog.Ln;
END ParseMainItem;
PROCEDURE ParseGlobalItem*( bTag, bSize, data, itemNr, depth: LONGINT);
VAR
BEGIN
PrintLevel(depth);
CASE bTag OF
0H: KernelLog.String("Usage Page (");
CASE data OF
0H:
KernelLog.String("Undefined");
|1H: KernelLog.String("Generic Desktop Controls");
|2H: KernelLog.String("Simulation Controls");
|3H: KernelLog.String("VR Controls");
|4H: KernelLog.String("Sport Controls ");
|5H: KernelLog.String("Game Controls");
|6H: KernelLog.String("Generic Device Controls");
|7H: KernelLog.String("Keyboard/Keypad");
|8H: KernelLog.String("LEDs");
|9H: KernelLog.String("Button");
|0AH: KernelLog.String("Ordinal");
|0BH: KernelLog.String("Telephony");
|0CH: KernelLog.String("Consumer");
|0DH: KernelLog.String("Digitizer");
|0EH: KernelLog.String("Reserved");
|0FH: KernelLog.String("PID Page");
|10H: KernelLog.String("Unicode");
|14H: KernelLog.String("Alphanumeric Display");
|40: KernelLog.String("Medical Instruments");
|81H: KernelLog.String("Monitor pages");
|82H: KernelLog.String("Monitor pages");
|83H: KernelLog.String("Monitor pages");
|84H: KernelLog.String("Power pages");
|85H: KernelLog.String("Power pages");
|86H: KernelLog.String("Power pages");
|87H: KernelLog.String("Power pages");
|8CH: KernelLog.String("Bar Code Scanner page");
|8DH: KernelLog.String("Scale page");
|8EH: KernelLog.String("Magnetic Stripe reading (MSR) Devices");
|8FH: KernelLog.String("Reserved Point of Sale pages");
ELSE
KernelLog.String("Reserved("); KernelLog.Int(data,0); KernelLog.String(")");
END;
|1H: KernelLog.String("Logical Minimum (");
KernelLog.Int(data,0);
|2H: KernelLog.String("Logical Maximum(");
KernelLog.Int(data,0);
|3H: KernelLog.String("Physical Minimum (");
KernelLog.Int(data,0);
|4H: KernelLog.String("Physical Maximum(");
KernelLog.Int(data,0);
|5H: KernelLog.String("Unit Exponent(");
KernelLog.Int(data,0);
|6H: KernelLog.String("Unit(");
KernelLog.Int(data,0);
|7H: KernelLog.String("Report Size(");
KernelLog.Int(data,0);
|8H: KernelLog.String("Report ID(");
KernelLog.Int(data,0);
|9H: KernelLog.String("Report Count (");
KernelLog.Int(data,0);
|10: KernelLog.String("Push(");
|11: KernelLog.String("Pop (");
ELSE
KernelLog.String("Reserved(");
END;
KernelLog.String(")");
KernelLog.Ln;
END ParseGlobalItem;
PROCEDURE ParseLocalItem*(bTag, bSize, data, itemNr, depth, usagePage: LONGINT);
BEGIN
PrintLevel(depth);
CASE bTag OF
0H: IF (data DIV 10000H>0) THEN
KernelLog.String("UsagePage("); UsbHidUP.PrintUsagePageName(data DIV 10000H); KernelLog.String(") ");
END;
KernelLog.String("Usage(");
UsbHidUP.PrintUsagePage(usagePage, data);
|1H: IF (data DIV 10000H>0) THEN
KernelLog.String("UsagePage("); UsbHidUP.PrintUsagePageName(data DIV 10000H); KernelLog.String(") ");
END;
KernelLog.String("Usage Minimum(");
KernelLog.Int(data MOD 10000H,0);
|2H: IF (data DIV 10000H>0) THEN
KernelLog.String("UsagePage("); UsbHidUP.PrintUsagePageName(data DIV 10000H); KernelLog.String(") ");
END;
KernelLog.String("Usage Maximum(");
KernelLog.Int(data MOD 10000H,0);
|3H: KernelLog.String("Designator Index(");
KernelLog.Int(data,0);
|4H: KernelLog.String("Designator Minimum(");
KernelLog.Int(data,0);
|5H: KernelLog.String("Designator Maximum(");
KernelLog.Int(data,0);
|7H: KernelLog.String("String Index(");
KernelLog.Int(data,0);
|8H: KernelLog.String("String Minimum(");
KernelLog.Int(data,0);
|9H: KernelLog.String("String Maximum(");
KernelLog.Int(data,0);
|0AH: KernelLog.String("Delimiter(");
CASE data OF
0: KernelLog.String("open set)");
|1H: KernelLog.String("close set)");
ELSE
END;
ELSE KernelLog.String("RESERVED");
END;
KernelLog.String(")");
KernelLog.Ln;
END ParseLocalItem;
END UsbHidParserExt.
SystemTools.Free UsbHidParserExt~