public static void WriteKeymaps() { byte *table = (byte *)keymapArchive + 4; byte *buf = getBuiltinKeyMapBuffer; for (int x = 0; x < keymapEntries; ++x) { int tSize = 0; int error = 0; int strSize = 0; strSize = BinaryTool.ReadPrefixedString(table, buf, EntryModule.MaxKeyMapNameLength, &error); table += strSize; table += 2; // keymask/statebit // default table tSize = *(int *)table; table += 4; table += tSize; // shifted table tSize = *(int *)table; table += 4; table += tSize; // Write it out. TextMode.WriteLine(buf); } }
/// <summary> /// Gets the address of a builtin key map, by it's numeric ID. Good /// for iterating through the list of builtin key maps. /// </summary> public static void *GetBuiltinKeyMap(int id) { byte *table = (byte *)keymapArchive + 4; byte *buf = stackalloc byte [EntryModule.MaxKeyMapNameLength]; int error = 0; for (int x = 0; x < keymapEntries; ++x) { if (x == id) { return((void *)table); } // name-size (x), name string (x), keymask and statebit (2) table += 2 + BinaryTool.ReadPrefixedString(table, buf, EntryModule.MaxKeyMapNameLength, &error); // table size (4), default table (x) table += 4 + *(int *)table; // table size (4), shifted table (x) table += 4 + *(int *)table; } return(null); }
public static void ListKeyMaps() { int count = KeyMap.GetBuiltinKeyMapsCount(); byte *str = stackalloc byte [EntryModule.MaxKeyMapNameLength]; int error = 0; byte *keymap = null; int len = 0; TextMode.Write(count); TextMode.WriteLine(" available keymaps:"); for (int x = 0; x < count; ++x) { keymap = (byte *)KeyMap.GetBuiltinKeyMap(x); len = BinaryTool.ReadPrefixedString(keymap, str, EntryModule.MaxKeyMapNameLength, &error); TextMode.Write(" "); TextMode.WriteLine(str); } }
static void *GetBuiltinKeyMap(byte *name, int nameLen) { #if VERBOSE_KeyMap_INIT TextMode.Write("Key Map Name: "); TextMode.Write(name); TextMode.WriteLine(); TextMode.Write("Key Map Name Length: "); TextMode.Write(nameLen); TextMode.WriteLine(); #endif byte *table = (byte *)keymapArchive + 4; byte *ret_table; byte *buf = getBuiltinKeyMapBuffer; Diagnostics.Assert(nameLen > 0, "KeyMap.GetBuiltinKeyMap(): key map name is too small"); Diagnostics.Assert(nameLen <= EntryModule.MaxKeyMapNameLength, "KeyMap.GetBuiltinKeyMap(): key map name is too large"); for (int x = 0; x < keymapEntries; ++x) { int nSize = 0; int tSize = 0; int error = 0; int strSize = 0; strSize = BinaryTool.ReadPrefixedString(table, buf, EntryModule.MaxKeyMapNameLength, &error); table += strSize; nSize = ByteString.Length(buf); #if VERBOSE_KeyMap_INIT TextMode.Write("nsize: "); TextMode.Write(nSize); TextMode.WriteLine(); TextMode.Write("found keymap: "); TextMode.WriteLine(buf); #endif ret_table = table; table += 2; // keymask/statebit // default table tSize = *(int *)table; #if VERBOSE_KeyMap_INIT TextMode.Write("Default-table size:"); TextMode.Write(tSize); TextMode.WriteLine(""); #endif table += 4; table += tSize; // shifted table tSize = *(int *)table; #if VERBOSE_KeyMap_INIT TextMode.Write("Shifted-table size:"); TextMode.Write(tSize); TextMode.WriteLine(""); #endif table += 4; table += tSize; if (nSize == nameLen && ByteString.Compare(name, buf, nameLen) == 0) { return(ret_table); } } return(null); }