public void setTOInterface(DevPID devID) { _devId = devID; system.debug("titanOne.log", "[0] using " + _devId.ToString()); system.debug("titanOne.log", ""); }
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", ""); }
public void setTOInterface(DevPID devID) { _devId = devID; system.debug("titanOne.log", "[0] using " + _devId.ToString()); system.debug("titanOne.log", ""); }