Author: ablackmann
Date: Fri Nov 6 01:38:04 2009
New Revision: 43985
URL: http://svn.reactos.org/svn/reactos?rev=43985&view=rev
Log:
Implement support for writing the virtual key to WCHAR translation for different shift states.
Only 2 shift states are supported for now, I have to add a lot more output generation code to get at least 3 states up and running.
Modified:
trunk/reactos/tools/kbdtool/output.c
Modified: trunk/reactos/tools/kbdtool/output.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/kbdtool/output.c?rev…
==============================================================================
--- trunk/reactos/tools/kbdtool/output.c [iso-8859-1] (original)
+++ trunk/reactos/tools/kbdtool/output.c [iso-8859-1] Fri Nov 6 01:38:04 2009
@@ -492,6 +492,7 @@
{
CHAR OutputFile[13];
CHAR KeyNameBuffer[50];
+ CHAR LineBuffer[256];
BOOLEAN NeedPlus;
FILE *FileHandle;
ULONG States[8];
@@ -864,7 +865,92 @@
"*\n"
"\\***************************************************************************/\n\n");
- /* FIXME: LOTS OF STATE STUFF */
+ /* Loop all the states */
+ for (i = 2; i <= StateCount; i++)
+ {
+ /* Check if this something else than state 2 */
+ if (i != 2)
+ {
+ /* Not yet supported */
+ printf("Extra states not yet supported!\n");
+ break;//exit(1);
+ }
+
+ /* Print the table header */
+ fprintf(FileHandle,
+ "static ALLOC_SECTION_LDATA VK_TO_WCHARS%d aVkToWch%d[] = {\n"
+ "// | | Shift |",
+ i,
+ i);
+
+ /* Print the correct state label */
+ for (k = 2; k < i; k++) fprintf(FileHandle, "%-9.9s|",
+ StateLabel[ShiftStates[k]]);
+
+ /* Print the next separator */
+ fprintf(FileHandle, "\n// |=========|=========|");
+
+ /* Check for extra states and print their separators too */
+ for (k = 2; k < i; k++) fprintf(FileHandle, "=========|");
+
+ /* Finalize the separator header */
+ fprintf(FileHandle, "\n");
+
+ /* 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) continue;
+
+ /* Print out the entry for this key */
+ fprintf(FileHandle,
+ " {%-13s,%-7s",
+ getVKName(Layout->Entry[j].VirtualKey, 1),
+ CapState[Layout->Entry[j].Cap]);
+
+ /* Initialize the buffer for this line */
+ *LineBuffer = '\0';
+
+ /* FIXME: Loop for states */
+
+ /* Finish the line */
+ fprintf(FileHandle, "},\n");
+
+ /* Do we have any data at all? */
+ if (*LineBuffer != '\0')
+ {
+ /* Print it, we're done */
+ fprintf(FileHandle, "%s},\n", LineBuffer);
+ continue;
+ }
+
+ /* Otherwise, we're done, unless this requires SGCAP data */
+ if (Layout->Entry[j].Cap != 2) continue;
+
+ /* Not yet supported */
+ printf("SGCAP not yet supported!\n");
+ exit(1);
+ }
+
+ /* Did we only have two states? */
+ if (i == 2)
+ {
+ /* Print out the built-in table */
+ fprintf(FileHandle,
+ " {VK_TAB ,0 ,'\\t' ,'\\t' },\n"
+ " {VK_ADD ,0 ,'+' ,'+' },\n"
+ " {VK_DIVIDE ,0 ,'/' ,'/' },\n"
+ " {VK_MULTIPLY ,0 ,'*' ,'*' },\n"
+ " {VK_SUBTRACT ,0 ,'-' ,'-' },\n");
+ }
+
+ /* Terminate the table */
+ fprintf(FileHandle, " {0 ,0 ");
+ for (k = 0; k < i; k++) fprintf(FileHandle, ",0 ");
+
+ /* Terminate the structure */
+ fprintf(FileHandle, "}\n" "};\n\n");
+ }
/* Numpad translation table */
fprintf(FileHandle,
Author: ablackmann
Date: Thu Nov 5 20:55:57 2009
New Revision: 43978
URL: http://svn.reactos.org/svn/reactos?rev=43978&view=rev
Log:
Add more support for shift state output. The tool now updates CharModifiers table based on the shift states present in the layout, building both the modification number and the key name based on the virtual key-> name table.
Modified:
trunk/reactos/tools/kbdtool/output.c
Modified: trunk/reactos/tools/kbdtool/output.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/kbdtool/output.c?rev…
==============================================================================
--- trunk/reactos/tools/kbdtool/output.c [iso-8859-1] (original)
+++ trunk/reactos/tools/kbdtool/output.c [iso-8859-1] Thu Nov 5 20:55:57 2009
@@ -387,11 +387,14 @@
IN PKEYNAME KeyNameDeadData)
{
CHAR OutputFile[13];
+ CHAR KeyNameBuffer[50];
+ BOOLEAN NeedPlus;
FILE *FileHandle;
ULONG States[8];
- ULONG i;
+ ULONG i, j, k;
ULONG HighestState;
PVKNAME Entry;
+ PCHAR p;
/* Build the keyboard name and internal name */
strcpy(OutputFile, gKBDName);
@@ -636,8 +639,9 @@
for (i = 0; i < 8; i++) States[i] = -1;
/* Find the highest set state */
- for (HighestState = 1, i = 0; i < 8 && ShiftStates[i] > -1; i++)
- {
+ for (HighestState = 1, i = 0; (i < 8) && (ShiftStates[i] != -1); i++)
+ {
+ /* Save all state values */
States[ShiftStates[i]] = i;
if (ShiftStates[i] > HighestState) HighestState = ShiftStates[i];
}
@@ -650,7 +654,68 @@
" {\n"
" // Modification# // Keys Pressed\n"
" // ============= // =============\n",
- 2); /* FIXME: STATE STUFF */
+ HighestState);
+
+ /* Loop states */
+ for (i = 0; i <= HighestState; i++)
+ {
+ /* Check for invalid state */
+ if (States[i] == -1)
+ {
+ /* Invalid state header */
+ fprintf(FileHandle, " SHFT_INVALID, // ");
+ }
+ else
+ {
+ /* Is this the last one? */
+ if (i == HighestState)
+ {
+ /* Last state header */
+ fprintf(FileHandle, " %d // ", States[i]);
+ }
+ else
+ {
+ /* Normal state header */
+ fprintf(FileHandle, " %d, // ", States[i]);
+ }
+
+ /* State 1 or higher? */
+ if (i >= 1)
+ {
+ /* J is the loop variable, K is the double */
+ for (NeedPlus = 0, j = 0, k = 1; (1 << j) <= i; j++, k = (1 << j))
+ {
+ /* Do we need to add a plus? */
+ if (NeedPlus)
+ {
+ /* Add it */
+ fprintf(FileHandle, "+");
+ NeedPlus = FALSE;
+ }
+
+ /* Check if it's time to add a modifier */
+ if (i & k)
+ {
+ /* Get the key state name and copy it into our buffer */
+ strcpy(KeyNameBuffer, getVKName(Modifiers[j].VirtualKey, 1));
+
+ /* Go go the 4th char (past the "KBD") and lower name */
+ for (p = &KeyNameBuffer[4]; *p; p++) *p = tolower(*p);
+
+ /* Print it */
+ fprintf(FileHandle, "%s", &KeyNameBuffer[3]);
+
+ /* We'll need a plus sign next */
+ NeedPlus = TRUE;
+ }
+ }
+ }
+
+ /* Terminate the entry */
+ fprintf(FileHandle, "\n");
+ }
+ }
+
/* Modifier conversion table end */
fprintf(FileHandle," }\n" "};\n\n");