mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 08:39:05 +00:00
Holy shit Batman! KbdTool can now write out the keyboard layout header file! You should get a Layout01.h if you run it on test.klc (in your current working directory).
svn path=/trunk/; revision=43961
This commit is contained in:
parent
1d161cccdd
commit
6191f04a40
|
@ -13,6 +13,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <time.h>
|
||||||
#include <host/typedefs.h>
|
#include <host/typedefs.h>
|
||||||
|
|
||||||
#define KEYWORD_COUNT 17
|
#define KEYWORD_COUNT 17
|
||||||
|
@ -65,11 +66,22 @@ typedef struct tagLAYOUT
|
||||||
LAYOUTENTRY Entry[110];
|
LAYOUTENTRY Entry[110];
|
||||||
} LAYOUT, *PLAYOUT;
|
} LAYOUT, *PLAYOUT;
|
||||||
|
|
||||||
|
PCHAR
|
||||||
|
getVKName(
|
||||||
|
IN ULONG VirtualKey,
|
||||||
|
IN BOOLEAN Prefix
|
||||||
|
);
|
||||||
|
|
||||||
extern BOOLEAN Verbose, UnicodeFile, SanityCheck, FallbackDriver;
|
extern BOOLEAN Verbose, UnicodeFile, SanityCheck, FallbackDriver;
|
||||||
extern PCHAR gpszFileName;
|
extern PCHAR gpszFileName;
|
||||||
extern FILE* gfpInput;
|
extern FILE* gfpInput;
|
||||||
extern VKNAME VKName[];
|
extern VKNAME VKName[];
|
||||||
extern SCVK ScVk[];
|
extern SCVK ScVk[];
|
||||||
extern LAYOUT g_Layout;
|
extern LAYOUT g_Layout;
|
||||||
|
extern CHAR gVKeyName[32];
|
||||||
|
extern CHAR gKBDName[10];
|
||||||
|
extern CHAR gCopyright[256];
|
||||||
|
extern CHAR gDescription[256];
|
||||||
|
extern ULONG gVersion, gSubVersion;
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -12,13 +12,133 @@
|
||||||
|
|
||||||
/* GLOBALS ********************************************************************/
|
/* GLOBALS ********************************************************************/
|
||||||
|
|
||||||
|
time_t Clock;
|
||||||
|
struct tm *Now;
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
kbd_h(IN PLAYOUT Layout)
|
kbd_h(IN PLAYOUT Layout)
|
||||||
{
|
{
|
||||||
/* FIXME: Stub */
|
CHAR OutputFile[13];
|
||||||
return FALSE;
|
FILE *FileHandle;
|
||||||
|
ULONG i;
|
||||||
|
CHAR UndefChar;
|
||||||
|
USHORT SubCode;
|
||||||
|
|
||||||
|
/* Build the keyboard name */
|
||||||
|
strcpy(OutputFile, gKBDName);
|
||||||
|
strcat(OutputFile, ".H");
|
||||||
|
|
||||||
|
/* Open it */
|
||||||
|
FileHandle = fopen(OutputFile, "wt");
|
||||||
|
if (!FileHandle)
|
||||||
|
{
|
||||||
|
/* Fail */
|
||||||
|
printf(" %12s : can't open for write.\n", OutputFile);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print the module header */
|
||||||
|
fprintf(FileHandle,
|
||||||
|
"/****************************** Module Header ******************************\\\n"
|
||||||
|
"* Module Name: %s\n*\n* keyboard layout header\n"
|
||||||
|
"*\n"
|
||||||
|
"* Copyright (c) 2009, ReactOS Foundation\n"
|
||||||
|
"*\n"
|
||||||
|
"* Various defines for use by keyboard input code.\n*\n* History:\n"
|
||||||
|
"*\n"
|
||||||
|
"* created by KBDTOOL v%d.%02d %s*\n"
|
||||||
|
"\\***************************************************************************/\n\n",
|
||||||
|
OutputFile,
|
||||||
|
gVersion,
|
||||||
|
gSubVersion,
|
||||||
|
asctime(Now));
|
||||||
|
|
||||||
|
/* Print out the includes and defines */
|
||||||
|
fprintf(FileHandle,
|
||||||
|
"/*\n"
|
||||||
|
" * kbd type should be controlled by cl command-line argument\n"
|
||||||
|
" *\\n"
|
||||||
|
"#define KBD_TYPE 4\n\n"
|
||||||
|
"/*\n"
|
||||||
|
"* Include the basis of all keyboard table values\n"
|
||||||
|
"*/\n"
|
||||||
|
"#include \"kbd.h\"\n");
|
||||||
|
|
||||||
|
/* Now print out the virtual key conversion table */
|
||||||
|
fprintf(FileHandle,
|
||||||
|
"/***************************************************************************\\\n"
|
||||||
|
"* The table below defines the virtual keys for various keyboard types where\n"
|
||||||
|
"* the keyboard differ from the US keyboard.\n"
|
||||||
|
"*\n"
|
||||||
|
"* _EQ() : all keyboard types have the same virtual key for this scancode\n"
|
||||||
|
"* _NE() : different virtual keys for this scancode, depending on kbd type\n"
|
||||||
|
"*\n"
|
||||||
|
"* +------+ +----------+----------+----------+----------+----------+----------+\n"
|
||||||
|
"* | Scan | | kbd | kbd | kbd | kbd | kbd | kbd |\n"
|
||||||
|
"* | code | | type 1 | type 2 | type 3 | type 4 | type 5 | type 6 |\n"
|
||||||
|
"\\****+-------+_+----------+----------+----------+----------+----------+----------+*/\n\n");
|
||||||
|
|
||||||
|
/* Loop all keys */
|
||||||
|
for (i = 0; i < 110; i++)
|
||||||
|
{
|
||||||
|
/* Check if we processed this key */
|
||||||
|
if (Layout->Entry[i].Processed)
|
||||||
|
{
|
||||||
|
/* Check if it redefined a virtual key */
|
||||||
|
if (Layout->Entry[i].VirtualKey != Layout->Entry[i].OriginalVirtualKey)
|
||||||
|
{
|
||||||
|
/* Do we have a subcode? */
|
||||||
|
SubCode = Layout->Entry[i].ScanCode & 0xFF00;
|
||||||
|
if (SubCode)
|
||||||
|
{
|
||||||
|
/* Which kind is it? */
|
||||||
|
if (SubCode == 0xE000)
|
||||||
|
{
|
||||||
|
/* Extended 0 */
|
||||||
|
UndefChar = 'X';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Illegal */
|
||||||
|
if (SubCode != 0xE100)
|
||||||
|
{
|
||||||
|
/* Unrecognized */
|
||||||
|
printf("Weird scancode value %04x: expected xx, E0xx, or E1xx\n", SubCode);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extended 1 */
|
||||||
|
UndefChar = 'Y';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Normal key */
|
||||||
|
UndefChar = 'T';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print out the virtual key redefinition */
|
||||||
|
fprintf(FileHandle,
|
||||||
|
"#undef %c%02X\n#define %c%02X _EQ(%43s%23s\n",
|
||||||
|
UndefChar,
|
||||||
|
Layout->Entry[i].ScanCode,
|
||||||
|
UndefChar,
|
||||||
|
Layout->Entry[i].ScanCode,
|
||||||
|
getVKName(Layout->Entry[i].VirtualKey, 0),
|
||||||
|
")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cleanup and close */
|
||||||
|
fprintf(FileHandle,"\n");
|
||||||
|
fclose(FileHandle);
|
||||||
|
|
||||||
|
/* We made it */
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
@ -64,7 +184,11 @@ DoOutput(IN ULONG StateCount,
|
||||||
IN PKEYNAME KeyNameDeadData)
|
IN PKEYNAME KeyNameDeadData)
|
||||||
{
|
{
|
||||||
ULONG FailureCode = 0;
|
ULONG FailureCode = 0;
|
||||||
|
|
||||||
|
/* Take the time */
|
||||||
|
time(&Clock);
|
||||||
|
Now = localtime(&Clock);
|
||||||
|
|
||||||
/* Check if this just a fallback driver*/
|
/* Check if this just a fallback driver*/
|
||||||
if (!FallbackDriver)
|
if (!FallbackDriver)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,7 @@ CHAR gCopyright[256];
|
||||||
CHAR gDescription[256];
|
CHAR gDescription[256];
|
||||||
CHAR gCompany[256];
|
CHAR gCompany[256];
|
||||||
CHAR gLocaleName[256];
|
CHAR gLocaleName[256];
|
||||||
|
CHAR gVKeyName[32];
|
||||||
ULONG gID = 0;
|
ULONG gID = 0;
|
||||||
ULONG gKbdLayoutVersion;
|
ULONG gKbdLayoutVersion;
|
||||||
LAYOUT g_Layout;
|
LAYOUT g_Layout;
|
||||||
|
@ -60,6 +61,53 @@ isKeyWord(PCHAR p)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PCHAR
|
||||||
|
getVKName(IN ULONG VirtualKey,
|
||||||
|
IN BOOLEAN Prefix)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
/* Loop for standard virtual key */
|
||||||
|
if (((VirtualKey >= 'A') && (VirtualKey <= 'Z')) ||
|
||||||
|
((VirtualKey >= '0') && (VirtualKey <= '9')))
|
||||||
|
{
|
||||||
|
/* Fill out the name */
|
||||||
|
gVKeyName[0] = '\'';
|
||||||
|
gVKeyName[1] = VirtualKey;
|
||||||
|
gVKeyName[2] = '\'';
|
||||||
|
gVKeyName[3] = '\0';
|
||||||
|
return gVKeyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if a prefix is required */
|
||||||
|
if (Prefix)
|
||||||
|
{
|
||||||
|
/* Add it */
|
||||||
|
strcpy(gVKeyName, "VK_");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Otherwise, don't add anything */
|
||||||
|
strcpy(gVKeyName, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loop all virtual keys */
|
||||||
|
for (i = 0; i < 36; i++)
|
||||||
|
{
|
||||||
|
/* Check if this key matches */
|
||||||
|
if (VKName[i].VirtualKey == VirtualKey)
|
||||||
|
{
|
||||||
|
/* Copy the key's name into the buffer */
|
||||||
|
strcat(gVKeyName, VKName[i].Name);
|
||||||
|
return gVKeyName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we got here, then we failed, so print out an error name */
|
||||||
|
strcpy(gVKeyName, "#ERROR#");
|
||||||
|
return gVKeyName;
|
||||||
|
}
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
getVKNum(IN PCHAR p)
|
getVKNum(IN PCHAR p)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue