Ejemplo n.º 1
0
        public void closeTitanOneInterface()
        {
            if (_gcapi_Unload != null)
            {
                _gcapi_Unload();
            }

            _gcapi_LoadDevice    = null;
            _gcapi_Load          = null;
            _gcapi_IsConnected   = null;
            _gcapi_GetTimeVal    = null;
            _gcapi_GetFwVer      = null;
            _gcapi_Write         = null;
            _gcapi_WriteEx       = null;
            _gcapi_WriteRef      = null;
            _gcapi_Read_TO       = null;
            _gcapi_CalcPressTime = null;
            _gcapi_Unload        = null;
        }
Ejemplo n.º 2
0
        public void closeTitanOneInterface()
        {
            string strDevice = "TitanOne";
            string strRef    = "TODI";

            if (_gcapi_Unload != null)
            {
                _gcapi_Unload();
            }

            _gcapi_LoadDevice    = null;
            _gcapi_Load          = null;
            _gcapi_IsConnected   = null;
            _gcapi_GetTimeVal    = null;
            _gcapi_GetFwVer      = null;
            _gcapi_Write         = null;
            _gcapi_WriteEx       = null;
            _gcapi_WriteRef      = null;
            _gcapi_Read_TO       = null;
            _gcapi_CalcPressTime = null;
            _gcapi_Unload        = null;

            system.debug("titanOne.log", "[OK] Closed " + strDevice + " (" + strRef + ")");
        }
Ejemplo n.º 3
0
        public void initTitanOne()
        {
            //TODO: Read from setup menu
            _MenuShow = 35;

            var strDevice = "TitanOne";
            var strRef    = "TODI";
            var strAPI    = "titanOne_gcdapi.dll";

            system.debug("titanOne.log", "[0] Opening " + strDevice + " api");
            var strDir = Directory.GetCurrentDirectory() + @"\";

            _strTODevice = strDevice;

            if (File.Exists(strDir + strAPI) == false)
            {
                system.debug("titanOne.log", "[0] [FAIL] Unable to find " + strDevice + " API (" + strAPI + ")");
                return;
            }

            system.debug("titanOne.log", "[TRY] Attempting to open " + strDevice + " Device Interface (" + strRef + ")");

            var ptrDll = LoadLibrary(strDir + strAPI);

            if (ptrDll == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] Unable to allocate Device API");
                return;
            }

            var ptrLoad = loadExternalFunction(ptrDll, "gcdapi_Load");

            if (ptrLoad == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_Load"); return;
            }

            var ptrLoadDevice = loadExternalFunction(ptrDll, "gcdapi_LoadDevice");

            if (ptrLoadDevice == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_LoadDevice"); return;
            }

            var ptrIsConnected = loadExternalFunction(ptrDll, "gcapi_IsConnected");

            if (ptrIsConnected == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_IsConnected"); return;
            }

            var ptrUnload = loadExternalFunction(ptrDll, "gcdapi_Unload");

            if (ptrUnload == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_Unload"); return;
            }

            var ptrGetTimeVal = loadExternalFunction(ptrDll, "gcapi_GetTimeVal");

            if (ptrGetTimeVal == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_GetTimeVal"); return;
            }

            var ptrGetFwVer = loadExternalFunction(ptrDll, "gcapi_GetFWVer");

            if (ptrGetFwVer == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_GetFWVer"); return;
            }

            var ptrWrite = loadExternalFunction(ptrDll, "gcapi_Write");

            if (ptrWrite == IntPtr.Zero)
            {
                return;
            }

            var ptrRead = loadExternalFunction(ptrDll, "gcapi_Read");

            if (ptrRead == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_WriteEX"); return;
            }

            var ptrWriteEx = loadExternalFunction(ptrDll, "gcapi_WriteEX");

            if (ptrWriteEx == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_WriteEX"); return;
            }

            var ptrReadEx = loadExternalFunction(ptrDll, "gcapi_ReadEX");

            if (ptrReadEx == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_ReadEX"); return;
            }

            var ptrCalcPressTime = loadExternalFunction(ptrDll, "gcapi_CalcPressTime");

            if (ptrCalcPressTime == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] gcapi_CalcPressTime"); return;
            }

            try
            {
                system.debug("titanOne.log", "[5] Marshal _gcapi_Load");
                _gcapi_Load = (GCAPI_LOAD)Marshal.GetDelegateForFunctionPointer(ptrLoad, typeof(GCAPI_LOAD));

                system.debug("titanOne.log", "[5] Marshal _gcapi_LoadDevice");
                _gcapi_LoadDevice = (GCAPI_LOADDEVICE)Marshal.GetDelegateForFunctionPointer(ptrLoadDevice, typeof(GCAPI_LOADDEVICE));

                system.debug("titanOne.log", "[5] Marshal _gcapi_IsConnected");
                _gcapi_IsConnected = (GCAPI_ISCONNECTED)Marshal.GetDelegateForFunctionPointer(ptrIsConnected, typeof(GCAPI_ISCONNECTED));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Unload");
                _gcapi_Unload = (GCAPI_UNLOAD)Marshal.GetDelegateForFunctionPointer(ptrUnload, typeof(GCAPI_UNLOAD));

                system.debug("titanOne.log", "[5] Marshal _gcapi_GetTimeVal");
                _gcapi_GetTimeVal = (GCAPI_GETTIMEVAL)Marshal.GetDelegateForFunctionPointer(ptrGetTimeVal, typeof(GCAPI_GETTIMEVAL));

                system.debug("titanOne.log", "[5] Marshal _gcapi_GetFwVer");
                _gcapi_GetFwVer = (GCAPI_GETFWVER)Marshal.GetDelegateForFunctionPointer(ptrGetFwVer, typeof(GCAPI_GETFWVER));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Write");
                _gcapi_Write = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));

                system.debug("titanOne.log", "[5] Marshal _gcapi_CalcPressTime");
                _gcapi_CalcPressTime = (GCAPI_CALCPRESSTIME)Marshal.GetDelegateForFunctionPointer(ptrCalcPressTime, typeof(GCAPI_CALCPRESSTIME));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Write");
                _gcapi_Write = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));

                //TitanOne - modified DLL to accept LED / rumble feedback
                system.debug("titanOne.log", "[5] Marshal _gcapi_WriteEx");
                _gcapi_WriteEx = (GCAPI_WRITE_EX)Marshal.GetDelegateForFunctionPointer(ptrWriteEx, typeof(GCAPI_WRITE_EX));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Read_TO");
                _gcapi_Read_TO = (GCAPI_READ_TO)Marshal.GetDelegateForFunctionPointer(ptrReadEx, typeof(GCAPI_READ_TO));

                system.debug("titanOne.log", "[5] Marshall _gcapi_read_CM");
                _gcapi_Read_CM = (GCAPI_READ_CM)Marshal.GetDelegateForFunctionPointer(ptrReadEx, typeof(GCAPI_READ_CM));
            }
            catch (Exception ex)
            {
                system.debug("titanOne.log", "[0] Fail -> " + ex.ToString());
                system.debug("titanOne.log", "[0] [ERR] Critical failure loading " + _strTODevice + " API.");
                return;
            }

            //TODO: _devID should be set by now on startup
            system.debug("titanOne.log", ">>>" + _devId.ToString());
            if (_gcapi_LoadDevice((ushort)_devId) == 1)
            {
                system.debug("titanOne.log", "[0] Initialize " + _strTODevice + " GCAPI ok");
            }
            else
            {
                system.debug("titanOne.log", "[0] Initialize " + _strTODevice + " failed");
                return;
            }

            loadShortcutKeys();

            system.debug("titanOne.log", "");
        }
Ejemplo n.º 4
0
        public void initTitanOne()
        {
            var Dir = Directory.GetCurrentDirectory() + @"\";
            _strTODevice = strDevice;

            if (File.Exists(Dir + strAPI) == false)
                return;

            var ptrDll = LoadLibrary(strDir + strAPI);
            if (ptrDll == IntPtr.Zero) return;

            var ptrLoad = loadExternalFunction(ptrDll, "gcdapi_Load");
            if (ptrLoad == IntPtr.Zero) return;

            var ptrLoadDevice = loadExternalFunction(ptrDll, "gcdapi_LoadDevice");
            if (ptrLoadDevice == IntPtr.Zero) return;

            var ptrIsConnected = loadExternalFunction(ptrDll, "gcapi_IsConnected");
            if (ptrIsConnected == IntPtr.Zero) return;

            var ptrUnload = loadExternalFunction(ptrDll, "gcdapi_Unload");
            if (ptrUnload == IntPtr.Zero) return;

            var ptrGetTimeVal = loadExternalFunction(ptrDll, "gcapi_GetTimeVal");
            if (ptrGetTimeVal == IntPtr.Zero) return;

            var ptrGetFwVer = loadExternalFunction(ptrDll, "gcapi_GetFWVer");
            if (ptrGetFwVer == IntPtr.Zero) return;

            var ptrWrite = loadExternalFunction(ptrDll, "gcapi_Write");
            if (ptrWrite == IntPtr.Zero) return;

            var ptrRead = loadExternalFunction(ptrDll, "gcapi_Read");
            if (ptrRead == IntPtr.Zero) return;

            var ptrWriteEx = loadExternalFunction(ptrDll, "gcapi_WriteEX");
            if (ptrWriteEx == IntPtr.Zero) return;

            var ptrReadEx = loadExternalFunction(ptrDll, "gcapi_ReadEX");
            if (ptrReadEx == IntPtr.Zero) return;

            var ptrCalcPressTime = loadExternalFunction(ptrDll, "gcapi_CalcPressTime");
            if (ptrCalcPressTime == IntPtr.Zero) return;

            try
            {
                _gcapi_Load = (GCAPI_LOAD)Marshal.GetDelegateForFunctionPointer(ptrLoad, typeof(GCAPI_LOAD));
                _gcapi_LoadDevice = (GCAPI_LOADDEVICE)Marshal.GetDelegateForFunctionPointer(ptrLoadDevice, typeof(GCAPI_LOADDEVICE));
                _gcapi_IsConnected = (GCAPI_ISCONNECTED)Marshal.GetDelegateForFunctionPointer(ptrIsConnected, typeof(GCAPI_ISCONNECTED));
                _gcapi_Unload = (GCAPI_UNLOAD)Marshal.GetDelegateForFunctionPointer(ptrUnload, typeof(GCAPI_UNLOAD));
                _gcapi_GetTimeVal = (GCAPI_GETTIMEVAL)Marshal.GetDelegateForFunctionPointer(ptrGetTimeVal, typeof(GCAPI_GETTIMEVAL));
                _gcapi_GetFwVer = (GCAPI_GETFWVER)Marshal.GetDelegateForFunctionPointer(ptrGetFwVer, typeof(GCAPI_GETFWVER));
                _gcapi_Write = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));
                _gcapi_CalcPressTime = (GCAPI_CALCPRESSTIME)Marshal.GetDelegateForFunctionPointer(ptrCalcPressTime, typeof(GCAPI_CALCPRESSTIME));
                _gcapi_Write = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));
                _gcapi_WriteEx = (GCAPI_WRITE_EX)Marshal.GetDelegateForFunctionPointer(ptrWriteEx, typeof(GCAPI_WRITE_EX));
                _gcapi_Read_TO = (GCAPI_READ_TO)Marshal.GetDelegateForFunctionPointer(ptrReadEx, typeof(GCAPI_READ_TO));
            }
            catch (Exception ex)
            {
                return;
            }

            if (_gcapi_LoadDevice((ushort)_devId) != 1)
                return;
        }
Ejemplo n.º 5
0
        public void closeTitanOneInterface()
        {
            if (_gcapi_Unload != null)
                _gcapi_Unload();

            _gcapi_LoadDevice = null;
            _gcapi_Load = null;
            _gcapi_IsConnected = null;
            _gcapi_GetTimeVal = null;
            _gcapi_GetFwVer = null;
            _gcapi_Write = null;
            _gcapi_WriteEx = null;
            _gcapi_WriteRef = null;
            _gcapi_Read_TO = null;
            _gcapi_CalcPressTime = null;
            _gcapi_Unload = null;
        }
Ejemplo n.º 6
0
        public void initControllerMax()
        {
            //TODO: Read from setup menu
            _intMenuShow = 35;

            string strDevice = "ControllerMax";
            string strRef = "CMDI";
            string strAPI = "controllerMax_gcdapi.dll";

            _class.System.Debug("ControllerMax.log", "[0] Opening " + strDevice + " api");
            string strDir = Directory.GetCurrentDirectory() + @"\";
            _strCMDevice = strDevice;

            if (File.Exists(strDir + strAPI) == false)
            {
                _class.System.Debug("ControllerMax.log", "[0] [FAIL] Unable to find " + strDevice + " API");
                return;
            }

            _class.System.Debug("ControllerMax.log", "[TRY] Attempting to open " + strDevice + " Device Interface (" + strRef + ")");

            IntPtr ptrDll = LoadLibrary(strDir + strAPI);
            if (ptrDll == IntPtr.Zero)
            {
                _class.System.Debug("ControllerMax.log", "[0] [FAIL] Unable to allocate Device API");
                return;
            }

            IntPtr ptrLoad = loadExternalFunction(ptrDll, "gcdapi_Load");
            if (ptrLoad == IntPtr.Zero) { _class.System.Debug("ControllerMax.log", "[0] [FAIL] gcapi_Load"); return; }

            IntPtr ptrIsConnected = loadExternalFunction(ptrDll, "gcapi_IsConnected");
            if (ptrIsConnected == IntPtr.Zero) { _class.System.Debug("ControllerMax.log", "[0] [FAIL] gcapi_IsConnected"); return; }

            IntPtr ptrUnload = loadExternalFunction(ptrDll, "gcdapi_Unload");
            if (ptrUnload == IntPtr.Zero) { _class.System.Debug("ControllerMax.log", "[0] [FAIL] gcapi_Unload"); return; }

            IntPtr ptrGetTimeVal = loadExternalFunction(ptrDll, "gcapi_GetTimeVal");
            if (ptrGetTimeVal == IntPtr.Zero) { _class.System.Debug("ControllerMax.log", "[0] [FAIL] gcapi_GetTimeVal"); return; }

            IntPtr ptrGetFwVer = loadExternalFunction(ptrDll, "gcapi_GetFWVer");
            if (ptrGetFwVer == IntPtr.Zero) { _class.System.Debug("ControllerMax.log", "[0] [FAIL] gcapi_GetFWVer"); return; }

            IntPtr ptrWrite = loadExternalFunction(ptrDll, "gcapi_Write");
            if (ptrWrite == IntPtr.Zero) return;

            IntPtr ptrRead = loadExternalFunction(ptrDll, "gcapi_Read");
            if (ptrRead == IntPtr.Zero) return;

            IntPtr ptrWriteEx = IntPtr.Zero;
            IntPtr ptrReadEx = IntPtr.Zero;

            IntPtr ptrCalcPressTime = loadExternalFunction(ptrDll, "gcapi_CalcPressTime");
            if (ptrCalcPressTime == IntPtr.Zero) { _class.System.Debug("ControllerMax.log", "[0] [FAIL] gcapi_CalcPressTime"); return; }

            try
            {
                _gcapi_Load = (GCAPI_LOAD)Marshal.GetDelegateForFunctionPointer(ptrLoad, typeof(GCAPI_LOAD));
                _gcapi_IsConnected = (GCAPI_ISCONNECTED)Marshal.GetDelegateForFunctionPointer(ptrIsConnected, typeof(GCAPI_ISCONNECTED));
                _gcapi_Unload = (GCAPI_UNLOAD)Marshal.GetDelegateForFunctionPointer(ptrUnload, typeof(GCAPI_UNLOAD));
                _gcapi_GetTimeVal = (GCAPI_GETTIMEVAL)Marshal.GetDelegateForFunctionPointer(ptrGetTimeVal, typeof(GCAPI_GETTIMEVAL));
                _gcapi_GetFwVer = (GCAPI_GETFWVER)Marshal.GetDelegateForFunctionPointer(ptrGetFwVer, typeof(GCAPI_GETFWVER));
                _gcapi_Write = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));
                _gcapi_Read_CM = (GCAPI_READ_CM)Marshal.GetDelegateForFunctionPointer(ptrRead, typeof(GCAPI_READ_CM));
                _gcapi_CalcPressTime = (GCAPI_CALCPRESSTIME)Marshal.GetDelegateForFunctionPointer(ptrCalcPressTime, typeof(GCAPI_CALCPRESSTIME));
            }
            catch (Exception ex)
            {
                _class.System.Debug("ControllerMax.log", "[0] Fail -> " + ex.ToString());
            }

            _gcapi_Load();
            _class.System.Debug("ControllerMax.log", "[0] Initialize ControllerMax GCAPI ok");

            loadShortcutKeys();
            _boolGCAPILoaded = true;
        }
Ejemplo n.º 7
0
        public void closeControllerMaxInterface()
        {
            string strDevice = "ControllerMax";
            string strRef = "CMDI";

            if (_gcapi_Unload != null)
                _gcapi_Unload();

            _gcapi_Load = null;
            _gcapi_IsConnected = null;
            _gcapi_GetTimeVal = null;
            _gcapi_GetFwVer = null;
            _gcapi_Write = null;
            _gcapi_WriteEx = null;
            _gcapi_WriteRef = null;
            _gcapi_Read_CM = null;
            _gcapi_CalcPressTime = null;
            _gcapi_Unload = null;

            _boolGCAPILoaded = false;

            _class.System.Debug("ControllerMax.log", "[OK] Closed " + strDevice + " (" + strRef + ")");
        }
Ejemplo n.º 8
0
        public void initTitanOne()
        {
            var Dir = Directory.GetCurrentDirectory() + @"\";

            _strTODevice = strDevice;

            if (File.Exists(Dir + strAPI) == false)
            {
                return;
            }

            var ptrDll = LoadLibrary(strDir + strAPI);

            if (ptrDll == IntPtr.Zero)
            {
                return;
            }

            var ptrLoad = loadExternalFunction(ptrDll, "gcdapi_Load");

            if (ptrLoad == IntPtr.Zero)
            {
                return;
            }

            var ptrLoadDevice = loadExternalFunction(ptrDll, "gcdapi_LoadDevice");

            if (ptrLoadDevice == IntPtr.Zero)
            {
                return;
            }

            var ptrIsConnected = loadExternalFunction(ptrDll, "gcapi_IsConnected");

            if (ptrIsConnected == IntPtr.Zero)
            {
                return;
            }

            var ptrUnload = loadExternalFunction(ptrDll, "gcdapi_Unload");

            if (ptrUnload == IntPtr.Zero)
            {
                return;
            }

            var ptrGetTimeVal = loadExternalFunction(ptrDll, "gcapi_GetTimeVal");

            if (ptrGetTimeVal == IntPtr.Zero)
            {
                return;
            }

            var ptrGetFwVer = loadExternalFunction(ptrDll, "gcapi_GetFWVer");

            if (ptrGetFwVer == IntPtr.Zero)
            {
                return;
            }

            var ptrWrite = loadExternalFunction(ptrDll, "gcapi_Write");

            if (ptrWrite == IntPtr.Zero)
            {
                return;
            }

            var ptrRead = loadExternalFunction(ptrDll, "gcapi_Read");

            if (ptrRead == IntPtr.Zero)
            {
                return;
            }

            var ptrWriteEx = loadExternalFunction(ptrDll, "gcapi_WriteEX");

            if (ptrWriteEx == IntPtr.Zero)
            {
                return;
            }

            var ptrReadEx = loadExternalFunction(ptrDll, "gcapi_ReadEX");

            if (ptrReadEx == IntPtr.Zero)
            {
                return;
            }

            var ptrCalcPressTime = loadExternalFunction(ptrDll, "gcapi_CalcPressTime");

            if (ptrCalcPressTime == IntPtr.Zero)
            {
                return;
            }

            try
            {
                _gcapi_Load          = (GCAPI_LOAD)Marshal.GetDelegateForFunctionPointer(ptrLoad, typeof(GCAPI_LOAD));
                _gcapi_LoadDevice    = (GCAPI_LOADDEVICE)Marshal.GetDelegateForFunctionPointer(ptrLoadDevice, typeof(GCAPI_LOADDEVICE));
                _gcapi_IsConnected   = (GCAPI_ISCONNECTED)Marshal.GetDelegateForFunctionPointer(ptrIsConnected, typeof(GCAPI_ISCONNECTED));
                _gcapi_Unload        = (GCAPI_UNLOAD)Marshal.GetDelegateForFunctionPointer(ptrUnload, typeof(GCAPI_UNLOAD));
                _gcapi_GetTimeVal    = (GCAPI_GETTIMEVAL)Marshal.GetDelegateForFunctionPointer(ptrGetTimeVal, typeof(GCAPI_GETTIMEVAL));
                _gcapi_GetFwVer      = (GCAPI_GETFWVER)Marshal.GetDelegateForFunctionPointer(ptrGetFwVer, typeof(GCAPI_GETFWVER));
                _gcapi_Write         = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));
                _gcapi_CalcPressTime = (GCAPI_CALCPRESSTIME)Marshal.GetDelegateForFunctionPointer(ptrCalcPressTime, typeof(GCAPI_CALCPRESSTIME));
                _gcapi_Write         = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));
                _gcapi_WriteEx       = (GCAPI_WRITE_EX)Marshal.GetDelegateForFunctionPointer(ptrWriteEx, typeof(GCAPI_WRITE_EX));
                _gcapi_Read_TO       = (GCAPI_READ_TO)Marshal.GetDelegateForFunctionPointer(ptrReadEx, typeof(GCAPI_READ_TO));
            }
            catch (Exception ex)
            {
                return;
            }


            if (_gcapi_LoadDevice((ushort)_devId) != 1)
            {
                return;
            }
        }
Ejemplo n.º 9
0
        public void initTitanOne()
        {
            //TODO: Read from setup menu
            _MenuShow = 35;

            var strDevice = "TitanOne";
            var strRef = "TODI";
            var strAPI = "titanOne_gcdapi.dll";

            system.debug("titanOne.log", "[0] Opening " + strDevice + " api");
            var strDir = Directory.GetCurrentDirectory() + @"\";
            _strTODevice = strDevice;

            if (File.Exists(strDir + strAPI) == false)
            {
                system.debug("titanOne.log", "[0] [FAIL] Unable to find " + strDevice + " API (" + strAPI + ")");
                return;
            }

            system.debug("titanOne.log", "[TRY] Attempting to open " + strDevice + " Device Interface (" + strRef + ")");

            var ptrDll = LoadLibrary(strDir + strAPI);
            if (ptrDll == IntPtr.Zero)
            {
                system.debug("titanOne.log", "[0] [FAIL] Unable to allocate Device API");
                return;
            }

            var ptrLoad = loadExternalFunction(ptrDll, "gcdapi_Load");
            if (ptrLoad == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_Load"); return; }

            var ptrLoadDevice = loadExternalFunction(ptrDll, "gcdapi_LoadDevice");
            if (ptrLoadDevice == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_LoadDevice"); return; }

            var ptrIsConnected = loadExternalFunction(ptrDll, "gcapi_IsConnected");
            if (ptrIsConnected == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_IsConnected"); return; }

            var ptrUnload = loadExternalFunction(ptrDll, "gcdapi_Unload");
            if (ptrUnload == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_Unload"); return; }

            var ptrGetTimeVal = loadExternalFunction(ptrDll, "gcapi_GetTimeVal");
            if (ptrGetTimeVal == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_GetTimeVal"); return; }

            var ptrGetFwVer = loadExternalFunction(ptrDll, "gcapi_GetFWVer");
            if (ptrGetFwVer == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_GetFWVer"); return; }

            var ptrWrite = loadExternalFunction(ptrDll, "gcapi_Write");
            if (ptrWrite == IntPtr.Zero) return;

            var ptrRead = loadExternalFunction(ptrDll, "gcapi_Read");
            if (ptrRead == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_WriteEX"); return; }

            var ptrWriteEx = loadExternalFunction(ptrDll, "gcapi_WriteEX");
            if (ptrWriteEx == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_WriteEX"); return; }

            var ptrReadEx = loadExternalFunction(ptrDll, "gcapi_ReadEX");
            if (ptrReadEx == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_ReadEX"); return; }

            var ptrCalcPressTime = loadExternalFunction(ptrDll, "gcapi_CalcPressTime");
            if (ptrCalcPressTime == IntPtr.Zero) { system.debug("titanOne.log", "[0] [FAIL] gcapi_CalcPressTime"); return; }

            try
            {
                system.debug("titanOne.log", "[5] Marshal _gcapi_Load");
                _gcapi_Load = (GCAPI_LOAD)Marshal.GetDelegateForFunctionPointer(ptrLoad, typeof(GCAPI_LOAD));

                system.debug("titanOne.log", "[5] Marshal _gcapi_LoadDevice");
                _gcapi_LoadDevice = (GCAPI_LOADDEVICE)Marshal.GetDelegateForFunctionPointer(ptrLoadDevice, typeof(GCAPI_LOADDEVICE));

                system.debug("titanOne.log", "[5] Marshal _gcapi_IsConnected");
                _gcapi_IsConnected = (GCAPI_ISCONNECTED)Marshal.GetDelegateForFunctionPointer(ptrIsConnected, typeof(GCAPI_ISCONNECTED));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Unload");
                _gcapi_Unload = (GCAPI_UNLOAD)Marshal.GetDelegateForFunctionPointer(ptrUnload, typeof(GCAPI_UNLOAD));

                system.debug("titanOne.log", "[5] Marshal _gcapi_GetTimeVal");
                _gcapi_GetTimeVal = (GCAPI_GETTIMEVAL)Marshal.GetDelegateForFunctionPointer(ptrGetTimeVal, typeof(GCAPI_GETTIMEVAL));

                system.debug("titanOne.log", "[5] Marshal _gcapi_GetFwVer");
                _gcapi_GetFwVer = (GCAPI_GETFWVER)Marshal.GetDelegateForFunctionPointer(ptrGetFwVer, typeof(GCAPI_GETFWVER));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Write");
                _gcapi_Write = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));

                system.debug("titanOne.log", "[5] Marshal _gcapi_CalcPressTime");
                _gcapi_CalcPressTime = (GCAPI_CALCPRESSTIME)Marshal.GetDelegateForFunctionPointer(ptrCalcPressTime, typeof(GCAPI_CALCPRESSTIME));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Write");
                _gcapi_Write = (GCAPI_WRITE)Marshal.GetDelegateForFunctionPointer(ptrWrite, typeof(GCAPI_WRITE));

                //TitanOne - modified DLL to accept LED / rumble feedback
                system.debug("titanOne.log", "[5] Marshal _gcapi_WriteEx");
                _gcapi_WriteEx = (GCAPI_WRITE_EX)Marshal.GetDelegateForFunctionPointer(ptrWriteEx, typeof(GCAPI_WRITE_EX));

                system.debug("titanOne.log", "[5] Marshal _gcapi_Read_TO");
                _gcapi_Read_TO = (GCAPI_READ_TO)Marshal.GetDelegateForFunctionPointer(ptrReadEx, typeof(GCAPI_READ_TO));

                system.debug("titanOne.log", "[5] Marshall _gcapi_read_CM");
                _gcapi_Read_CM = (GCAPI_READ_CM)Marshal.GetDelegateForFunctionPointer(ptrReadEx, typeof(GCAPI_READ_CM));
            }
            catch (Exception ex)
            {
                system.debug("titanOne.log", "[0] Fail -> " + ex.ToString());
                system.debug("titanOne.log", "[0] [ERR] Critical failure loading " + _strTODevice + " API.");
                return;
            }

            //TODO: _devID should be set by now on startup
            system.debug("titanOne.log", ">>>" + _devId.ToString());
            if (_gcapi_LoadDevice((ushort)_devId) == 1)
                system.debug("titanOne.log", "[0] Initialize " + _strTODevice + " GCAPI ok");
            else
            {
                system.debug("titanOne.log", "[0] Initialize " + _strTODevice + " failed");
                return;
            }

            loadShortcutKeys();

            system.debug("titanOne.log", "");
        }
Ejemplo n.º 10
0
        public void closeTitanOneInterface()
        {
            string strDevice = "TitanOne";
            string strRef = "TODI";

            if (_gcapi_Unload != null)
                _gcapi_Unload();

            _gcapi_LoadDevice = null;
            _gcapi_Load = null;
            _gcapi_IsConnected = null;
            _gcapi_GetTimeVal = null;
            _gcapi_GetFwVer = null;
            _gcapi_Write = null;
            _gcapi_WriteEx = null;
            _gcapi_WriteRef = null;
            _gcapi_Read_TO = null;
            _gcapi_CalcPressTime = null;
            _gcapi_Unload = null;

            system.debug("titanOne.log", "[OK] Closed " + strDevice + " (" + strRef + ")");
        }