Ejemplo n.º 1
0
        private void USBHostController_DeviceConnectedEvent(USBH_Device device)
        {
            try
            {
                switch (device.TYPE)
                {
                case USBH_DeviceType.MassStorage:
                    lock (this.storageDevices)
                    {
                        var ps = new PersistentStorage(device);
                        ps.MountFileSystem();
                        this.storageDevices.Add(device.ID, ps);
                    }

                    break;

                case USBH_DeviceType.Mouse:
                    lock (this.mice)
                    {
                        var mouse = new USBH_Mouse(device);
                        mouse.SetCursorBounds(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue);
                        this.mice.Add(device.ID, mouse);
                        this.OnMouseConnectedEvent(this, mouse);
                    }

                    break;

                case USBH_DeviceType.Keyboard:
                    lock (this.keyboards)
                    {
                        var keyboard = new USBH_Keyboard(device);
                        this.keyboards.Add(device.ID, keyboard);
                        this.OnKeyboardConnectedEvent(this, keyboard);
                    }

                    break;

                case USBH_DeviceType.Webcamera:
                    ErrorPrint("Use GTM.GHIElectronics.Camera for USB WebCamera support.");
                    break;

                default:
                    ErrorPrint("USB device is not supported by the Gadgeteer driver. More devices are supported by the GHI USB Host driver. Remove the USB Host from the designer, and proceed without using Gadgeteer code.");
                    break;
                }
            }
            catch (Exception)
            {
                ErrorPrint("Unable to identify USB Host device.");
            }
        }
Ejemplo n.º 2
0
 static void DeviceConnectedEvent(USBH_Device device)
 {
     if (device.TYPE == USBH_DeviceType.Keyboard)
     {
         _keyboard          = new USBH_Keyboard(device);
         _keyboard.KeyDown += _keyboard_KeyDown;
         _keyboard.KeyUp   += _keyboard_KeyUp;
         Debug.Print("Keyboard attached");
     }
     else if (device.TYPE == USBH_DeviceType.Mouse)
     {
         _mouse = new USBH_Mouse(device);
         _mouse.SetCursorBounds(0, Core.ScreenWidth, 0, Core.ScreenHeight);
         _mouse.SetCursor(0, 0);
         _mouse.Scale(20);
         _mouse.MouseMove   += _mouse_MouseMove;
         _mouse.MouseDown   += _mouse_MouseDown;
         _mouse.MouseUp     += _mouse_MouseUp;
         Core.MouseAvailable = true;
         Debug.Print("Mouse attached");
     }
 }