Exemple #1
0
 private void CheckDeviceTimeout(object sender, EventArgs eventargs)
 {
     if (_Count > _LastCount && Ready)
     {
         // normal situation
         _LastCount = _Count;
         return;
     }
     else if (_LastCount == _Count && Ready)
     {
         // no data rcvd since last check
         ResourceSoundPlayer.TryToPlay(Properties.Resources.beep_bad);
         Ready      = false;
         _Count     = 0;
         _LastCount = 0;
     }
     else if (_Count > _LastCount && !Ready)
     {
         // device was idle but new data was rcvd
         ResourceSoundPlayer.TryToPlay(Properties.Resources.beep_good);
         _LastCount = _Count;
         Ready      = true;
     }
 }
        public void InjectControllerIntoProcess(Process p)
        {
            if (!Valve.VR.OpenVR.IsHmdPresent())
            {
                throw new PocketStrafeOutputDeviceException("No HMD was found.");
            }
            try
            {
                log.Info("  Injecting " + _InjectDll + " into " + p.ProcessName + " " + "(" + p.Id + ")");
                RemoteHooking.Inject(
                    p.Id,
                    InjectionOptions.DoNotRequireStrongName,
                    _InjectDll,
                    _InjectDll,
                    _ChannelName);

                for (int i = 0; i < 20; i++)
                {
                    if (Iface.Installed)
                    {
                        ResourceSoundPlayer.TryToPlay(Properties.Resources.beep_good);
                        log.Info("Successfully injected!");
                        return;
                    }
                    System.Threading.Thread.Sleep(300);
                }
                throw new PocketStrafeOutputDeviceException("Connecting hook timed out. Make sure Steam VR is running.");
            }
            catch (Exception e)
            {
                ResourceSoundPlayer.TryToPlay(Properties.Resources.beep_bad);
                log.Error("  EasyHook Error: " + e.Message);
                log.Error(e);
                throw new PocketStrafeOutputDeviceException(e.Message);
            }
        }