From d23204652e9a6ce8e92041563e3bebf4f4b9b97e Mon Sep 17 00:00:00 2001 From: Arch Blackmann Date: Fri, 6 Nov 2009 22:42:26 +0000 Subject: [PATCH] Implement printout the the state tables. It seems to work fine, but the tool doesn't yet generate the modified keys (shift+, ctrl+, etc) for each virtual key. This is the last thing that remains. svn path=/trunk/; revision=43989 --- reactos/tools/kbdtool/kbdtool.h | 1 + reactos/tools/kbdtool/output.c | 104 ++++++++++++++++++++++++++++++-- 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/reactos/tools/kbdtool/kbdtool.h b/reactos/tools/kbdtool/kbdtool.h index 8549796398d..406a83337ce 100644 --- a/reactos/tools/kbdtool/kbdtool.h +++ b/reactos/tools/kbdtool/kbdtool.h @@ -54,6 +54,7 @@ typedef struct tagLAYOUTENTRY ULONG StateCount; ULONG CharData[8]; ULONG DeadCharData[8]; + UCHAR LigatureCharData[8]; ULONG OtherCharData[8]; struct LAYOUTENTRY* CapData; PCHAR Name; diff --git a/reactos/tools/kbdtool/output.c b/reactos/tools/kbdtool/output.c index 91acc7d7959..55e5fa9fe90 100644 --- a/reactos/tools/kbdtool/output.c +++ b/reactos/tools/kbdtool/output.c @@ -17,9 +17,76 @@ ULONG gStringIdForLanguageNames = 1100; ULONG gStringIdForLocaleName = 1200; time_t Clock; struct tm *Now; +CHAR gCharName[32]; /* FUNCTIONS ******************************************************************/ +PCHAR +WChName(IN ULONG Char, + IN BOOLEAN AddZero) +{ + PCHAR p; + + /* Check for invalid character */ + if (Char == -1) + { + /* No name */ + strcpy(gCharName, "WCH_NONE"); + } + else if ((Char > 31) && (Char < 128)) + { + /* Use our global buffer */ + p = gCharName; + + /* Add the first quote unless this was a zero-string */ + if (!AddZero) *p++ = '\''; + + /* Now replace any other quote or comment character with a slash */ + if ((Char == '\"') || (Char == '\'') || (Char == '\\')) *p++ = '\\'; + + /* Now plug in the character */ + *p++ = Char; + + /* And add the terminating quote, unless this was a zero-string */ + if (!AddZero) *p++ = '\''; + + /* Terminate the buffer */ + *p = '\0'; + } + else + { + /* Handle special cases */ + if (Char == '\b') + { + /* Bell */ + strcpy(gCharName, "'\\b'"); + } + else if (Char == '\n') + { + /* New line */ + strcpy(gCharName, "'\\n'"); + } + else if (Char == '\r') + { + /* Return */ + strcpy(gCharName, "'\\r'"); + } + else if (!AddZero) + { + /* Char value, in hex */ + sprintf(gCharName, "0x%04x", Char); + } + else + { + /* Char value, C-style */ + sprintf(gCharName, "\\x%04x", Char); + } + } + + /* Return the name */ + return gCharName; +} + VOID PrintNameTable(FILE* FileHandle, PKEYNAME KeyName, @@ -871,9 +938,12 @@ kbd_c(IN ULONG StateCount, /* Check if this something else than state 2 */ if (i != 2) { - /* Not yet supported */ - printf("Extra states not yet supported!\n"); - break;//exit(1); + /* Loop all the scan codes */ + for (j = 0; j < 110; j++) + { + /* Check if this is the state for the entry */ + if (i == Layout->Entry[j].StateCount) break; + } } /* Print the table header */ @@ -911,7 +981,33 @@ kbd_c(IN ULONG StateCount, /* Initialize the buffer for this line */ *LineBuffer = '\0'; - /* FIXME: Loop for states */ + /* Loop states */ + for (k = 0; k < i; k++) + { + /* Check for dead key data */ + if (DeadKeyData) + { + /* Not yet supported */ + printf("Dead key data not supported!\n"); + exit(1); + } + + /* Check if it's a ligature key */ + if (Layout->Entry[j].LigatureCharData[k]) + { + /* Not yet supported */ + printf("Ligature key data not supported!\n"); + exit(1); + } + + /* Print out the WCH_ name */ + fprintf(FileHandle, + ",%-9s", + WChName(Layout->Entry[j].CharData[k])); + + /* If we have something on the line buffer by now, add WCH_NONE */ + if (*LineBuffer != '\0') strcpy(LineBuffer, "WCH_NONE "); + } /* Finish the line */ fprintf(FileHandle, "},\n");