//
        // DISCLAIMER:
        //
        // Those are helper methods needed because `host` object (part of which `USBIPServer` is)
        // is not fully supported in monitor/repl.
        //
        public static void AttachUSBMouse(this USBIPServer usbController, int?port = null)
        {
            if (usbController.Children.Where(m => m.Peripheral.GetType() == typeof(USBMouse)).Count() != 0)
            {
                throw new RecoverableException("There is already a USB mouse connected to the USB/IP server");
            }

            usbController.Register(new USBMouse(), port);
        }
Ejemplo n.º 2
0
        public static void CreateArduinoLoader(this USBIPServer server, CortexM cpu, int?port = null, string name = null)
        {
            var loader = new ArduinoLoader(cpu);

            server.Register(loader, port);

            var emulation = EmulationManager.Instance.CurrentEmulation;

            emulation.ExternalsManager.AddExternal(loader, name ?? "arduinoLoader");
        }
        public static void MoveMouse(this USBIPServer usbController, int x, int y)
        {
            var mouse = usbController.Children.Where(m => m.Peripheral.GetType() == typeof(USBMouse)).Select(m => m.Peripheral).Cast <USBMouse>().FirstOrDefault();

            if (mouse == null)
            {
                throw new RecoverableException("No USB mouse attached to the host. Did you forget to call 'host AttachUSBMouse'?");
            }

            mouse.MoveBy(x, y);
        }
        public static void KeyboardType(this USBIPServer usbController, string text)
        {
            var keyboard = usbController.Children.Where(m => m.Peripheral.GetType() == typeof(USBKeyboard)).Select(m => m.Peripheral).Cast <USBKeyboard>().FirstOrDefault();

            if (keyboard == null)
            {
                throw new RecoverableException("No USB keyboard attached to the host. Did you forget to call 'host AttachUSBKeyboard'?");
            }

            keyboard.TypeText(text);
        }
        public static void KeyboardType(this USBIPServer usbController, string text)
        {
            var keyboard = usbController.Children.Where(m => m.Peripheral.GetType() == typeof(USBKeyboard)).Select(m => m.Peripheral).Cast <USBKeyboard>().FirstOrDefault();

            if (keyboard == null)
            {
                throw new RecoverableException("No USB keyboard attached to the host. Did you forget to call 'host AttachUSBKeyboard'?");
            }

            foreach (var character in text)
            {
                foreach (var scanCode in character.ToKeyScanCodes())
                {
                    keyboard.Press(scanCode);
                }

                foreach (var scanCode in character.ToKeyScanCodes())
                {
                    keyboard.Release(scanCode);
                }
            }
        }
        public static void PendriveFromFile(this USBIPServer usbController, string file, bool persistent = true, int?port = null)
        {
            var pendrive = new USBPendrive(file, persistent: persistent);

            usbController.Register(pendrive, port);
        }