/// <summary>
        /// restore scan button mapping to point to named event 1
        /// </summary>
        void restoreKey()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            //change the scan button back to the original events
            if (iIdx != -1)
            {
                _usbKey = _OldUsbKey; //save for later restore
                addLog("scanbutton key index is " + iIdx.ToString());
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _usbKey.bIntScan = 1;
                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                    {
                        addLog("setKey for scanbutton key OK");
                    }
                    else
                    {
                        addLog("setKey for scanbutton key failed");
                    }
                }
                _cusb.writeKeyTables();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #2
0
 /// <summary>
 /// restore scan button mapping to point to named event 1
 /// </summary>
 public static void restoreKey()
 {
     ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
     ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
     int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);
     //change the scan button back to the original events
     if (iIdx != -1)
     {
         _usbKey = _OldUsbKey; //use saved var for restore
         addLog("scanbutton key index is " + iIdx.ToString());
         //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
         //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
         //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
         _usbKey.bIntScan = 1;
         for (int iPlane = 0; iPlane < _cusb.getNumPlanes(); iPlane++)
         {
             addLog("using plane: " + iPlane.ToString());
             if (_cusb.setKey(iPlane, _usbKey.bScanKey, _usbKey) == 0) //changed "setKey(0," to "setKey(i,"
                 addLog("setKey for scanbutton key OK");
             else
                 addLog("setKey for scanbutton key failed");
         }
         _cusb.writeKeyTables();
         mapAllSide2NOOP();                
     }
     else
     {
         addLog("Could not get index for scanbutton key");
     }
 }
Example #3
0
        /// <summary>
        /// change the event names of scanbutton to StateLeftScan1 and DeltaLeftScan1
        /// </summary>
        void mapScan2Enter()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();

            //get the index of the ENTER button and load keystruct
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKeyENTER = new CUSBkeys.usbKeyStruct();
            int iIdxEnter = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.Return, ref _usbKeyENTER);

            if (iIdxEnter != -1)
            { //we found the index
                addLog("ENTER key index is " + iIdxEnter.ToString());
                dumpKey(_usbKeyENTER);
                // 07,28,00,00,00,5A 'Return'  'Return'
            }

            //get the index of the scan button
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            //change the scan button to fire an ENTER
            if (iIdx != -1)
            {
                _iScanButtonIndex = iIdx;    //save for later use
                _OldUsbKey        = _usbKey; //save for later restore
                addLog("scanbutton key index is " + iIdx.ToString());
                dumpKey(_usbKey);
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                //_usbKey.bIntScan = 5; //change EventIndex to 5

                //change to a normal key with ENTER as
                _usbKey.bScanKey  = CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1;
                _usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.Silent | CUsbKeyTypes.usbFlagsMid.NoRepeat;
                _usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _usbKey.bIntScan  = 0x5A;// _usbKeyENTER.bIntScan;
                addLog("_usbKey after change to ENTER:");
                dumpKey(_usbKey);
                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                    {
                        addLog("setKey for scanbutton key OK");
                    }
                    else
                    {
                        addLog("setKey for scanbutton key failed");
                    }
                }
                _cusb.writeKeyTables();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #4
0
        /// <summary>
        /// change the event names of scanbutton to StateLeftScan1 and DeltaLeftScan1
        /// will also map all side buttons to scan
        /// </summary>
        public static void mapKey()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            //although we read the scan button setting here, we 'adjust' need to adjust it
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            //add two new events
            string sReg = ITC_KEYBOARD.CUSBkeys.getRegLocation();

            Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\State", true);
            reg.SetValue("Event5", "StateLeftScan1");
            reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\Delta", true);
            reg.SetValue("Event5", "DeltaLeftScan1");

            //change the scan button to fire these events
            if (iIdx != -1)
            {
                _OldUsbKey = _usbKey; //save for later restore
                //adjust the saved scan button:
                _OldUsbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _OldUsbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;
                _OldUsbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NamedEventIndex;
                _OldUsbKey.bIntScan  = 1;

                addLog("scanbutton key index is " + iIdx.ToString());

                //make a standard scan button
                _usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;
                _usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NamedEventIndex;
                _usbKey.bIntScan  = 5;  //let it point to our named Events

                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                    {
                        addLog("setKey for scanbutton key OK");
                    }
                    else
                    {
                        addLog("setKey for scanbutton key failed");
                    }
                }
                _cusb.writeKeyTables();
                _cusb = null;
                mapAllSide2SCAN();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #5
0
        /// <summary>
        /// change the event names of scanbutton to StateLeftScan1 and DeltaLeftScan1
        /// </summary>
        void mapScan2Enter()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            
            //get the index of the ENTER button and load keystruct
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKeyENTER = new CUSBkeys.usbKeyStruct();
            int iIdxEnter = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.Return, ref _usbKeyENTER);
            if (iIdxEnter != -1)
            { //we found the index
                addLog("ENTER key index is " + iIdxEnter.ToString());
                dumpKey(_usbKeyENTER);
                // 07,28,00,00,00,5A 'Return'  'Return'
            }
            
            //get the index of the scan button
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);
            //change the scan button to fire an ENTER
            if (iIdx != -1)
            {
                _iScanButtonIndex = iIdx; //save for later use
                _OldUsbKey = _usbKey; //save for later restore
                addLog("scanbutton key index is " + iIdx.ToString());
                dumpKey(_usbKey);
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                //_usbKey.bIntScan = 5; //change EventIndex to 5

                //change to a normal key with ENTER as 
                _usbKey.bScanKey = CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1;
                _usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.Silent | CUsbKeyTypes.usbFlagsMid.NoRepeat;
                _usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _usbKey.bIntScan = 0x5A;// _usbKeyENTER.bIntScan;
                addLog("_usbKey after change to ENTER:");
                dumpKey(_usbKey);
                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                        addLog("setKey for scanbutton key OK");
                    else
                        addLog("setKey for scanbutton key failed");
                }
                _cusb.writeKeyTables();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #6
0
        /// <summary>
        /// change the event names of scanbutton to StateLeftScan1 and DeltaLeftScan1
        /// </summary>
        public static void mapKey()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            //although we read the scan button setting here, we 'adjust' need to adjust it
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            //add two new events
            string sReg = ITC_KEYBOARD.CUSBkeys.getRegLocation();
            Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\State", true);
            reg.SetValue("Event5", "StateLeftScan1");
            reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\Delta", true);
            reg.SetValue("Event5", "DeltaLeftScan1");

            //change the scan button to fire these events
            if (iIdx != -1)
            {
                _OldUsbKey = _usbKey; //save for later restore
                //adjust the saved scan button:
                _OldUsbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _OldUsbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;
                _OldUsbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NamedEventIndex;
                _OldUsbKey.bIntScan = 1;

                addLog("scanbutton key index is " + iIdx.ToString());

                //make a standard scan button
                _usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;
                _usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NamedEventIndex;
                _usbKey.bIntScan = 5;   //let it point to our named Events

                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                        addLog("setKey for scanbutton key OK");
                    else
                        addLog("setKey for scanbutton key failed");
                }
                _cusb.writeKeyTables();
                _cusb = null;
                mapAllSide2SCAN();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #7
0
        private static void mapAllSide2NOOP()
        {
            //init the class
            ITC_KEYBOARD.CUSBkeys _cusbKeys = new ITC_KEYBOARD.CUSBkeys();

            //struct to hold key definition
            CUSBkeys.usbKeyStruct usbKey = new CUSBkeys.usbKeyStruct();

            //NORMAL Plane = 0x00
            //orange plane = 0x01
            //green/aqua plane = 0x02
            int iCount = _cusbKeys.getNumPlanes();

            for (int iPlane = 0; iPlane < iCount; iPlane++) //do for all planes
            {
                //remap F6 to NOOP
                //new use: _cusbKeys.getKeyStruct(iPlane, HardwareKeys.CK70Keys.ITC_Standard_UpperRight_Btn, ref usbKey);
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F6_VOL_UP, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F6_VOL_UP, usbKey);

                // F7
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F7_VOL_DN, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F7_VOL_DN, usbKey);

                //Side Scan button: dec145, 0x91
                _cusbKeys.getKeyStruct(iPlane, 0x91, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, 0x91, usbKey);

                //APP key: dec67, 0x43
                _cusbKeys.getKeyStruct(iPlane, 0x43, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, 0x43, usbKey);
            }
            _cusbKeys.writeKeyTables();
        }
        /// <summary>
        /// change the event names of scanbutton to StateLeftScan1 and DeltaLeftScan1
        /// </summary>
        void mapKey()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            //add two new events
            string sReg = ITC_KEYBOARD.CUSBkeys.getRegLocation();

            Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\State", true);
            reg.SetValue("Event5", "StateLeftScan1");
            reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\Delta", true);
            reg.SetValue("Event5", "DeltaLeftScan1");

            //change the scan button to fire these events
            if (iIdx != -1)
            {
                _OldUsbKey = _usbKey; //save for later restore
                addLog("scanbutton key index is " + iIdx.ToString());
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _usbKey.bIntScan = 5;
                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                    {
                        addLog("setKey for scanbutton key OK");
                    }
                    else
                    {
                        addLog("setKey for scanbutton key failed");
                    }
                }
                _cusb.writeKeyTables();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #9
0
        /// <summary>
        /// restore scan button mapping to point to named event 1
        /// </summary>
        public static void mapScanKey2Multi(byte b)
        {
            addLog("########### mapScanKey2Multi #################");
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            if (iIdx != -1)
            {
                _usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;//
                _usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.MultiKeyIndex;
                _usbKey.bIntScan  = b;

                addLog("scanbutton key index is " + iIdx.ToString());
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                for (int iPlane = 0; iPlane < _cusb.getNumPlanes(); iPlane++)
                {
                    addLog("using plane: " + iPlane.ToString());
                    if (_cusb.setKey(iPlane, _usbKey.bScanKey, _usbKey) == 0) //changed "setKey(0," to "setKey(i,"
                    {
                        addLog("setKey for scanbutton key OK");
                    }
                    else
                    {
                        addLog("setKey for scanbutton key failed");
                    }
                }
                _cusb.writeKeyTables();
                mapAllSide2NOOP();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
            addLog("----------- mapScanKey2Multi -----------------");
        }
Example #10
0
        /// <summary>
        /// restore scan button mapping to point to named event 1
        /// </summary>
        public static void restoreScanKeyDefault()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            //change the scan button back to the original events
            if (iIdx != -1)
            {
                _usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _usbKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NoRepeat;// | CUsbKeyTypes.usbFlagsMid.Silent;
                _usbKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NamedEventIndex;
                _usbKey.bIntScan  = 1;

                addLog("scanbutton key index is " + iIdx.ToString());
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _usbKey.bIntScan = 1;
                for (int iPlane = 0; iPlane < _cusb.getNumPlanes(); iPlane++)
                {
                    addLog("using plane: " + iPlane.ToString());
                    if (_cusb.setKey(iPlane, _usbKey.bScanKey, _usbKey) == 0) //changed "setKey(0," to "setKey(i,"
                    {
                        addLog("setKey for scanbutton key OK");
                    }
                    else
                    {
                        addLog("setKey for scanbutton key failed");
                    }
                }
                _cusb.writeKeyTables();
                mapAllSide2NOOP();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #11
0
        public static int createMultiKey()
        {
            addLog("########### createMultiKey #################");
            int iRet = -1;

            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            //get current keyboard mapping reg location
            string sReg = ITC_KEYBOARD.CUSBkeys.getRegLocation();

            //count Multikey entries, remember: Multikey numbering starts by 1 (not zero)!
            addLog("Opening subkey '" + sReg + "\\Multikeys'...");
            Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Multikeys", true);
            int iNumKeys = reg.ValueCount;

            addLog("Found " + iNumKeys.ToString() + " value entries");
            #region usbkeys
            //we need two entries in the last, new reg entry
            //one to fire a vkey:
            //one to fire an named event
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKeyVKEY = new CUSBkeys.usbKeyStruct();
            _usbKeyVKEY.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
            _usbKeyVKEY.bFlagMid  = CUsbKeyTypes.usbFlagsMid.VKEY | CUsbKeyTypes.usbFlagsMid.NoRepeat;
            _usbKeyVKEY.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NormalKey;
            _usbKeyVKEY.bIntScan  = (byte)ITC_KEYBOARD.VKEY.undef_0x88; //use vkey=0x88

            byte[] bytesVKey = { (byte)_usbKeyVKEY.bFlagHigh, (byte)_usbKeyVKEY.bFlagMid, (byte)_usbKeyVKEY.bFlagLow, (byte)_usbKeyVKEY.bIntScan };

            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKeyEVENT = new CUSBkeys.usbKeyStruct();
            _usbKeyEVENT.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
            _usbKeyEVENT.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.VKEY;
            _usbKeyEVENT.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NormalKey;
            _usbKeyEVENT.bIntScan  = 0x88;
            byte[] bytesEventKey = { (byte)_usbKeyEVENT.bFlagHigh, (byte)_usbKeyEVENT.bFlagMid, (byte)_usbKeyEVENT.bFlagLow, (byte)_usbKeyEVENT.bIntScan };


            byte[] bytesAll = new byte[bytesVKey.Length + bytesEventKey.Length];
            System.Buffer.BlockCopy(bytesVKey, 0, bytesAll, 0, bytesVKey.Length);
            System.Buffer.BlockCopy(bytesEventKey, 0, bytesAll, bytesVKey.Length, bytesEventKey.Length);
            #endregion
            //check if the mutlikey is already in place
            string sValueName = "Multi" + iNumKeys.ToString("");
            byte[] bValues    = null;
            try
            {
                bValues = (byte[])reg.GetValue(sValueName, null);
                addLog("GetValue last multikey ('" + sValueName + "') OK");
            }
            catch (Exception ex)
            {
                addLog("GetValue last multikey ('" + sValueName + "') failed" + ex.Message);
            }
            //write new mutlikey?
            if (bValues != null)
            {
                if (!compareBytes(bValues, bytesAll))
                {
                    //create a new entry
                    try
                    {
                        reg.SetValue("Multi" + (iNumKeys + 1).ToString(), bytesAll, Microsoft.Win32.RegistryValueKind.Binary);
                        addLog("Creating new multikey value OK: " + reg.ToString());
                    }
                    catch (Exception ex)
                    {
                        addLog("Creating new multikey value failed" + ex.Message);
                    }
                }
            }
            //change the scanner key to point to the new multikey index
            mapScanKey2Multi((byte)(iNumKeys + 1));
            addLog("----------- createMultiKey -----------------");
            reg.Close();
            return(iRet);
        }
Example #12
0
        /// <summary>
        /// read the scanbutton mapping and apply "Event Name 1" to all side buttons
        /// </summary>
        public static void mapAllSide2SCAN_Event1()
        {
            //init the class
            ITC_KEYBOARD.CUSBkeys _cusbKeys = new ITC_KEYBOARD.CUSBkeys();

            //struct to hold key definition
            CUSBkeys.usbKeyStruct usbKey = new CUSBkeys.usbKeyStruct();

            //NORMAL Plane = 0x00
            //orange plane = 0x01
            //green/aqua plane = 0x02
            int iCount = _cusbKeys.getNumPlanes();

            //struct to hold key definition
            CUSBkeys.usbKeyStruct usbScanKey = new CUSBkeys.usbKeyStruct();
            //get main scan button
            //int iIndex = _cusbKeys.getKeyIndex(0, (int)ITC_KEYBOARD.CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1 /*0x90*/);
            _cusbKeys.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref usbScanKey);

            //make a normal scan button
            usbScanKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
            usbScanKey.bFlagMid  = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;
            usbScanKey.bFlagLow  = CUsbKeyTypes.usbFlagsLow.NamedEventIndex;
            usbScanKey.bIntScan  = 1;                       //map to Delta/State-LeftScan Event 1

            for (int iPlane = 0; iPlane < iCount; iPlane++) //do for all planes
            {
                //remap F6 to SCAN
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F6_VOL_UP, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid  = usbScanKey.bFlagMid;
                usbKey.bFlagLow  = usbScanKey.bFlagLow;
                usbKey.bIntScan  = usbScanKey.bIntScan;
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F6_VOL_UP, usbKey);

                // F7
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F7_VOL_DN, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid  = usbScanKey.bFlagMid;
                usbKey.bFlagLow  = usbScanKey.bFlagLow;
                usbKey.bIntScan  = usbScanKey.bIntScan;
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F7_VOL_DN, usbKey);

                //Side Scan button: dec145, 0x91
                _cusbKeys.getKeyStruct(iPlane, 0x91, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid  = usbScanKey.bFlagMid;
                usbKey.bFlagLow  = usbScanKey.bFlagLow;
                usbKey.bIntScan  = usbScanKey.bIntScan;
                _cusbKeys.setKey(iPlane, 0x91, usbKey);

                //APP key: dec67, 0x43
                _cusbKeys.getKeyStruct(iPlane, 0x43, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid  = usbScanKey.bFlagMid;
                usbKey.bFlagLow  = usbScanKey.bFlagLow;
                usbKey.bIntScan  = usbScanKey.bIntScan;
                _cusbKeys.setKey(iPlane, 0x43, usbKey);
            }
            _cusbKeys.writeKeyTables();
        }
Example #13
0
        public static int createMultiKey()
        {
            addLog("########### createMultiKey #################");
            int iRet = -1;
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            //get current keyboard mapping reg location
            string sReg = ITC_KEYBOARD.CUSBkeys.getRegLocation();
            //count Multikey entries, remember: Multikey numbering starts by 1 (not zero)! 
            addLog("Opening subkey '" + sReg + "\\Multikeys'...");
            Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Multikeys", true);
            int iNumKeys = reg.ValueCount;
            addLog("Found " + iNumKeys.ToString() + " value entries");
            #region usbkeys
            //we need two entries in the last, new reg entry
            //one to fire a vkey: 
            //one to fire an named event
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKeyVKEY = new CUSBkeys.usbKeyStruct();
            _usbKeyVKEY.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
            _usbKeyVKEY.bFlagMid = CUsbKeyTypes.usbFlagsMid.VKEY | CUsbKeyTypes.usbFlagsMid.NoRepeat;
            _usbKeyVKEY.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
            _usbKeyVKEY.bIntScan = (byte)ITC_KEYBOARD.VKEY.undef_0x88; //use vkey=0x88

            byte[] bytesVKey = { (byte)_usbKeyVKEY.bFlagHigh, (byte)_usbKeyVKEY.bFlagMid, (byte)_usbKeyVKEY.bFlagLow, (byte)_usbKeyVKEY.bIntScan };
            
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKeyEVENT = new CUSBkeys.usbKeyStruct();
            _usbKeyEVENT.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
            _usbKeyEVENT.bFlagMid = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.VKEY;
            _usbKeyEVENT.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
            _usbKeyEVENT.bIntScan = 0x88;
            byte[] bytesEventKey = { (byte)_usbKeyEVENT.bFlagHigh, (byte)_usbKeyEVENT.bFlagMid, (byte)_usbKeyEVENT.bFlagLow, (byte)_usbKeyEVENT.bIntScan };


            byte[] bytesAll = new byte[bytesVKey.Length + bytesEventKey.Length];
            System.Buffer.BlockCopy(bytesVKey, 0, bytesAll, 0, bytesVKey.Length);
            System.Buffer.BlockCopy(bytesEventKey, 0, bytesAll, bytesVKey.Length, bytesEventKey.Length);
            #endregion
            //check if the mutlikey is already in place
            string sValueName = "Multi" + iNumKeys.ToString("");
            byte[] bValues=null;
            try
            {
                bValues = (byte[])reg.GetValue(sValueName, null);
                addLog("GetValue last multikey ('"+ sValueName + "') OK");
            }
            catch (Exception ex)
            {
                addLog("GetValue last multikey ('"+ sValueName + "') failed" + ex.Message);
            }
            //write new mutlikey?
            if(bValues!=null){
                if (!compareBytes(bValues, bytesAll))
                {
                    //create a new entry
                    try
                    {
                        reg.SetValue("Multi" + (iNumKeys+1).ToString(), bytesAll, Microsoft.Win32.RegistryValueKind.Binary);
                        addLog("Creating new multikey value OK: " + reg.ToString() );
                    }
                    catch (Exception ex)
                    {
                        addLog("Creating new multikey value failed" + ex.Message);
                    }
                }
            }
            //change the scanner key to point to the new multikey index
            mapScanKey2Multi((byte)(iNumKeys+1));
            addLog("----------- createMultiKey -----------------");
            reg.Close();
            return iRet;
        }
Example #14
0
        private static void mapAllSide2NOOP()
        {
            //init the class
            ITC_KEYBOARD.CUSBkeys _cusbKeys = new ITC_KEYBOARD.CUSBkeys();

            //struct to hold key definition
            CUSBkeys.usbKeyStruct usbKey = new CUSBkeys.usbKeyStruct();

            //NORMAL Plane = 0x00
            //orange plane = 0x01
            //green/aqua plane = 0x02
            int iCount = _cusbKeys.getNumPlanes();
            for (int iPlane = 0; iPlane < iCount; iPlane++) //do for all planes
            {
                //remap F6 to NOOP
                //new use: _cusbKeys.getKeyStruct(iPlane, HardwareKeys.CK70Keys.ITC_Standard_UpperRight_Btn, ref usbKey);
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F6_VOL_UP, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F6_VOL_UP, usbKey);

                // F7
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F7_VOL_DN, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F7_VOL_DN, usbKey);

                //Side Scan button: dec145, 0x91
                _cusbKeys.getKeyStruct(iPlane, 0x91, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, 0x91, usbKey);

                //APP key: dec67, 0x43
                _cusbKeys.getKeyStruct(iPlane, 0x43, ref usbKey);
                usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _cusbKeys.setKey(iPlane, 0x43, usbKey);

            }
            _cusbKeys.writeKeyTables();
        }
Example #15
0
        /*
            07,3F,00,02,02,01 'F6'  'F9' 'EventIndex'|'StateLeftScan'|'DeltaLeftScan
            07,40,00,02,02,01 'F7'  'F9' 'EventIndex'|'StateLeftScan'|'DeltaLeftScan
            07,43,00,02,02,01 'F10'  'F9' 'EventIndex'|'StateLeftScan'|'DeltaLeftScan
            07,91,00,02,02,01 'Keyboard Lang 2'  'F9' 'EventIndex'|'StateLeftScan'|'DeltaLeftScan
            07,90,00,02,02,01 'Keyboard Lang 1 (<SCAN>)'  'F9' 'EventIndex'|'StateLeftScan'|'DeltaLeftScan
        */
        /// <summary>
        /// read the scanbutton mapping and apply it to the side buttons
        /// </summary>
        private static void mapAllSide2SCAN()
        {
            //init the class
            ITC_KEYBOARD.CUSBkeys _cusbKeys = new ITC_KEYBOARD.CUSBkeys();

            //struct to hold key definition
            CUSBkeys.usbKeyStruct usbKey = new CUSBkeys.usbKeyStruct();

            //NORMAL Plane = 0x00
            //orange plane = 0x01
            //green/aqua plane = 0x02
            int iCount = _cusbKeys.getNumPlanes();

            //struct to hold key definition
            CUSBkeys.usbKeyStruct usbScanKey = new CUSBkeys.usbKeyStruct();
            //get main scan button 
            //int iIndex = _cusbKeys.getKeyIndex(0, (int)ITC_KEYBOARD.CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1 /*0x90*/);
            _cusbKeys.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref usbScanKey);

            //make a normal scan button
            usbScanKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
            usbScanKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;
            usbScanKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NamedEventIndex;
            usbScanKey.bIntScan = 5; //map to Event 5

            for (int iPlane = 0; iPlane < iCount; iPlane++) //do for all planes
            {
                //remap F6 to SCAN
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F6_VOL_UP, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid = usbScanKey.bFlagMid;
                usbKey.bFlagLow = usbScanKey.bFlagLow;
                usbKey.bIntScan = usbScanKey.bIntScan;
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F6_VOL_UP, usbKey);

                // F7
                _cusbKeys.getKeyStruct(iPlane, ITC_KEYBOARD.CUsbKeyTypes.HWkeys.F7_VOL_DN, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid = usbScanKey.bFlagMid;
                usbKey.bFlagLow = usbScanKey.bFlagLow;
                usbKey.bIntScan = usbScanKey.bIntScan; 
                _cusbKeys.setKey(iPlane, CUsbKeyTypes.HWkeys.F7_VOL_DN, usbKey);

                //Side Scan button: dec145, 0x91
                _cusbKeys.getKeyStruct(iPlane, 0x91, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid = usbScanKey.bFlagMid;
                usbKey.bFlagLow = usbScanKey.bFlagLow;
                usbKey.bIntScan = usbScanKey.bIntScan; 
                _cusbKeys.setKey(iPlane, 0x91, usbKey);

                //APP key: dec67, 0x43
                _cusbKeys.getKeyStruct(iPlane, 0x43, ref usbKey);
                usbKey.bFlagHigh = usbScanKey.bFlagHigh;
                usbKey.bFlagMid = usbScanKey.bFlagMid;
                usbKey.bFlagLow = usbScanKey.bFlagLow;
                usbKey.bIntScan = usbScanKey.bIntScan; 
                _cusbKeys.setKey(iPlane, 0x43, usbKey);

            }
            _cusbKeys.writeKeyTables();
        }
Example #16
0
        /// <summary>
        /// restore scan button mapping to point to named event 1
        /// </summary>
        void restoreScanKey()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);
            //change the scan button back to the original events
            if (iIdx != -1)
            {
                //idx should be the save value _iScanButtonIndex
                addLog("saved scanbutton key index is " + _iScanButtonIndex.ToString());

                _usbKey = _OldUsbKey; //restore saved key
                addLog("scanbutton key index is " + iIdx.ToString());
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _usbKey.bIntScan = 1;
                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                        addLog("setKey for scanbutton key OK");
                    else
                        addLog("setKey for scanbutton key failed");
                }
                _cusb.writeKeyTables();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
        /// <summary>
        /// change the event names of scanbutton to StateLeftScan1 and DeltaLeftScan1
        /// </summary>
        void mapKey()
        {
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);

            //add two new events
            string sReg = ITC_KEYBOARD.CUSBkeys.getRegLocation();
            Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\State", true);
            reg.SetValue("Event5", "StateLeftScan1");
            reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sReg + "\\Events\\Delta", true);
            reg.SetValue("Event5", "DeltaLeftScan1");

            //change the scan button to fire these events
            if (iIdx != -1)
            {
                _OldUsbKey = _usbKey; //save for later restore
                addLog("scanbutton key index is " + iIdx.ToString());
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                _usbKey.bIntScan = 5;
                for (int i = 0; i < _cusb.getNumPlanes(); i++)
                {
                    addLog("using plane: " + i.ToString());
                    if (_cusb.setKey(0, _usbKey.bScanKey, _usbKey) == 0)
                        addLog("setKey for scanbutton key OK");
                    else
                        addLog("setKey for scanbutton key failed");
                }
                _cusb.writeKeyTables();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
        }
Example #18
0
        /// <summary>
        /// restore scan button mapping to point to named event 1
        /// </summary>
        public static void mapScanKey2Multi(byte b)
        {
            addLog("########### mapScanKey2Multi #################");
            ITC_KEYBOARD.CUSBkeys _cusb = new ITC_KEYBOARD.CUSBkeys();
            ITC_KEYBOARD.CUSBkeys.usbKeyStruct _usbKey = new CUSBkeys.usbKeyStruct();
            int iIdx = _cusb.getKeyStruct(0, CUsbKeyTypes.HWkeys.SCAN_Button_KeyLang1, ref _usbKey);
            if (iIdx != -1)
            {
                _usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                _usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NoRepeat | CUsbKeyTypes.usbFlagsMid.Silent;//
                _usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.MultiKeyIndex;
                _usbKey.bIntScan = b;

                addLog("scanbutton key index is " + iIdx.ToString());
                //_usbKey.bFlagHigh = CUsbKeyTypes.usbFlagsHigh.NoFlag;
                //_usbKey.bFlagMid = CUsbKeyTypes.usbFlagsMid.NOOP;
                //_usbKey.bFlagLow = CUsbKeyTypes.usbFlagsLow.NormalKey;
                for (int iPlane = 0; iPlane < _cusb.getNumPlanes(); iPlane++)
                {
                    addLog("using plane: " + iPlane.ToString());
                    if (_cusb.setKey(iPlane, _usbKey.bScanKey, _usbKey) == 0) //changed "setKey(0," to "setKey(i,"
                        addLog("setKey for scanbutton key OK");
                    else
                        addLog("setKey for scanbutton key failed");
                }
                _cusb.writeKeyTables();
                mapAllSide2NOOP();
            }
            else
            {
                addLog("Could not get index for scanbutton key");
            }
            addLog("----------- mapScanKey2Multi -----------------");
        }