Esempio n. 1
0
        private ReturnValues SetImageNoResize(uint page, Bitmap fipImage)
        {
            if (fipImage == null)
            {
                return(ReturnValues.E_INVALIDARG);
            }
            var returnValues = ReturnValues.E_FAIL;

            try
            {
                if (fipImage == null)
                {
                    return(ReturnValues.E_FAIL);
                }
                lock (_imageLockObject)
                {
                    var local1 = fipImage.LockBits(new Rectangle(0, 0, fipImage.Width, fipImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
                    var local2 = local1.Scan0;
                    var local3 = local1.Stride * fipImage.Height;
                    returnValues = DirectOutputClass.SetImage(_devicePtr, page, 0U, local3, local2);
                    fipImage.UnlockBits(local1);
                }
            }
            catch (Exception ex)
            {
                Common.LogError(8998, ex, "FIPPanel.SetImageNoResize");
            }
            return(returnValues);
        }
Esempio n. 2
0
        public FIPPanel(IntPtr devicePtr, FIPHandler fipHandler) : base(SaitekPanelsEnum.FIP, null)
        {
            _devicePtr  = devicePtr;
            _fipHandler = fipHandler;
            var guidType = Guid.Empty;
            var num      = (int)DirectOutputClass.GetDeviceType(_devicePtr, ref guidType);

            _deviceType = string.Compare(guidType.ToString(), "3E083CD8-6A37-4A58-80A8-3D6A2C07513E", true, CultureInfo.InvariantCulture) == 0 ? DeviceTypes.Fip : DeviceTypes.X52Pro;
        }
Esempio n. 3
0
        public void RemovePage(uint index)
        {
            if (!_pageList.Contains(index))
            {
                return;
            }
            var retVal = DirectOutputClass.RemovePage(_devicePtr, index);

            _pageList.Remove(index);
        }
Esempio n. 4
0
        private DeviceTypes GetDeviceType(IntPtr device)
        {
            Guid        m_guid = Guid.Empty;
            DeviceTypes retVal = DeviceTypes.X52Pro;

            DirectOutputClass.GetDeviceType(device, ref m_guid);

            if (string.Compare(m_guid.ToString(), DirectOutputClass.DeviceTypeFip, true, CultureInfo.InvariantCulture) == 0)
            {
                retVal = DeviceTypes.Fip;
            }

            return(retVal);
        }
Esempio n. 5
0
 public override void Shutdown()
 {
     try
     {
         if (_pageList.Count > 0)
         {
             do
             {
                 DirectOutputClass.RemovePage(_devicePtr, _pageList[0]);
                 _pageList.Remove(_pageList[0]);
             } while (_pageList.Count > 0);
             Closed = true;
         }
     }
     catch (Exception e)
     {
         SetLastException(e);
     }
 }
Esempio n. 6
0
        public bool Initialize()
        {
            _initOk = false;
            try
            {
                _deviceCallback    = DeviceCallback;
                _enumerateCallback = EnumerateCallback;

                if (!File.Exists(@"C:\Program Files\Saitek\DirectOutput\DirectOutput.dll"))
                {
                    //Did not find Saitek drivers
                    Common.LogError(1, "INFO : No Saitek FIP driver found. FIP support not loaded. (assuming no FIPs are connected)");
                    return(false);
                }

                var retVal = DirectOutputClass.Initialize("ABC");
                if (retVal != ReturnValues.S_OK)
                {
                    Common.LogError(1, "FIPHandler failed to init DirectOutputClass. retval = " + retVal);
                    return(false);
                }
                Debug.Print("Init returned: " + retVal);

                retVal = DirectOutputClass.RegisterDeviceCallback(_deviceCallback);
                Debug.Print("Register Device Callback returned: " + retVal);

                retVal = DirectOutputClass.Enumerate(_enumerateCallback);
                if (retVal != ReturnValues.S_OK)
                {
                    Common.LogError(1, "FIPHandler failed to Enumerate DirectOutputClass. retval = " + retVal);
                    return(false);
                }
                Debug.Print("Enumerate Callback returned: " + retVal);
            }
            catch (Exception ex)
            {
                Common.LogError(1, ex, "FIPHandler failed to init.");
                return(false);
            }
            _initOk = true;
            return(true);
        }
Esempio n. 7
0
 public void Close()
 {
     try
     {
         foreach (var fipPanel in _fipPanels)
         {
             fipPanel.Shutdown();
         }
         if (InitOk)
         {
             //No need to deinit if init never worked. (e.g. missing Saitek Drivers)
             DirectOutputClass.Deinitialize();
         }
         //Console.WriteLine(retVal);
     }
     catch (Exception e)
     {
         Common.LogError(234323, e);
     }
 }
Esempio n. 8
0
        public ReturnValues AddPage(uint pageNumber, bool setActive)
        {
            if (_pageList.Contains(pageNumber))
            {
                return(ReturnValues.S_OK);
            }

            var returnValues = DirectOutputClass.AddPage(_devicePtr, (IntPtr)((long)pageNumber), string.Concat(new object[4]
            {
                "0x",
                _devicePtr.ToString(),
                " PageNo: ",
                pageNumber
            }), setActive);

            if (returnValues == ReturnValues.S_OK)
            {
                Debug.Print("Page: " + (pageNumber) + " added");
                _pageList.Add(pageNumber);
            }
            return(returnValues);
        }