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.


svn path=/trunk/; revision=43949
This commit is contained in:
Arch Blackmann 2009-11-04 19:38:21 +00:00
parent 650e86a2df
commit 7662e72971

View file

@ -42,7 +42,7 @@ typedef struct tagLAYOUTENTRY
UCHAR OriginalVirtualKey; UCHAR OriginalVirtualKey;
ULONG Cap; ULONG Cap;
ULONG StateCount; ULONG StateCount;
ULONGLONG CharData[8]; ULONG CharData[8];
ULONG DeadCharData[8]; ULONG DeadCharData[8];
ULONG OtherCharData[8]; ULONG OtherCharData[8];
struct LAYOUTENTRY* CapData; struct LAYOUTENTRY* CapData;
@ -60,7 +60,7 @@ typedef struct tagLAYOUT
#define KEYWORD_COUNT 17 #define KEYWORD_COUNT 17
extern BOOLEAN Verbose, UnicodeFile; extern BOOLEAN Verbose, UnicodeFile, SanityCheck;
extern PCHAR gpszFileName; extern PCHAR gpszFileName;
extern FILE* gfpInput; extern FILE* gfpInput;
CHAR gBuf[256]; CHAR gBuf[256];
@ -318,12 +318,74 @@ getVKNum(IN PCHAR p)
UCHAR UCHAR
getCharacterInfo(IN PCHAR State, getCharacterInfo(IN PCHAR State,
IN PLAYOUTENTRY Entry, OUT PULONG EntryChar,
OUT PCHAR LigatureChar) OUT PCHAR LigatureChar)
{ {
/* FIXME: NOT YET IMPLEMENTED */ ULONG Length;
ASSERT(FALSE); ULONG CharInfo = CHAR_NORMAL_KEY;
return 0; 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 BOOLEAN
@ -892,34 +954,34 @@ DoLAYOUT(IN PLAYOUT LayoutData,
/* Fill out the entry */ /* Fill out the entry */
Entry->VirtualKey = getVKNum(Token); Entry->VirtualKey = getVKNum(Token);
goto FillEntry; break;
}
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;
} }
/* If we found it, process it */
if (ScanCode == CurrentCode) break;
} }
/* Make sure we didn't already process it */ /* The entry is now processed */
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:
Entry->Processed = TRUE; Entry->Processed = TRUE;
ScVk[i].Processed = TRUE; ScVk[i].Processed = TRUE;
@ -983,7 +1045,9 @@ FillEntry:
} }
/* Otherwise, check what kind of character this is */ /* 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) if (CharacterType == CHAR_DEAD_KEY)
{ {
/* Save it as such */ /* Save it as such */
@ -995,6 +1059,22 @@ FillEntry:
Entry->OtherCharData[i] = 1; 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 */ /* Skip what's left */