Author: ablackmann
Date: Wed Nov 4 20:52:36 2009
New Revision: 43950
URL: http://svn.reactos.org/svn/reactos?rev=43950&view=rev
Log:
Add some helpful debug output to LAYOUT parsing, and enable DoLAYOUT code. The tool is able to fully decode/parse the test.klc English US layout file!
Modified:
trunk/reactos/tools/kbdtool/parser.c
Modified: trunk/reactos/tools/kbdtool/parser.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/kbdtool/parser.c?rev…
==============================================================================
--- trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] (original)
+++ trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] Wed Nov 4 20:52:36 2009
@@ -890,9 +890,6 @@
PLAYOUTENTRY Entry;
UCHAR CharacterType, LigatureChar;
- /* Only attempt this is Verbose is enabled (FOR DEBUGGING ONLY) */
- if (!Verbose) return SkipLines();
-
/* Zero out the layout */
memset(LayoutData, 0, sizeof(LAYOUT));
@@ -930,6 +927,7 @@
}
/* One more */
+ DPRINT1("RAW ENTRY: [%x %s %s]\n", ScanCode, Token, Cap);
Entry++;
if (++ScanCodeCount >= 110)
{
@@ -988,6 +986,8 @@
/* Get the virtual key from the entry */
VirtualKey = getVKNum(Token);
Entry->VirtualKey = VirtualKey;
+ DPRINT1("ENTRY: [%x %x %x %s] with ",
+ Entry->VirtualKey, Entry->OriginalVirtualKey, Entry->ScanCode, Entry->Name);
/* Make sure it's valid */
if (VirtualKey == 0xFFFF)
@@ -1024,6 +1024,7 @@
State[6],
State[7]);
Entry->StateCount = Count;
+ DPRINT1("%d STATES: [", Count);
/* Check if there are less than 2 states */
if ((Count < 2) && (FullEntry))
@@ -1037,6 +1038,7 @@
for (i = 0; i < Count; i++)
{
/* Check if this is an undefined state */
+ DPRINT1("%s ", State[i]);
if (!strcmp(State[i], "-1"))
{
/* No data for this state */
@@ -1061,6 +1063,7 @@
}
/* Check for sanity checks */
+ DPRINT1("]\n");
if (SanityCheck)
{
/* Not yet handled... */
Author: ablackmann
Date: Wed Nov 4 20:38:21 2009
New Revision: 43949
URL: http://svn.reactos.org/svn/reactos?rev=43949&view=rev
Log:
Implement getCharacterInfo so the tool can now handle most LAYOUT entries, but not complicated ligature entries (dead keys are fine though). Also cleaned up the parsing loop of DoLAYOUT to avoid a goto, and finally added detection of SGCAP entries (in which case the tool will fail, since these are complex and not needed for now).
The main parsing loop is pretty much done, now the tool "just" has to merge the states and perform a check for duplicate entries. Then it'll be ready to generate the output files.
Modified:
trunk/reactos/tools/kbdtool/parser.c
Modified: trunk/reactos/tools/kbdtool/parser.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/kbdtool/parser.c?rev…
==============================================================================
--- trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] (original)
+++ trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] Wed Nov 4 20:38:21 2009
@@ -42,7 +42,7 @@
UCHAR OriginalVirtualKey;
ULONG Cap;
ULONG StateCount;
- ULONGLONG CharData[8];
+ ULONG CharData[8];
ULONG DeadCharData[8];
ULONG OtherCharData[8];
struct LAYOUTENTRY* CapData;
@@ -60,7 +60,7 @@
#define KEYWORD_COUNT 17
-extern BOOLEAN Verbose, UnicodeFile;
+extern BOOLEAN Verbose, UnicodeFile, SanityCheck;
extern PCHAR gpszFileName;
extern FILE* gfpInput;
CHAR gBuf[256];
@@ -318,12 +318,74 @@
UCHAR
getCharacterInfo(IN PCHAR State,
- IN PLAYOUTENTRY Entry,
+ OUT PULONG EntryChar,
OUT PCHAR LigatureChar)
{
- /* FIXME: NOT YET IMPLEMENTED */
- ASSERT(FALSE);
- return 0;
+ ULONG Length;
+ ULONG CharInfo = CHAR_NORMAL_KEY;
+ UCHAR StateChar;
+ ULONG CharCode;
+
+ /* Calculate the length of the state */
+ Length = strlen(State);
+
+ /* Check if this is at least a simple key state */
+ if (Length > 1)
+ {
+ /* Read the first character and check if it's a dead key */
+ StateChar = State[Length - 1];
+ if (StateChar == '@')
+ {
+ /* This is a dead key */
+ CharInfo = CHAR_DEAD_KEY;
+ }
+ else if (StateChar == '%')
+ {
+ /* This is another key */
+ CharInfo = CHAR_OTHER_KEY;
+ }
+ }
+
+ /* Check if this is a numerical key state */
+ if ((Length - 1) >= 2)
+ {
+ /* Scan for extended character code entry */
+ if ((sscanf(State, "%6x", &CharCode) == 1) &&
+ ((Length == 5) && (State[0] == '0') ||
+ (Length == 6) && ((State[0] == '0') && (State[1] == '0'))))
+ {
+ /* Handle a ligature key */
+ CharInfo = CHAR_LIGATURE_KEY;
+
+ /* Not yet handled */
+ printf("Ligatured character entries not yet supported!\n");
+ exit(1);
+ }
+ else
+ {
+ /* Get the normal character entry */
+ if (sscanf(State, "%4x", &CharCode) == 1)
+ {
+ /* Does the caller want the key? */
+ if (EntryChar) *EntryChar = CharCode;
+ }
+ else
+ {
+ /* The entry is totally invalid */
+ if (Verbose) printf("An unparseable character entry '%s' was found.\n", State);
+ if (EntryChar) *EntryChar = 0;
+ CharInfo = CHAR_INVALID_KEY;
+ }
+ }
+ }
+ else
+ {
+ /* Save the key if the caller requested it */
+ if (EntryChar) *EntryChar = *State;
+ }
+
+ /* Return the type of character this is */
+ return CharInfo;
}
BOOLEAN
@@ -892,34 +954,34 @@
/* Fill out the entry */
Entry->VirtualKey = getVKNum(Token);
- goto FillEntry;
+ break;
}
-
- /* If we found it, process it */
- if (ScanCode == CurrentCode) break;
- }
-
- /* Make sure we didn't already process it */
- if (ScVk[i].Processed)
- {
- /* Fail */
- printf("Scancode %X was previously defined.\n", ScanCode);
- exit(1);
- }
-
- /* Check if there is a valid virtual key */
- if (ScVk[i].VirtualKey == 0xFFFF)
- {
- /* Fail */
- printf("The Scancode you tried to use (%X) is reserved.\n", ScanCode);
- exit(1);
- }
-
- /* Fill out the entry */
- Entry->OriginalVirtualKey = ScVk[i].VirtualKey;
- Entry->Name = ScVk[i].Name;
-
-FillEntry:
+ else if (ScanCode == CurrentCode)
+ {
+ /* Make sure we didn't already process it */
+ if (ScVk[i].Processed)
+ {
+ /* Fail */
+ printf("Scancode %X was previously defined.\n", ScanCode);
+ exit(1);
+ }
+
+ /* Check if there is a valid virtual key */
+ if (ScVk[i].VirtualKey == 0xFFFF)
+ {
+ /* Fail */
+ printf("The Scancode you tried to use (%X) is reserved.\n", ScanCode);
+ exit(1);
+ }
+
+ /* Fill out the entry */
+ Entry->OriginalVirtualKey = ScVk[i].VirtualKey;
+ Entry->Name = ScVk[i].Name;
+ break;
+ }
+ }
+
+ /* The entry is now processed */
Entry->Processed = TRUE;
ScVk[i].Processed = TRUE;
@@ -983,7 +1045,9 @@
}
/* Otherwise, check what kind of character this is */
- CharacterType = getCharacterInfo(State[i], Entry, &LigatureChar);
+ CharacterType = getCharacterInfo(State[i],
+ &Entry->CharData[i],
+ &LigatureChar);
if (CharacterType == CHAR_DEAD_KEY)
{
/* Save it as such */
@@ -995,6 +1059,22 @@
Entry->OtherCharData[i] = 1;
}
}
+
+ /* Check for sanity checks */
+ if (SanityCheck)
+ {
+ /* Not yet handled... */
+ printf("Sanity checks not yet handled!\n");
+ exit(1);
+ }
+
+ /* Check if we had SGCAP data */
+ if (Entry->Cap & 2)
+ {
+ /* Not yet handled... */
+ printf("SGCAP state not yet handled!\n");
+ exit(1);
+ }
}
/* Skip what's left */
Author: ablackmann
Date: Wed Nov 4 05:49:00 2009
New Revision: 43947
URL: http://svn.reactos.org/svn/reactos?rev=43947&view=rev
Log:
Started adding support for reading the different character states and the cap data (including detecting SGCAP). Now the tool has to determine the type of each character defined at every stage (dead, valid, invalid, ligature, etc...) and save the character in the appropriate slot. Dead and other keys are currently handled, as are undefined keys.
Major work remains to be done...
Modified:
trunk/reactos/tools/kbdtool/parser.c
Modified: trunk/reactos/tools/kbdtool/parser.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/kbdtool/parser.c?rev…
==============================================================================
--- trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] (original)
+++ trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] Wed Nov 4 05:49:00 2009
@@ -40,9 +40,9 @@
USHORT ScanCode;
UCHAR VirtualKey;
UCHAR OriginalVirtualKey;
- UCHAR Cap;
+ ULONG Cap;
ULONG StateCount;
- ULONG CharData[8];
+ ULONGLONG CharData[8];
ULONG DeadCharData[8];
ULONG OtherCharData[8];
struct LAYOUTENTRY* CapData;
@@ -250,6 +250,11 @@
{0xe6, "RGROUPSHIFT"}
};
+#define CHAR_NORMAL_KEY 0
+#define CHAR_DEAD_KEY 1
+#define CHAR_OTHER_KEY 2
+#define CHAR_INVALID_KEY 3
+#define CHAR_LIGATURE_KEY 4
/* FUNCTIONS ******************************************************************/
@@ -311,6 +316,16 @@
return -1;
}
+UCHAR
+getCharacterInfo(IN PCHAR State,
+ IN PLAYOUTENTRY Entry,
+ OUT PCHAR LigatureChar)
+{
+ /* FIXME: NOT YET IMPLEMENTED */
+ ASSERT(FALSE);
+ return 0;
+}
+
BOOLEAN
NextLine(PCHAR LineBuffer,
ULONG BufferSize,
@@ -806,9 +821,12 @@
ULONG TokenCount;
ULONG VirtualKey;
ULONG i;
+ ULONG Count;
BOOLEAN FullEntry;
+ CHAR State[8][8];
ULONG ScanCodeCount = -1;
PLAYOUTENTRY Entry;
+ UCHAR CharacterType, LigatureChar;
/* Only attempt this is Verbose is enabled (FOR DEBUGGING ONLY) */
if (!Verbose) return SkipLines();
@@ -915,6 +933,67 @@
/* Warn the user */
if (Verbose) printf("An invalid Virtual Key '%s' was defined.\n", Token);
continue;
+ }
+
+ /* Is this a full entry */
+ if (FullEntry)
+ {
+ /* Do we have SGCAP data? Set cap mode to 2 */
+ if (!strcmp(Cap, "SGCAP")) *Cap = '2';
+
+ /* Read the cap mode */
+ if (sscanf(Cap, "%1d[012]", &Entry->Cap) != 1)
+ {
+ /* Invalid cap mode */
+ printf("invalid Cap specified (%s). Must be 0, 1, or 2.\n", Cap);
+ exit(1);
+ }
+ }
+
+ /* Read the states */
+ Count = sscanf(gBuf,
+ " %*s %*s %*s %s %s %s %s %s %s %s %s",
+ State[0],
+ State[1],
+ State[2],
+ State[3],
+ State[4],
+ State[5],
+ State[6],
+ State[7]);
+ Entry->StateCount = Count;
+
+ /* Check if there are less than 2 states */
+ if ((Count < 2) && (FullEntry))
+ {
+ /* Fail */
+ printf("You must have at least 2 characters.\n");
+ exit(1);
+ }
+
+ /* Loop all states */
+ for (i = 0; i < Count; i++)
+ {
+ /* Check if this is an undefined state */
+ if (!strcmp(State[i], "-1"))
+ {
+ /* No data for this state */
+ Entry->CharData[i] = -1;
+ continue;
+ }
+
+ /* Otherwise, check what kind of character this is */
+ CharacterType = getCharacterInfo(State[i], Entry, &LigatureChar);
+ if (CharacterType == CHAR_DEAD_KEY)
+ {
+ /* Save it as such */
+ Entry->DeadCharData[i] = 1;
+ }
+ else if (CharacterType == CHAR_OTHER_KEY)
+ {
+ /* Save it as such */
+ Entry->OtherCharData[i] = 1;
+ }
}
}