예제 #1
0
 static void Connect(object xbox)
 {
     try
     { _xbox.Connect((string)xbox); }
     catch (Exception e)
     { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
     finally
     { _xboxLocator.Hide(); }
 }
예제 #2
0
        public void Main()
        {
            try
            {
                int      counter = 0;
                DateTime before  = DateTime.Now;
                while (Xbox.Ping(500))
                {
                    try
                    {
                        if (!mnuPause.Checked && Video.IsActive)
                        {
                            //ParseUserInput();

                            // dont bother updating at full speed if minimized, just poll so we don't lose the stream...
                            if (this.WindowState == FormWindowState.Minimized)
                            {
                                System.Threading.Thread.Sleep(1000);
                            }

                            renderWindow.Image = Video.NextFrame();
                            status.Text        = "Frame: " + Video.FrameNumber; // Xbox.GetUInt32(Xbox.GetUInt32(0xB0033DA0)); (presentation frame number)
                            counter++;
                        }

                        // attempt to recreate videostream before breaking out of the loop
                        // the main reason for it becoming inactive is if its paused for more than 5 seconds or so...
                        if (!Video.IsActive && !Video.Restart())
                        {
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        Xbox.Connect();
                        Video.Restart();
                    }
                    Application.DoEvents();
                }
                TimeSpan elapse = DateTime.Now - before;
                double   fps    = counter / elapse.TotalSeconds;

                Xbox.Disconnect();
                renderWindow.Image = null;
                mnuPause.Checked   = false;
                mnuStep.Enabled    = false;
                status.Text        = "Disconnected";
            }
            catch (Exception)
            {
            }

            renderWindow.Image = GetDefaultImage();
        }
예제 #3
0
        private static void EnterRDCP(Xbox xbox)
        {
            //Get input
            string input = string.Empty;

            xbox.Connect();

            //Loop
            do
            {
                Console.Write("{0}>", xbox.Name);
                input = Console.ReadLine();
                string[] cmd = GetCommand(input);
                if (input == ".")
                {
                }
                else if (cmd.Length > 0 && cmd[0].ToUpper() != "BYE")
                {
                    xbox.SendCommand(cmd[0], cmd.Where((c, i) => i > 0).ToArray());
                    Thread.Sleep(5);
                    xbox.GetResponse();
                }
                else
                {
                    break;  //If user types bye command exit the loop and disconnect
                }
            }while (true);

            //Disconnect
            xbox.Disconnect();
        }
예제 #4
0
        public void ConnectionTest()
        {
            _xbox.Connect(AssemblyGlobals.TestXbox.Ip);
            _xbox.Disconnect();

            // subsequent connections should reconnect
            for (int i = 0; i < 5; i++)
            {
                _xbox.Connect(AssemblyGlobals.TestXbox.Ip);
            }

            for (int i = 0; i < 5; i++)
            {
                _xbox.Reconnect();
            }
        }
예제 #5
0
 public void Initialize()
 {
     _xbox = new Xbox(AssemblyGlobals.Logger);
     _xbox.Connect(AssemblyGlobals.TestXbox.Ip);
     _xbox.CommandSession.SendBufferSize    = 1024;
     _xbox.CommandSession.ReceiveBufferSize = 1024;
 }
        static void Connect(object xboxAddress)
        {
            try
            {
                if (!XBox.Connected || !XBox.Ping())
                {
                    _xbox.Connect((string)xboxAddress);
                    UpdateConnectionInfo();
                }
            }
            catch (Exception e)
            { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
            finally
            { WaitDialog.Hide(); }

            LaunchHalo2();
        }
예제 #7
0
 public void Initialize()
 {
     _xbox = new Xbox(AssemblyGlobals.Logger);
     _xbox.Connect(AssemblyGlobals.TestXbox.Ip);
     _xbox.CommandSession.SendBufferSize    = 1024;
     _xbox.CommandSession.ReceiveBufferSize = 1024;
     _xbox.FileSystem.CreateDirectory(XboxFileSystem.TempDirectory);
 }
예제 #8
0
        public RemoteHaloMapViewModel()
        {
            var xboxes = NameAnsweringProtocol.Discover(10);

            if (xboxes.Any())
            {
                Xbox = xboxes.First();
                Xbox.ConnectionStateChanged += Xbox_ConnectionStateChanged;
                Xbox.Connect();
            }
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteItemObject"/> class using the specified debug Xbox and items.
        /// </summary>
        /// <param name="xbox">The remote debug Xbox.</param>
        /// <param name="remoteItems">The remote items.</param>
        public RemoteItemObject(Xbox xbox, params ItemInformation[] remoteItems)
        {
            //Setup
            xboxAddress = (xbox ?? throw new ArgumentNullException(nameof(xbox))).RemoteEndPoint.Address;
            List <ItemObject> items = new List <ItemObject>();

            //Connect
            xbox.Connect();

            //Set items
            if (remoteItems != null && remoteItems.Length > 0)
            {
                //Add files
                foreach (var file in remoteItems.Where(i => !i.Attributes.HasFlag(FileAttributes.Directory)))
                {
                    items.Add(new ItemObject()
                    {
                        Attributes = (uint)file.Attributes,
                        Created    = file.Created,
                        Directory  = file.Directory,
                        Modified   = file.Modified,
                        Name       = file.Name,
                        Size       = file.Size,
                    });
                }

                //Discover files in directories
                foreach (var directory in remoteItems.Where(i => i.Attributes.HasFlag(FileAttributes.Directory)))
                {
                    //Get items
                    var tempItems = DiscoverObjects(xbox, Path.Combine(directory.Directory, directory.Name));

                    //Localize
                    for (int i = 0; i < tempItems.Length; i++)
                    {
                        tempItems[i].Name      = Path.Combine(tempItems[i].Directory, tempItems[i].Name);
                        tempItems[i].Name      = tempItems[i].Name.Replace(directory.Directory, string.Empty);
                        tempItems[i].Directory = directory.Directory;
                    }

                    //Add
                    items.AddRange(tempItems);
                }

                //Set
                this.items = items.ToArray();
            }

            //Disconnect
            xbox.Disconnect();
        }
예제 #10
0
        private static void Test()
        {
            Xbox xbox = NameAnsweringProtocol.Discover(15).FirstOrDefault();

            if (xbox != null)
            {
                xbox.Connect();
                if (xbox.Connected)
                {
                    if (xbox.Screenshot(out var screenshot))
                    {
                        screenshot.Save(@"F:\screenshot.png", System.Drawing.Imaging.ImageFormat.Png);
                    }
                }
            }
        }
예제 #11
0
        static void Main(string[] args)
        {
            string ipString = "";

            if (args.Length == 1)
            {
                ipString = args[0];
            }

            IPAddress ip = null;

            while (ip == null)
            {
                if (IPAddress.TryParse(ipString, out ip))
                {
                    break;
                }
                else
                {
                    if (ipString != "")
                    {
                        Console.Error.WriteLine($"Unable to parse {ipString} as an IP Address");
                    }

                    Console.Write("Enter Xbox IP: ");
                    ipString = Console.ReadLine();
                }
            }

            var xbox = new Xbox(new ConsoleLogger());

            xbox.Connect(ip, ViridiX.Linguist.Network.XboxConnectionOptions.PerformanceMode);
            xbox.CommandSession.SendBufferSize    = 80192;
            xbox.CommandSession.ReceiveBufferSize = 80192;
            xbfs = xbox.FileSystem;

            var localRoot = Path.Combine(Directory.GetCurrentDirectory(), ip.ToString());

            foreach (var drive in xbfs.DriveLetters)
            {
                DownloadDrive(drive, localRoot);
            }

            Console.WriteLine("Done");
            Console.ReadLine();
        }
예제 #12
0
        private MemoryStream GetFileContents(ItemObject[] items, int index)
        {
            //Prepare
            MemoryStream ms = null;

            //Check
            if (items != null && index < items.Length)
            {
                //Prepare
                ms = new MemoryStream();
                ItemObject item = items[index];

                //Setup
                byte[] buffer = new byte[item.Size];

                //Find xbox
                Xbox xbox = NameAnsweringProtocol.Discover(xboxAddress);
                try
                {
                    //Connect
                    xbox.Connect();

                    //Download
                    if (!xbox.GetData(Path.Combine(item.Directory, item.Name), ref buffer))
                    {
                        buffer = new byte[1];
                    }

                    //Disconnect
                    xbox.Disconnect();
                }
                catch { buffer = new byte[1]; }

                //Check
                if (buffer.Length == 0)
                {
                    buffer = new byte[1];
                }
                ms.Write(buffer, 0, buffer.Length);
            }

            //Return
            return(ms);
        }
예제 #13
0
        private static void InitYeloDebug(string IP)
        {
            xboxDebug = new YeloDebug.Xbox();
            // Do we really need a 5 second timeout period? How about half that?
            xboxDebug.Timeout = 2500;

            // If we are presented with an IP, use it
            if (IP.Split('.').Length == 4)
            {
                xboxDebug.ConnectToIP(IP);
            }
            // otherwise, use auto-detect
            else
            {
                System.Collections.Generic.List <DebugConnection> cons = xboxDebug.QueryXboxConnections();
                xboxDebug.Connect(cons[0].Name);
            }
            _debugName = xboxDebug.DebugName;
            _debugIP   = xboxDebug.DebugIP.ToString();
        }
예제 #14
0
        public FileUploadDialog(Xbox xbox, string destinationDirectoryName, params LocalObject[] objects) : this()
        {
            //Setup
            Xbox                       = xbox ?? throw new ArgumentNullException(nameof(xbox));
            m_LocalObjects             = objects ?? throw new ArgumentNullException(nameof(objects));
            m_DestinationDirectoryName = destinationDirectoryName;

            //Connect
            xbox.Connect();

            //Loop
            foreach (LocalObject localObject in objects.Where(o => o.IsDirectory))
            {
                foreach (string directory in localObject.NestedDirectories)
                {
                    //Get info
                    DirectoryInfo info       = new DirectoryInfo(directory);
                    string        targetPath = GetRemoteName(m_DestinationDirectoryName, localObject.Root, directory);

                    //Make directory
                    if (xbox.MakeDirectory(targetPath))
                    {
                        xbox.SetAttributes(targetPath, info.CreationTime, info.LastWriteTime, info.Attributes);
                    }
                }
            }

            //Disconnect
            xbox.Disconnect();

            //Get file count
            m_FileCount = objects.Count(o => o.IsFile) + objects.SelectMany(o => o.NestedFiles).Count();

            //Setup
            xbox.UploadFileCompleted   += Xbox_UploadFileCompleted;
            xbox.UploadProgressChanged += Xbox_UploadProgressChanged;
        }
예제 #15
0
 public void Initialize()
 {
     _xbox = new Xbox(AssemblyGlobals.Logger);
     _xbox.Connect(AssemblyGlobals.TestXbox.Ip);
 }
예제 #16
0
        void XCE_Shown(object sender, System.EventArgs e)
        {
            try
            {
                this.WindowState = FormWindowState.Normal;
                System.Threading.Thread.Sleep(1000);

                Prompt.Show();
                while (!Prompt.IsDisposed)                  // waits for it to be disposed
                {
                    System.Threading.Thread.Sleep(1);
                    Application.DoEvents();
                }
                Input = new Input(this);
                Xbox.Connect(Prompt.DebugName);
                Xbox.Gamepad.InitializeControllerHook();
                Xbox.Gamepad.OverrideControllers(true);

                while (running)
                {
                    NewInput = new InputState();
                    //DateTime before = DateTime.Now;

                    ParseKeyboardInput(ref NewInput);

                    #region Mouse Input
                    MouseState Mouse = Input.GetMouseState();
                    if (Mouse.GetMouseButtons()[0] > 0)                     // left click
                    {
                        NewInput.AnalogButtons[(int)AnalogButtons.RightTrigger] = 0xFF;
                    }
                    if (Mouse.GetMouseButtons()[1] > 0)                     // right click
                    {
                        NewInput.AnalogButtons[(int)AnalogButtons.LeftTrigger] = 0xFF;
                    }
                    if (Mouse.GetMouseButtons()[2] > 0)                     // middle click
                    {
                        NewInput.Buttons |= Buttons.RightThumb;
                    }

                    /*
                     * // get mouse input with separate function...we need to capture constantly instead of 30fps
                     *
                     * NewInput.ThumbRX = (short)(Mouse.X * 0x7FF);
                     * NewInput.ThumbRY = (short)(-Mouse.Y * 0x7FF);
                     *
                     *
                     * //NewInput.ThumbRX = (short)(((float)short.MaxValue * (Mouse.X / 2)) / 4);
                     * //NewInput.ThumbRY = (short)(-((float)short.MaxValue * (Mouse.Y / 2) / 4));
                     */
                    #endregion


                    //int PollsPerSecond = 30;
                    //System.Threading.Thread.Sleep(1000 / PollsPerSecond);
                    System.Threading.Thread.Sleep(1);
                    Xbox.Gamepad.SetState(0, NewInput);
                    Application.DoEvents();
                }
            }
            catch
            {
                Hide();
                MessageBox.Show("You slipped one past the goalie, don't let it happen again ;P", "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Close();
            }
        }