559{
561 CHAR KeyNameBuffer[50];
562 CHAR LineBuffer[256];
570
571
574
575
578 {
579
580 printf(
" %12s : can't open for write.\n", OutputFile);
582 }
583
584
586 "/***************************************************************************\\\n"
587 "* Module Name: %s\n*\n* keyboard layout\n"
588 "*\n"
589 "* Copyright (c) 2009, ReactOS Foundation\n"
590 "*\n"
591 "* History:\n"
592 "* KBDTOOL v%d.%02d - Created %s"
593 "\\***************************************************************************/\n\n",
594 OutputFile,
598
599
601 {
602
604 }
605 else
606 {
607
609 "#include <windows.h>\n"
610 "#include \"kbd.h\"\n"
611 "#include \"%s.h\"\n\n",
613 }
614
615
617 {
618
620 "#pragma data_seg(\"%s\")\n#define ALLOC_SECTION_LDATA\n\n",
621 ".kbdfallback");
622 }
623 else
624 {
625
627 "#if defined(_M_IA64)\n"
628 "#pragma section(\"%s\")\n"
629 "#define ALLOC_SECTION_LDATA __declspec(allocate(\"%s\"))\n"
630 "#else\n"
631 "#pragma data_seg(\"%s\")\n"
632 "#define ALLOC_SECTION_LDATA\n"
633 "#endif\n\n",
634 ".data",
635 ".data",
636 ".data");
637 }
638
639
641 "/***************************************************************************\\\n"
642 "* ausVK[] - Virtual Scan Code to Virtual Key conversion table\n"
643 "\\***************************************************************************/\n\n");
644
645
647 "static ALLOC_SECTION_LDATA USHORT ausVK[] = {\n"
648 " T00, T01, T02, T03, T04, T05, T06, T07,\n"
649 " T08, T09, T0A, T0B, T0C, T0D, T0E, T0F,\n"
650 " T10, T11, T12, T13, T14, T15, T16, T17,\n"
651 " T18, T19, T1A, T1B, T1C, T1D, T1E, T1F,\n"
652 " T20, T21, T22, T23, T24, T25, T26, T27,\n"
653 " T28, T29, T2A, T2B, T2C, T2D, T2E, T2F,\n"
654 " T30, T31, T32, T33, T34, T35,\n\n");
655
656
658 " /*\n"
659 " * Right-hand Shift key must have KBDEXT bit set.\n"
660 " */\n"
661 " T36 | KBDEXT,\n\n"
662 " T37 | KBDMULTIVK, // numpad_* + Shift/Alt -> SnapShot\n\n"
663 " T38, T39, T3A, T3B, T3C, T3D, T3E,\n"
664 " T3F, T40, T41, T42, T43, T44,\n\n");
665
666
668 " /*\n"
669 " * NumLock Key:\n"
670 " * KBDEXT - VK_NUMLOCK is an Extended key\n"
671 " * KBDMULTIVK - VK_NUMLOCK or VK_PAUSE (without or with CTRL)\n"
672 " */\n"
673 " T45 | KBDEXT | KBDMULTIVK,\n\n"
674 " T46 | KBDMULTIVK,\n\n");
675
676
678 " /*\n"
679 " * Number Pad keys:\n"
680 " * KBDNUMPAD - digits 0-9 and decimal point.\n"
681 " * KBDSPECIAL - require special processing by Windows\n"
682 " */\n"
683 " T47 | KBDNUMPAD | KBDSPECIAL, // Numpad 7 (Home)\n"
684 " T48 | KBDNUMPAD | KBDSPECIAL, // Numpad 8 (Up),\n"
685 " T49 | KBDNUMPAD | KBDSPECIAL, // Numpad 9 (PgUp),\n"
686 " T4A,\n"
687 " T4B | KBDNUMPAD | KBDSPECIAL, // Numpad 4 (Left),\n"
688 " T4C | KBDNUMPAD | KBDSPECIAL, // Numpad 5 (Clear),\n"
689 " T4D | KBDNUMPAD | KBDSPECIAL, // Numpad 6 (Right),\n"
690 " T4E,\n"
691 " T4F | KBDNUMPAD | KBDSPECIAL, // Numpad 1 (End),\n"
692 " T50 | KBDNUMPAD | KBDSPECIAL, // Numpad 2 (Down),\n"
693 " T51 | KBDNUMPAD | KBDSPECIAL, // Numpad 3 (PgDn),\n"
694 " T52 | KBDNUMPAD | KBDSPECIAL, // Numpad 0 (Ins),\n"
695 " T53 | KBDNUMPAD | KBDSPECIAL, // Numpad . (Del),\n\n");
696
697
699 " T54, T55, T56, T57, T58, T59, T5A, T5B,\n"
700 " T5C, T5D, T5E, T5F, T60, T61, T62, T63,\n"
701 " T64, T65, T66, T67, T68, T69, T6A, T6B,\n"
702 " T6C, T6D, T6E, T6F, T70, T71, T72, T73,\n"
703 " T74, T75, T76, T77, T78, T79, T7A, T7B,\n"
704 " T7C, T7D, T7E\n\n"
705 "};\n\n");
706
707
709
710
711 for (
i = 0;
i < 110;
i++)
712 {
713
714 if ((Layout->Entry[
i].ScanCode & 0xFF00) == 0xE000)
715 {
716
717 if (Layout->Entry[
i].ScanCode != 0xFF)
718 {
719
720 if (Layout->Entry[
i].VirtualKey != 0xFF)
721 {
722
724 " { 0x%02X, X%02X | KBDEXT }, // %s\n",
725 Layout->Entry[
i].ScanCode,
726 Layout->Entry[
i].ScanCode,
727 Layout->Entry[
i].
Name);
728 }
729 }
730 }
731 }
732
733
735
736
738
739
740 for (
i = 0;
i < 110;
i++)
741 {
742
743 if ((Layout->Entry[
i].ScanCode & 0xFF00) == 0xE100)
744 {
745
746 if (Layout->Entry[
i].ScanCode != 0xFF)
747 {
748
749 if (Layout->Entry[
i].VirtualKey != 0xFF)
750 {
751
753 " { 0x%02X, Y%02X | KBDEXT }, // %s\n",
754 Layout->Entry[
i].ScanCode,
755 Layout->Entry[
i].ScanCode,
756 Layout->Entry[
i].
Name);
757 }
758 }
759 }
760 }
761
762
764 " { 0x1D, Y1D }, // Pause\n"
765 " { 0 , 0 }\n};\n\n");
766
767
769 "/***************************************************************************\\\n"
770 "* aVkToBits[] - map Virtual Keys to Modifier Bits\n"
771 "*\n"
772 "* See kbd.h for a full description.\n"
773 "*\n"
774 "* The keyboard has only three shifter keys:\n"
775 "* SHIFT (L & R) affects alphabnumeric keys,\n"
776 "* CTRL (L & R) is used to generate control characters\n"
777 "* ALT (L & R) used for generating characters by number with numpad\n"
778 "\\***************************************************************************/\n");
779
780
782
783
786 while (
Entry->VirtualKey)
787 {
788
790 " { %-12s, %-12s },\n",
793
794
796 }
797
798
800
801
803 "/***************************************************************************\\\n"
804 "* aModification[] - map character modifier bits to modification number\n"
805 "*\n"
806 "* See kbd.h for a full description.\n"
807 "*\n"
808 "\\***************************************************************************/\n\n");
809
810
811 for (
i = 0;
i < 8;
i++) States[
i] = -1;
812
813
814 for (HighestState = 1,
i = 0; (
i < 8) && (ShiftStates[
i] != -1);
i++)
815 {
816
817 States[ShiftStates[
i]] =
i;
818 if (ShiftStates[
i] > HighestState) HighestState = ShiftStates[
i];
819 }
820
821
823 "static ALLOC_SECTION_LDATA MODIFIERS CharModifiers = {\n"
824 " &aVkToBits[0],\n"
825 " %d,\n"
826 " {\n"
827 " // Modification# // Keys Pressed\n"
828 " // ============= // =============\n",
829 HighestState);
830
831
832 for (
i = 0;
i <= HighestState;
i++)
833 {
834
836 {
837
839 }
840 else
841 {
842
843 if (
i == HighestState)
844 {
845
847 }
848 else
849 {
850
852 }
853
854
856 {
857
858 for (NeedPlus = 0,
j = 0,
k = 1; (1u <<
j) <=
i;
j++,
k = (1 <<
j))
859 {
860
861 if (NeedPlus)
862 {
863
866 }
867
868
870 {
871
873
874
876
877
879
880
882 }
883 }
884 }
885
886
888 }
889 }
890
891
892
894
895
897 "/***************************************************************************\\\n"
898 "*\n"
899 "* aVkToWch2[] - Virtual Key to WCHAR translation for 2 shift states\n"
900 "* aVkToWch3[] - Virtual Key to WCHAR translation for 3 shift states\n"
901 "* aVkToWch4[] - Virtual Key to WCHAR translation for 4 shift states\n");
902
903
904 for (
i = 5;
i < HighestState;
i++)
905 {
906
908 "* aVkToWch%d[] - Virtual Key to WCHAR translation for %d shift states\n",
911 }
912
913
915 "*\n"
916 "* Table attributes: Unordered Scan, null-terminated\n"
917 "*\n"
918 "* Search this table for an entry with a matching Virtual Key to find the\n"
919 "* corresponding unshifted and shifted WCHAR characters.\n"
920 "*\n"
921 "* Special values for VirtualKey (column 1)\n"
922 "* 0xff - dead chars for the previous entry\n"
923 "* 0 - terminate the list\n"
924 "*\n"
925 "* Special values for Attributes (column 2)\n"
926 "* CAPLOK bit - CAPS-LOCK affect this key like SHIFT\n"
927 "*\n"
928 "* Special values for wch[*] (column 3 & 4)\n"
929 "* WCH_NONE - No character\n"
930 "* WCH_DEAD - Dead Key (diaresis) or invalid (US keyboard has none)\n"
931 "* WCH_LGTR - Ligature (generates multiple characters)\n"
932 "*\n"
933 "\\***************************************************************************/\n\n");
934
935
936 for (
i = 2;
i <= StateCount;
i++)
937 {
938
940 {
941
942 for (
j = 0;
j < 110;
j++)
943 {
944
945 if (
i == Layout->Entry[
j].StateCount)
break;
946 }
947 }
948
949
951 "static ALLOC_SECTION_LDATA VK_TO_WCHARS%d aVkToWch%d[] = {\n"
952 "// | | Shift |",
955
956
959
960
962
963
965
966
968
969
970 for (
j = 0;
j < 110;
j++)
971 {
972
973 if (
i != Layout->Entry[
j].StateCount)
continue;
974
975
977 " {%-13s,%-7s",
980
981
982 *LineBuffer = '\0';
983
984
985 for (
k = 0;
k <
i;
k++)
986 {
987
988 if (DeadKeyData)
989 {
990
991 printf(
"Dead key data not supported!\n");
993 }
994
995
996 if (Layout->Entry[
j].LigatureCharData[
k])
997 {
998
999 printf(
"Ligature key data not supported!\n");
1001 }
1002
1003
1005 ",%-9s",
1006 WChName(Layout->Entry[
j].CharData[
k], 0));
1007
1008
1009 if (*LineBuffer !=
'\0')
strcpy(LineBuffer,
"WCH_NONE ");
1010 }
1011
1012
1014
1015
1016 if (*LineBuffer != '\0')
1017 {
1018
1020 continue;
1021 }
1022
1023
1024 if (Layout->Entry[
j].Cap != 2)
continue;
1025
1026
1027 printf(
"SGCAP not yet supported!\n");
1029 }
1030
1031
1033 {
1034
1036 " {VK_TAB ,0 ,'\\t' ,'\\t' },\n"
1037 " {VK_ADD ,0 ,'+' ,'+' },\n"
1038 " {VK_DIVIDE ,0 ,'/' ,'/' },\n"
1039 " {VK_MULTIPLY ,0 ,'*' ,'*' },\n"
1040 " {VK_SUBTRACT ,0 ,'-' ,'-' },\n");
1041 }
1042
1043
1046
1047
1049 }
1050
1051
1053 "// Put this last so that VkKeyScan interprets number characters\n"
1054 "// as coming from the main section of the kbd (aVkToWch2 and\n"
1055 "// aVkToWch5) before considering the numpad (aVkToWch1).\n\n"
1056 "static ALLOC_SECTION_LDATA VK_TO_WCHARS1 aVkToWch1[] = {\n"
1057 " { VK_NUMPAD0 , 0 , '0' },\n"
1058 " { VK_NUMPAD1 , 0 , '1' },\n"
1059 " { VK_NUMPAD2 , 0 , '2' },\n"
1060 " { VK_NUMPAD3 , 0 , '3' },\n"
1061 " { VK_NUMPAD4 , 0 , '4' },\n"
1062 " { VK_NUMPAD5 , 0 , '5' },\n"
1063 " { VK_NUMPAD6 , 0 , '6' },\n"
1064 " { VK_NUMPAD7 , 0 , '7' },\n"
1065 " { VK_NUMPAD8 , 0 , '8' },\n"
1066 " { VK_NUMPAD9 , 0 , '9' },\n"
1067 " { 0 , 0 , '\\0' }\n"
1068 "};\n\n");
1069
1070
1071 fprintf(
FileHandle,
"static ALLOC_SECTION_LDATA VK_TO_WCHAR_TABLE aVkToWcharTable[] = {\n");
1072
1073
1074 for (
i = 3;
i <= StateCount;
i++)
1075 {
1076
1078 " { (PVK_TO_WCHARS1)aVkToWch%d, %d, sizeof(aVkToWch%d[0]) },\n",
1082 }
1083
1084
1086 " { (PVK_TO_WCHARS1)aVkToWch2, 2, sizeof(aVkToWch2[0]) },\n"
1087 " { (PVK_TO_WCHARS1)aVkToWch1, 1, sizeof(aVkToWch1[0]) },\n"
1088 " { NULL, 0, 0 },\n"
1089 "};\n\n");
1090
1091
1093 "/***************************************************************************\\\n"
1094 "* aKeyNames[], aKeyNamesExt[] - Virtual Scancode to Key Name tables\n"
1095 "*\n"
1096 "* Table attributes: Ordered Scan (by scancode), null-terminated\n"
1097 "*\n"
1098 "* Only the names of Extended, NumPad, Dead and Non-Printable keys are here.\n"
1099 "* (Keys producing printable characters are named by that character)\n"
1100 "\\***************************************************************************/\n\n");
1101
1102
1103 if (KeyNameData)
1104 {
1105
1107
1108
1110
1111
1113 }
1114
1115
1116 if (KeyNameExtData)
1117 {
1118
1119 fprintf(
FileHandle,
"static ALLOC_SECTION_LDATA VSC_LPWSTR aKeyNamesExt[] = {\n");
1120
1121
1123
1124
1126 }
1127
1128
1129 if (KeyNameDeadData)
1130 {
1131
1132 printf(
"Dead key name data not supported!\n");
1134 }
1135
1136
1137 if (DeadKeyData)
1138 {
1139
1140 printf(
"Dead key data not supported!\n");
1142 }
1143
1144
1145 if (LigatureData)
1146 {
1147
1148 printf(
"Ligature key data not supported!\n");
1150 }
1151
1152
1154
1155
1156
1157
1159 "ALLOC_SECTION_LDATA KBDTABLES KbdTables%s = {\n"
1160 " /*\n"
1161 " * Modifier keys\n"
1162 " */\n"
1163 " &CharModifiers,\n\n"
1164 " /*\n"
1165 " * Characters tables\n"
1166 " */\n"
1167 " aVkToWcharTable,\n\n"
1168 " /*\n"
1169 " * Diacritics\n"
1170 " */\n",
1172
1173
1174 if (DeadKeyData)
1175 {
1177 }
1178 else
1179 {
1181 }
1182
1183
1185 " /*\n"
1186 " * Names of Keys\n"
1187 " */\n");
1188
1189
1190 if (KeyNameData)
1191 {
1193 }
1194 else
1195 {
1197 }
1198
1199
1200 if (KeyNameExtData)
1201 {
1203 }
1204 else
1205 {
1207 }
1208
1209
1210 if ((DeadKeyData) && (KeyNameDeadData))
1211 {
1213 }
1214 else
1215 {
1217 }
1218
1219
1221 " /*\n"
1222 " * Scan codes to Virtual Keys\n"
1223 " */\n"
1224 " ausVK,\n"
1225 " sizeof(ausVK) / sizeof(ausVK[0]),\n"
1226 " aE0VscToVk,\n"
1227 " aE1VscToVk,\n\n"
1228 " /*\n"
1229 " * Locale-specific special processing\n"
1230 " */\n");
1231
1232
1233
1234
1236
1237
1239
1240
1241 if (!LigatureData)
1242 {
1245 }
1246 else
1247 {
1250 }
1251
1252
1254
1255
1257 "PKBDTABLES KbdLayerDescriptor(VOID)\n"
1258 "{\n"
1259 " return &KbdTables;\n"
1260 "}\n");
1261
1262
1265}
char * strcat(char *DstString, const char *SrcString)
char * strcpy(char *DstString, const char *SrcString)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
PCHAR WChName(IN ULONG Char, IN BOOLEAN AddZero)
VOID PrintNameTable(FILE *FileHandle, PKEYNAME KeyName, BOOL DeadKey)
_Check_return_ _CRTIMP char *__cdecl asctime(_In_ const struct tm *_Tm)
base of all file and directory entries