예제 #1
0
 public void InitKeyboard()
 {
     KeyMap = null;
     ClearUserKey();
     PreviousKey = 0;
     VKBackslash = Keys.OemBackslash;            //(byte)(VkKeyScan('\\' & 0xFF));
 }
예제 #2
0
 internal void CopyTo(TKeyMap dest)
 {
     System.Buffer.BlockCopy(Map, 0, dest.Map, 0, Map.Length);
     System.Buffer.BlockCopy(UserKeyPtr, 0, dest.UserKeyPtr, 0, UserKeyPtr.Length);
     System.Buffer.BlockCopy(UserKeyLen, 0, dest.UserKeyLen, 0, UserKeyLen.Length);
     BlockCopy(UserKeyStr, 0, dest.UserKeyStr, 0, UserKeyStr.Length);
     System.Buffer.BlockCopy(UserKeyType, 0, dest.UserKeyType, 0, UserKeyType.Length);
 }
예제 #3
0
파일: ttcmn.cs 프로젝트: h7ga40/PeachCamWin
 internal static void ChangeDefaultSet(TTTSet ts, TKeyMap km)
 {
     if ((ts != null) &&
         (String.Compare(ts.SetupFName, pm.ts.SetupFName, true) == 0))
     {
         ts.CopyTo(pm.ts);
     }
     if (km != null)
     {
         km.CopyTo(pm.km);
     }
 }
예제 #4
0
파일: ttcmn.cs 프로젝트: h7ga40/PeachCamWin
        internal static InternalKeyCodes GetKeyCode(TKeyMap KeyMap, ushort Scan)
        {
            InternalKeyCodes Key;

            if (KeyMap == null)
            {
                KeyMap = pm.km;
            }
            Key = InternalKeyCodes.IdKeyMax;
            while ((Key > 0) && (KeyMap.Map[(int)Key - 1] != Scan))
            {
                Key--;
            }
            return(Key);
        }
예제 #5
0
        public void SetKeyMap()
        {
            string TempDir;
            string TempName;

#if SHARED_KEYMAP
            if (String.IsNullOrEmpty(ts.KeyCnfFN))
            {
                return;
            }
#else
            /*
             * if (String.IsNullOrEmpty(ts.KeyCnfFN)) {
             *      if ( KeyMap != null ) {
             *              return;
             *      }
             *      ts.KeyCnfFN = "KEYBOARD.CNF";
             * }
             */
#endif
            TempName = Path.GetFileName(ts.KeyCnfFN);
            TempDir  = Path.GetDirectoryName(ts.KeyCnfFN);
            if (String.IsNullOrEmpty(TempDir))
            {
                TempDir = ts.HomeDir;
            }
            TempName = Path.ChangeExtension(TempName, ".CNF");

            ts.KeyCnfFN = Path.Combine(TempDir, TempName);

            if (KeyMap == null)
            {
                KeyMap = new TKeyMap();
            }
            if (KeyMap != null)
            {
                ttset.ReadKeyboardCnf(ts.KeyCnfFN, KeyMap, true);
                //ttset.FreeTTSET();
            }
#if SHARED_KEYMAP
            if ((TempDir == ts.HomeDir) &&
                (TempName == "KEYBOARD.CNF"))
            {
                ttcmn.ChangeDefaultSet(null, KeyMap);
                KeyMap = null;
            }
#endif
        }
예제 #6
0
        static void GetInt(TKeyMap KeyMap, InternalKeyCodes KeyId, string Sect, string Key, string FName)
        {
            char[] Buf = new char[11];
            string Temp;
            ushort Num;

            //GetPrivateProfileString(Sect, Key, "", Buf, Buf.Length, FName);
            Temp = null;            // new String(Buf);
            if (String.IsNullOrEmpty(Temp))
            {
                Num = 0xFFFF;
            }
            else if (String.Compare(Temp, "off", true) == 0)
            {
                Num = 0xFFFF;
            }
            else if (!UInt16.TryParse(Temp, out Num))
            {
                Num = 0xFFFF;
            }

            KeyMap.Map[(int)KeyId - 1] = Num;
        }
예제 #7
0
파일: ttcmn.cs 프로젝트: h7ga40/PeachCamWin
        internal static void GetKeyStr(Control HWin, TKeyMap KeyMap, InternalKeyCodes KeyCode,
                                       bool AppliKeyMode, bool AppliCursorMode, bool Send8BitMode, byte[] KeyStr, int destlen,
                                       ref int Len, ref keyTypeIds Type)
        {
            MSG Msg = new MSG();

            char[] Temp = new char[201];

            if (KeyMap == null)
            {
                KeyMap = new TKeyMap();
                pm.km.CopyTo(KeyMap);
            }

            Type = keyTypeIds.IdBinary;              // key type
            Len  = 0;
            switch (KeyCode)
            {
            case InternalKeyCodes.IdUp:
                if (Send8BitMode)
                {
                    Len = 2;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\xb9A");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x9bA");
                    }
                }
                else
                {
                    Len = 3;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\x1bOA");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x1b[A");
                    }
                }
                break;

            case InternalKeyCodes.IdDown:
                if (Send8BitMode)
                {
                    Len = 2;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\xb9B");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x9bB");
                    }
                }
                else
                {
                    Len = 3;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\x1bOB");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x1b[B");
                    }
                }
                break;

            case InternalKeyCodes.IdRight:
                if (Send8BitMode)
                {
                    Len = 2;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\xb9C");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x9bC");
                    }
                }
                else
                {
                    Len = 3;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\x1bOC");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x1b[C");
                    }
                }
                break;

            case InternalKeyCodes.IdLeft:
                if (Send8BitMode)
                {
                    Len = 2;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\xb9D");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x9bD");
                    }
                }
                else
                {
                    Len = 3;
                    if (AppliCursorMode)
                    {
                        strncpy_s(KeyStr, destlen, "\x1bOD");
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, "\x1b[D");
                    }
                }
                break;

            case InternalKeyCodes.Id0:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9p");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOp");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'0';
                }
                break;

            case InternalKeyCodes.Id1:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9q");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOq");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'1';
                }
                break;

            case InternalKeyCodes.Id2:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9r");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOr");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'2';
                }
                break;

            case InternalKeyCodes.Id3:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9s");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOs");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'3';
                }
                break;

            case InternalKeyCodes.Id4:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9t");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOt");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'4';
                }
                break;

            case InternalKeyCodes.Id5:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9u");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOu");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'5';
                }
                break;

            case InternalKeyCodes.Id6:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9v");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOv");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'6';
                }
                break;

            case InternalKeyCodes.Id7:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9w");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOw");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'7';
                }
                break;

            case InternalKeyCodes.Id8:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9x");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOx");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'8';
                }
                break;

            case InternalKeyCodes.Id9:
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9y");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOy");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'9';
                }
                break;

            case InternalKeyCodes.IdMinus:             /* numeric pad - key (DEC) */
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9m");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOm");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'-';
                }
                break;

            case InternalKeyCodes.IdComma:             /* numeric pad , key (DEC) */
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9l");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOl");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)',';
                }
                break;

            case InternalKeyCodes.IdPeriod:             /* numeric pad . key */
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9n");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOn");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'.';
                }
                break;

            case InternalKeyCodes.IdEnter:             /* numeric pad enter key */
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9M");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOM");
                    }
                }
                else
                {
                    Type      = keyTypeIds.IdText;                // do new-line conversion
                    Len       = 1;
                    KeyStr[0] = 0x0D;
                }
                break;

            case InternalKeyCodes.IdSlash:             /* numeric pad slash key */
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9o");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOo");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'/';
                }
                break;

            case InternalKeyCodes.IdAsterisk:             /* numeric pad asterisk key */
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9j");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOj");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'*';
                }
                break;

            case InternalKeyCodes.IdPlus:             /* numeric pad plus key */
                if (AppliKeyMode)
                {
                    if (Send8BitMode)
                    {
                        Len = 2;
                        strncpy_s(KeyStr, destlen, "\xb9k");
                    }
                    else
                    {
                        Len = 3;
                        strncpy_s(KeyStr, destlen, "\x1bOk");
                    }
                }
                else
                {
                    Len       = 1;
                    KeyStr[0] = (byte)'+';
                }
                break;

            case InternalKeyCodes.IdPF1:             /* DEC Key: PF1 */
                if (Send8BitMode)
                {
                    Len = 2;
                    strncpy_s(KeyStr, destlen, "\xb9P");
                }
                else
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x1bOP");
                }
                break;

            case InternalKeyCodes.IdPF2:             /* DEC Key: PF2 */
                if (Send8BitMode)
                {
                    Len = 2;
                    strncpy_s(KeyStr, destlen, "\xb9Q");
                }
                else
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x1bOQ");
                }
                break;

            case InternalKeyCodes.IdPF3:             /* DEC Key: PF3 */
                if (Send8BitMode)
                {
                    Len = 2;
                    strncpy_s(KeyStr, destlen, "\xb9R");
                }
                else
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x1bOR");
                }
                break;

            case InternalKeyCodes.IdPF4:             /* DEC Key: PF4 */
                if (Send8BitMode)
                {
                    Len = 2;
                    strncpy_s(KeyStr, destlen, "\xb9S");
                }
                else
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x1bOS");
                }
                break;

            case InternalKeyCodes.IdFind:             /* DEC Key: Find */
                if (Send8BitMode)
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x9b1~");
                }
                else
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x1b[1~");
                }
                break;

            case InternalKeyCodes.IdInsert:             /* DEC Key: Insert Here */
                if (Send8BitMode)
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x9b2~");
                }
                else
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x1b[2~");
                }
                break;

            case InternalKeyCodes.IdRemove:             /* DEC Key: Remove */
                if (Send8BitMode)
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x9b3~");
                }
                else
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x1b[3~");
                }
                break;

            case InternalKeyCodes.IdSelect:             /* DEC Key: Select */
                if (Send8BitMode)
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x9b4~");
                }
                else
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x1b[4~");
                }
                break;

            case InternalKeyCodes.IdPrev:             /* DEC Key: Prev */
                if (Send8BitMode)
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x9b5~");
                }
                else
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x1b[5~");
                }
                break;

            case InternalKeyCodes.IdNext:             /* DEC Key: Next */
                if (Send8BitMode)
                {
                    Len = 3;
                    strncpy_s(KeyStr, destlen, "\x9b6~");
                }
                else
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x1b[6~");
                }
                break;

            case InternalKeyCodes.IdF6:             /* DEC Key: F6 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b17~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[17~");
                }
                break;

            case InternalKeyCodes.IdF7:             /* DEC Key: F7 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b18~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[18~");
                }
                break;

            case InternalKeyCodes.IdF8:             /* DEC Key: F8 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b19~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[19~");
                }
                break;

            case InternalKeyCodes.IdF9:             /* DEC Key: F9 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b20~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[20~");
                }
                break;

            case InternalKeyCodes.IdF10:             /* DEC Key: F10 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b21~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[21~");
                }
                break;

            case InternalKeyCodes.IdF11:             /* DEC Key: F11 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b23~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[23~");
                }
                break;

            case InternalKeyCodes.IdF12:             /* DEC Key: F12 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b24~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[24~");
                }
                break;

            case InternalKeyCodes.IdF13:             /* DEC Key: F13 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b25~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[25~");
                }
                break;

            case InternalKeyCodes.IdF14:             /* DEC Key: F14 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b26~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[26~");
                }
                break;

            case InternalKeyCodes.IdHelp:             /* DEC Key: Help */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b28~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[28~");
                }
                break;

            case InternalKeyCodes.IdDo:             /* DEC Key: Do */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b29~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[29~");
                }
                break;

            case InternalKeyCodes.IdF17:             /* DEC Key: F17 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b31~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[31~");
                }
                break;

            case InternalKeyCodes.IdF18:             /* DEC Key: F18 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b32~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[32~");
                }
                break;

            case InternalKeyCodes.IdF19:             /* DEC Key: F19 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b33~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[33~");
                }
                break;

            case InternalKeyCodes.IdF20:             /* DEC Key: F20 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b34~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[34~");
                }
                break;

            case InternalKeyCodes.IdXF1:             /* XTERM F1 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b11~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[11~");
                }
                break;

            case InternalKeyCodes.IdXF2:             /* XTERM F2 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b12~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[12~");
                }
                break;

            case InternalKeyCodes.IdXF3:             /* XTERM F3 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b13~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[13~");
                }
                break;

            case InternalKeyCodes.IdXF4:             /* XTERM F4 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b14~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[14~");
                }
                break;

            case InternalKeyCodes.IdXF5:             /* XTERM F5 */
                if (Send8BitMode)
                {
                    Len = 4;
                    strncpy_s(KeyStr, destlen, "\x9b15~");
                }
                else
                {
                    Len = 5;
                    strncpy_s(KeyStr, destlen, "\x1b[15~");
                }
                break;

            case InternalKeyCodes.IdHold:
            case InternalKeyCodes.IdPrint:
            case InternalKeyCodes.IdBreak:
            case InternalKeyCodes.IdCmdEditCopy:
            case InternalKeyCodes.IdCmdEditPaste:
            case InternalKeyCodes.IdCmdEditPasteCR:
            case InternalKeyCodes.IdCmdEditCLS:
            case InternalKeyCodes.IdCmdEditCLB:
            case InternalKeyCodes.IdCmdCtrlOpenTEK:
            case InternalKeyCodes.IdCmdCtrlCloseTEK:
            case InternalKeyCodes.IdCmdLineUp:
            case InternalKeyCodes.IdCmdLineDown:
            case InternalKeyCodes.IdCmdPageUp:
            case InternalKeyCodes.IdCmdPageDown:
            case InternalKeyCodes.IdCmdBuffTop:
            case InternalKeyCodes.IdCmdBuffBottom:
            case InternalKeyCodes.IdCmdNextWin:
            case InternalKeyCodes.IdCmdPrevWin:
            case InternalKeyCodes.IdCmdNextSWin:
            case InternalKeyCodes.IdCmdPrevSWin:
            case InternalKeyCodes.IdCmdLocalEcho:
            case InternalKeyCodes.IdScrollLock:
                VTWindow.PostMessage(HWin.Handle, tttypes.WM_USER_ACCELCOMMAND, new IntPtr((int)KeyCode), IntPtr.Zero);
                break;

            default:
                if ((KeyCode >= InternalKeyCodes.IdUser1) && (KeyCode <= InternalKeyCodes.IdKeyMax))
                {
                    Type      = (keyTypeIds)KeyMap.UserKeyType[KeyCode - InternalKeyCodes.IdUser1];                // key type
                    Len       = KeyMap.UserKeyLen[KeyCode - InternalKeyCodes.IdUser1];
                    Temp      = KeyMap.UserKeyStr[KeyMap.UserKeyPtr[KeyCode - InternalKeyCodes.IdUser1]].ToCharArray();
                    Temp[Len] = '\0';
                    if ((Type == keyTypeIds.IdBinary) || (Type == keyTypeIds.IdText))
                    {
                        Len = ttlib.Hex2Str(Temp, KeyStr, destlen);
                    }
                    else
                    {
                        strncpy_s(KeyStr, destlen, new String(Temp));
                    }
                }
                else
                {
                    return;
                }
                break;
            }
            /* remove WM_CHAR message for used keycode */
            keyboard.PeekMessage(ref Msg, HWin.Handle, VTWindow.WM_CHAR, VTWindow.WM_CHAR, keyboard.PM_REMOVE);
        }
예제 #8
0
        internal static void ReadKeyboardCnf(string FName, TKeyMap KeyMap, bool ShowWarning)
        {
            int    i, j, Ptr;
            string EntName;
            string TempStr;
            string KStr;

            // clear key map
            for (i = 0; i <= (int)InternalKeyCodes.IdKeyMax - 1; i++)
            {
                KeyMap.Map[i] = 0xFFFF;
            }
            for (i = 0; i <= (int)InternalKeyCodes.NumOfUserKey - 1; i++)
            {
                KeyMap.UserKeyPtr[i] = 0;
                KeyMap.UserKeyLen[i] = 0;
            }

            // VT editor keypad
            GetInt(KeyMap, InternalKeyCodes.IdUp, VTEditor, "Up", FName);

            GetInt(KeyMap, InternalKeyCodes.IdDown, VTEditor, "Down", FName);

            GetInt(KeyMap, InternalKeyCodes.IdRight, VTEditor, "Right", FName);

            GetInt(KeyMap, InternalKeyCodes.IdLeft, VTEditor, "Left", FName);

            GetInt(KeyMap, InternalKeyCodes.IdFind, VTEditor, "Find", FName);

            GetInt(KeyMap, InternalKeyCodes.IdInsert, VTEditor, "Insert", FName);

            GetInt(KeyMap, InternalKeyCodes.IdRemove, VTEditor, "Remove", FName);

            GetInt(KeyMap, InternalKeyCodes.IdSelect, VTEditor, "Select", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPrev, VTEditor, "Prev", FName);

            GetInt(KeyMap, InternalKeyCodes.IdNext, VTEditor, "Next", FName);

            // VT numeric keypad
            GetInt(KeyMap, InternalKeyCodes.Id0, VTNumeric, "Num0", FName);

            GetInt(KeyMap, InternalKeyCodes.Id1, VTNumeric, "Num1", FName);

            GetInt(KeyMap, InternalKeyCodes.Id2, VTNumeric, "Num2", FName);

            GetInt(KeyMap, InternalKeyCodes.Id3, VTNumeric, "Num3", FName);

            GetInt(KeyMap, InternalKeyCodes.Id4, VTNumeric, "Num4", FName);

            GetInt(KeyMap, InternalKeyCodes.Id5, VTNumeric, "Num5", FName);

            GetInt(KeyMap, InternalKeyCodes.Id6, VTNumeric, "Num6", FName);

            GetInt(KeyMap, InternalKeyCodes.Id7, VTNumeric, "Num7", FName);

            GetInt(KeyMap, InternalKeyCodes.Id8, VTNumeric, "Num8", FName);

            GetInt(KeyMap, InternalKeyCodes.Id9, VTNumeric, "Num9", FName);

            GetInt(KeyMap, InternalKeyCodes.IdMinus, VTNumeric, "NumMinus", FName);

            GetInt(KeyMap, InternalKeyCodes.IdComma, VTNumeric, "NumComma", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPeriod, VTNumeric, "NumPeriod", FName);

            GetInt(KeyMap, InternalKeyCodes.IdEnter, VTNumeric, "NumEnter", FName);

            GetInt(KeyMap, InternalKeyCodes.IdSlash, VTNumeric, "NumSlash", FName);

            GetInt(KeyMap, InternalKeyCodes.IdAsterisk, VTNumeric, "NumAsterisk", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPlus, VTNumeric, "NumPlus", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPF1, VTNumeric, "PF1", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPF2, VTNumeric, "PF2", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPF3, VTNumeric, "PF3", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPF4, VTNumeric, "PF4", FName);

            // VT function keys
            GetInt(KeyMap, InternalKeyCodes.IdHold, VTFunction, "Hold", FName);

            GetInt(KeyMap, InternalKeyCodes.IdPrint, VTFunction, "Print", FName);

            GetInt(KeyMap, InternalKeyCodes.IdBreak, VTFunction, "Break", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF6, VTFunction, "F6", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF7, VTFunction, "F7", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF8, VTFunction, "F8", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF9, VTFunction, "F9", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF10, VTFunction, "F10", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF11, VTFunction, "F11", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF12, VTFunction, "F12", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF13, VTFunction, "F13", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF14, VTFunction, "F14", FName);

            GetInt(KeyMap, InternalKeyCodes.IdHelp, VTFunction, "Help", FName);

            GetInt(KeyMap, InternalKeyCodes.IdDo, VTFunction, "Do", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF17, VTFunction, "F17", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF18, VTFunction, "F18", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF19, VTFunction, "F19", FName);

            GetInt(KeyMap, InternalKeyCodes.IdF20, VTFunction, "F20", FName);

            // UDK
            GetInt(KeyMap, InternalKeyCodes.IdUDK6, VTFunction, "UDK6", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK7, VTFunction, "UDK7", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK8, VTFunction, "UDK8", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK9, VTFunction, "UDK9", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK10, VTFunction, "UDK10", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK11, VTFunction, "UDK11", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK12, VTFunction, "UDK12", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK13, VTFunction, "UDK13", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK14, VTFunction, "UDK14", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK15, VTFunction, "UDK15", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK16, VTFunction, "UDK16", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK17, VTFunction, "UDK17", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK18, VTFunction, "UDK18", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK19, VTFunction, "UDK19", FName);

            GetInt(KeyMap, InternalKeyCodes.IdUDK20, VTFunction, "UDK20", FName);

            // XTERM function keys
            GetInt(KeyMap, InternalKeyCodes.IdXF1, XFunction, "XF1", FName);

            GetInt(KeyMap, InternalKeyCodes.IdXF2, XFunction, "XF2", FName);

            GetInt(KeyMap, InternalKeyCodes.IdXF3, XFunction, "XF3", FName);

            GetInt(KeyMap, InternalKeyCodes.IdXF4, XFunction, "XF4", FName);

            GetInt(KeyMap, InternalKeyCodes.IdXF5, XFunction, "XF5", FName);

            // accelerator keys
            GetInt(KeyMap, InternalKeyCodes.IdCmdEditCopy, ShortCut, "EditCopy", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdEditPaste, ShortCut, "EditPaste", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdEditPasteCR, ShortCut, "EditPasteCR", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdEditCLS, ShortCut, "EditCLS", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdEditCLB, ShortCut, "EditCLB", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdCtrlOpenTEK, ShortCut, "ControlOpenTEK", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdCtrlCloseTEK, ShortCut, "ControlCloseTEK", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdLineUp, ShortCut, "LineUp", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdLineDown, ShortCut, "LineDown", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdPageUp, ShortCut, "PageUp", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdPageDown, ShortCut, "PageDown", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdBuffTop, ShortCut, "BuffTop", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdBuffBottom, ShortCut, "BuffBottom", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdNextWin, ShortCut, "NextWin", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdPrevWin, ShortCut, "PrevWin", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdNextSWin, ShortCut, "NextShownWin", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdPrevSWin, ShortCut, "PrevShownWin", FName);

            GetInt(KeyMap, InternalKeyCodes.IdCmdLocalEcho, ShortCut, "LocalEcho", FName);

            GetInt(KeyMap, InternalKeyCodes.IdScrollLock, ShortCut, "ScrollLock", FName);

            /* user keys */

            Ptr = 0;

            i = (int)InternalKeyCodes.IdUser1;
            do
            {
                EntName = String.Format("User{0}", i - InternalKeyCodes.IdUser1 + 1);
                //GetPrivateProfileString("User keys", EntName, "", TempStr, TempStr.Length, FName);
                TempStr = "";
                if (TempStr.Length > 0)
                {
                    /* scan code */
                    ttlib.GetNthString(TempStr, 1, out KStr);
                    if (String.Compare(KStr, "off", true) == 0)
                    {
                        KeyMap.Map[i - 1] = 0xFFFF;
                    }
                    else
                    {
                        ttlib.GetNthNum(TempStr, 1, out j);
                        KeyMap.Map[i - 1] = (ushort)j;
                    }
                    /* conversion flag */
                    ttlib.GetNthNum(TempStr, 2, out j);
                    KeyMap.UserKeyType[i - (int)InternalKeyCodes.IdUser1] = (byte)j;
                    /* key string */
                    /*	GetNthString(TempStr,3,KStr.Length,KStr); */
                    KeyMap.UserKeyPtr[i - (int)InternalKeyCodes.IdUser1] = Ptr;

                    /*	KeyMap.UserKeyLen[i-TeraTermInternalKeyCodes.IdUser1] =
                     *      Hex2Str(KStr,&(KeyMap.UserKeyStr[Ptr]),KeyStrMax-Ptr+1);
                     */
                    ttlib.GetNthString(TempStr, 3, out KeyMap.UserKeyStr[Ptr]);
                    KeyMap.UserKeyLen[i - (int)InternalKeyCodes.IdUser1] =
                        KeyMap.UserKeyStr[Ptr].Length;
                    Ptr = Ptr + KeyMap.UserKeyLen[i - (int)InternalKeyCodes.IdUser1];
                }

                i++;
            }while ((i <= (int)InternalKeyCodes.IdKeyMax) && (TempStr.Length > 0) && (Ptr <= (int)InternalKeyCodes.KeyStrMax));

            for (j = 1; j <= (int)InternalKeyCodes.IdKeyMax - 1; j++)
            {
                if (KeyMap.Map[j] != 0xFFFF)
                {
                    for (i = 0; i <= j - 1; i++)
                    {
                        if (KeyMap.Map[i] == KeyMap.Map[j])
                        {
                            if (ShowWarning)
                            {
                                TempStr = String.Format("Keycode {0} is used more than once", KeyMap.Map[j]);
                                MessageBox.Show(TempStr,
                                                "Tera Term: Error in keyboard setup file",
                                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            KeyMap.Map[i] = 0xFFFF;
                        }
                    }
                }
            }
        }